Guest User

Untitled

a guest
Jul 6th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 9.75 KB | None | 0 0
  1. # -----------------------------------------------------------
  2. # File Read on RHEL8 Box
  3. # -----------------------------------------------------------
  4. [root@rhel8-base ~]# curl http://169.254.169.254/latest/user-data
  5. #cloud-config
  6. # Cloud-Config file must start with the above line or bad things happen.
  7. datasource:
  8.   Ec2:
  9.     strict_id: false
  10.  
  11. # Ensure Password Auth is Enabled
  12. ssh_pwauth: true
  13.  
  14. # Configure some prereq stuff semi-statically so the test images can build/work
  15. # Add hostfile entry for this server to /etc/hosts
  16. # Configure static Facter Values
  17. # Create root/initialbuild directory
  18. # Ensure Password SSH Config is ENABLED
  19. runcmd:
  20.   - echo "$(/opt/puppetlabs/bin/facter networking.interfaces.eth0.bindings.0.address) $(/opt/puppetlabs/bin/facter fqdn) $(/opt/puppetlabs/bin/facter hostname)" >> /etc/hosts
  21.   - echo "$(/opt/puppetlabs/bin/facter fqdn)" > /etc/hostname
  22.   - [mkdir, -p, /etc/facter/facts.d]
  23.   - echo "payx_network_segment=zone1" > /etc/facter/facts.d/payx_network_segment.txt
  24.   - echo "payx_datacenter=webster" > /etc/facter/facts.d/payx_datacenter.txt
  25.   - echo "payx_network_location=webster_zone1" > /etc/facter/facts.d/payx_network_location.txt
  26.   - echo "payx_environment=prod" > /etc/facter/facts.d/payx_environment.txt
  27.   - echo "payx_tan=no" > /etc/facter/facts.d/payx_tan.txt
  28.   - echo "payx_multi=no" > /etc/facter/facts.d/payx_multi.txt
  29.   - [systemctl, disable, --no-block, NetworkManager.service]
  30.   - [systemctl, enable, --no-block, puppet.service]
  31.   - [mkdir, -p, /root/initialbuild]
  32.   - [sed, -i, 's/PasswordAuthentication no/PasswordAuthentication yes/', /etc/ssh/sshd_config]
  33.  
  34. final_message: Test Instance is up and ready for Inspec Testing!
  35.  
  36.  
  37. # -----------------------------------------------------------
  38. # File Read on RHEL7 Box
  39. # -----------------------------------------------------------
  40. [root@rhel7-test-hen ~]# curl http://169.254.169.254/latest/user-data
  41. #cloud-config
  42. # Cloud-Config file must start with the above line or bad things happen.
  43. datasource:
  44.   Ec2:
  45.     strict_id: false
  46.  
  47. # Ensure Password Auth is Enabled
  48. ssh_pwauth: true
  49.  
  50. # Configure some prereq stuff semi-statically so the test images can build/work
  51. # Add hostfile entry for this server to /etc/hosts
  52. # Configure static Facter Values
  53. # Create root/initialbuild directory
  54. # Ensure Password SSH Config is ENABLED
  55. runcmd:
  56.   - echo "$(/opt/puppetlabs/bin/facter networking.interfaces.eth0.bindings.0.address) $(/opt/puppetlabs/bin/facter fqdn) $(/opt/puppetlabs/bin/facter hostname)" >> /etc/hosts
  57.   - echo "$(/opt/puppetlabs/bin/facter fqdn)" > /etc/hostname
  58.   - [mkdir, -p, /etc/facter/facts.d]
  59.   - echo "payx_network_segment=zone1" > /etc/facter/facts.d/payx_network_segment.txt
  60.   - echo "payx_datacenter=webster" > /etc/facter/facts.d/payx_datacenter.txt
  61.   - echo "payx_network_location=webster_zone1" > /etc/facter/facts.d/payx_network_location.txt
  62.   - echo "payx_environment=prod" > /etc/facter/facts.d/payx_environment.txt
  63.   - echo "payx_tan=no" > /etc/facter/facts.d/payx_tan.txt
  64.   - echo "payx_multi=no" > /etc/facter/facts.d/payx_multi.txt
  65.   - [systemctl, disable, --no-block, NetworkManager.service]
  66.   - [systemctl, enable, --no-block, puppet.service]
  67.   - [mkdir, -p, /root/initialbuild]
  68.   - [sed, -i, 's/PasswordAuthentication no/PasswordAuthentication yes/', /etc/ssh/sshd_config]
  69.  
  70. final_message: Test Instance is up and ready for Inspec Testing!
  71.  
  72.  
  73.  
  74. # -----------------------------------------------------------
  75. ## Identical Hashes of files from metadata service as well:
  76. # -----------------------------------------------------------
  77. [root@rhel8-base ~]# curl http://169.254.169.254/latest/user-data | md5sum
  78.   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
  79.                                  Dload  Upload   Total   Spent    Left  Speed
  80. 100  1466  100  1466    0     0   3878      0 --:--:-- --:--:-- --:--:--  3868
  81. e5d8cece78385ef0a54de242fd856a75  -
  82.  
  83. [root@rhel7-test-hen ~]# curl http://169.254.169.254/latest/user-data | md5sum
  84.   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
  85.                                  Dload  Upload   Total   Spent    Left  Speed
  86. 100  1466  100  1466    0     0   3401      0 --:--:-- --:--:-- --:--:--  3401
  87. e5d8cece78385ef0a54de242fd856a75  -
  88.  
  89.  
  90.  
  91.  
  92. # -----------------------------------------------------------
  93. ## Proof that "User Data" is actually read (not disabled via config)
  94.  
  95. # -----------------------------------------------------------
  96.  
  97. [root@rhel8-base ~]# cloud-init analyze show | grep user-data
  98. |`->reading and applying user-data @96.36500s +00.00300s
  99.  
  100. [root@rhel7-test-hen ~]# cloud-init analyze show | grep user-data
  101. |`->reading and applying user-data @100.75800s +00.02300s
  102.  
  103.  
  104.  
  105. # -----------------------------------------------------------
  106. ## Error message noted on RHEL8
  107. # -----------------------------------------------------------
  108. [root@rhel8-base ~]# cat /var/log/cloud-init.log | grep "text/x-not-multipart"
  109. 2020-07-01 18:38:33,270 - __init__.py[DEBUG]: {'MIME-Version': '1.0', 'Content-Type': 'text/x-not-multipart', 'Content-Disposition': 'attachment; filename="part-001"'}
  110. 2020-07-01 18:38:33,270 - __init__.py[DEBUG]: Empty payload of type text/x-not-multipart
  111.  
  112.  
  113. # -----------------------------------------------------------
  114. ## Absence of this error on RHEL7:
  115. # -----------------------------------------------------------
  116. [root@rhel7-test-hen ~]# cat /var/log/cloud-init.log | grep "text/x-not-multipart"
  117. [root@rhel7-test-hen ~]#
  118.  
  119.  
  120.  
  121. # -----------------------------------------------------------
  122. ## User-Data file EMPTY on RHEL8 - correct on RHEL7
  123. # -----------------------------------------------------------
  124. [root@rhel8-base ~]# cat /var/lib/cloud/instance/user-data.txt
  125. [root@rhel8-base ~]#
  126.  
  127. [root@rhel7-test-hen ~]# cat /var/lib/cloud/instance/user-data.txt
  128. #cloud-config
  129. # Cloud-Config file must start with the above line or bad things happen.
  130. datasource:
  131.   Ec2:
  132.     strict_id: false
  133.  
  134. # Ensure Password Auth is Enabled
  135. ssh_pwauth: true
  136.  
  137. # Configure some prereq stuff semi-statically so the test images can build/work
  138. # Add hostfile entry for this server to /etc/hosts
  139. # Configure static Facter Values
  140. # Create root/initialbuild directory
  141. # Ensure Password SSH Config is ENABLED
  142. runcmd:
  143.   - echo "$(/opt/puppetlabs/bin/facter networking.interfaces.eth0.bindings.0.address) $(/opt/puppetlabs/bin/facter fqdn) $(/opt/puppetlabs/bin/facter hostname)" >> /etc/hosts
  144.   - echo "$(/opt/puppetlabs/bin/facter fqdn)" > /etc/hostname
  145.   - [mkdir, -p, /etc/facter/facts.d]
  146.   - echo "payx_network_segment=zone1" > /etc/facter/facts.d/payx_network_segment.txt
  147.   - echo "payx_datacenter=webster" > /etc/facter/facts.d/payx_datacenter.txt
  148.   - echo "payx_network_location=webster_zone1" > /etc/facter/facts.d/payx_network_location.txt
  149.   - echo "payx_environment=prod" > /etc/facter/facts.d/payx_environment.txt
  150.   - echo "payx_tan=no" > /etc/facter/facts.d/payx_tan.txt
  151.   - echo "payx_multi=no" > /etc/facter/facts.d/payx_multi.txt
  152.   - [systemctl, disable, --no-block, NetworkManager.service]
  153.   - [systemctl, enable, --no-block, puppet.service]
  154.   - [mkdir, -p, /root/initialbuild]
  155.   - [sed, -i, 's/PasswordAuthentication no/PasswordAuthentication yes/', /etc/ssh/sshd_config]
  156.  
  157. final_message: Test Instance is up and ready for Inspec Testing!
  158.  
  159.  
  160.  
  161.  
  162. # -----------------------------------------------------------
  163. ## user-data.txt.i file on rhel8 shows weird mimetype issues:
  164. # -----------------------------------------------------------
  165. [root@rhel8-base ~]# cat /var/lib/cloud/instance/user-data.txt.i
  166. Content-Type: multipart/mixed; boundary="===============9020804030255639540=="
  167. MIME-Version: 1.0
  168. Number-Attachments: 1
  169.  
  170. --===============9020804030255639540==
  171. MIME-Version: 1.0
  172. Content-Type: text/x-not-multipart
  173. Content-Disposition: attachment; filename="part-001"
  174.  
  175.  
  176. --===============9020804030255639540==--
  177. [root@rhel8-base ~]#
  178.  
  179.  
  180. Seems OK on RHEL7
  181. [root@rhel7-test-hen ~]# cat /var/lib/cloud/instance/user-data.txt.i
  182. From nobody Wed Jul  1 15:00:11 2020
  183. Content-Type: multipart/mixed; boundary="===============4957072323274166186=="
  184. MIME-Version: 1.0
  185. Number-Attachments: 1
  186.  
  187. --===============4957072323274166186==
  188. MIME-Version: 1.0
  189. Content-Type: text/cloud-config
  190. Content-Disposition: attachment; filename="part-001"
  191.  
  192. #cloud-config
  193. # Cloud-Config file must start with the above line or bad things happen.
  194. datasource:
  195.   Ec2:
  196.     strict_id: false
  197.  
  198. # Ensure Password Auth is Enabled
  199. ssh_pwauth: true
  200.  
  201. # Configure some prereq stuff semi-statically so the test images can build/work
  202. # Add hostfile entry for this server to /etc/hosts
  203. # Configure static Facter Values
  204. # Create root/initialbuild directory
  205. # Ensure Password SSH Config is ENABLED
  206. runcmd:
  207.   - echo "$(/opt/puppetlabs/bin/facter networking.interfaces.eth0.bindings.0.address) $(/opt/puppetlabs/bin/facter fqdn) $(/opt/puppetlabs/bin/facter hostname)" >> /etc/hosts
  208.   - echo "$(/opt/puppetlabs/bin/facter fqdn)" > /etc/hostname
  209.   - [mkdir, -p, /etc/facter/facts.d]
  210.   - echo "payx_network_segment=zone1" > /etc/facter/facts.d/payx_network_segment.txt
  211.   - echo "payx_datacenter=webster" > /etc/facter/facts.d/payx_datacenter.txt
  212.   - echo "payx_network_location=webster_zone1" > /etc/facter/facts.d/payx_network_location.txt
  213.   - echo "payx_environment=prod" > /etc/facter/facts.d/payx_environment.txt
  214.   - echo "payx_tan=no" > /etc/facter/facts.d/payx_tan.txt
  215.   - echo "payx_multi=no" > /etc/facter/facts.d/payx_multi.txt
  216.   - [systemctl, disable, --no-block, NetworkManager.service]
  217.   - [systemctl, enable, --no-block, puppet.service]
  218.   - [mkdir, -p, /root/initialbuild]
  219.   - [sed, -i, 's/PasswordAuthentication no/PasswordAuthentication yes/', /etc/ssh/sshd_config]
  220.  
  221. final_message: Test Instance is up and ready for Inspec Testing!
  222.  
  223. --===============4957072323274166186==--[root@rhel7-test-hen ~]#
Add Comment
Please, Sign In to add comment