cloud-init.tpl 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #cloud-config
  2. preserve_hostname: false
  3. salt-master: ${salt_master}
  4. # Write files happens early
  5. write_files:
  6. - content: |
  7. proxy=http://${proxy}:80
  8. path: /etc/yum.conf
  9. append: true
  10. - content: |
  11. [global]
  12. proxy=${proxy}
  13. path: /etc/pip.conf
  14. - content: |
  15. export HTTPS_PROXY=http://${proxy}:80
  16. export HTTP_PROXY=http://${proxy}:80
  17. export NO_PROXY=localhost,127.0.0.1,169.254.169.254,pvt.xdrtest.accenturefederalcyber.com,pvt.xdr.accenturefederalcyber.com,reposerver.msoc.defpoint.local,jenkins.msoc.defpoint.local,pod1search-splunk-sh.msoc.defpoint.local,s3.amazonaws.com,ssm.${ aws_region }.amazonaws.com,ec2messages.${ aws_region }.amazonaws.com,ec2.${ aws_region }.amazonaws.com,ssmmessages.${ aws_region }.amazonaws.com,iratemoses.mdr.defpoint.com,jira.mdr.defpoint.com,reposerver.pvt.xdr.accenturefederalcyber.com,jenkins.pvt.xdr.accenturefederalcyber.com,pod1search-splunk-sh.pvt.xdr.accenturefederalcyber.com,reposerver.pvt.xdrtest.accenturefederalcyber.com,jenkins.pvt.xdrtest.accenturefederalcyber.com,pod1search-splunk-sh.pvt.xdrtest.accenturefederalcyber.com,iratemoses.xdr.accenturefederalcyber.com,jira.xdr.accenturefederalcyber.com,iratemoses.xdrtest.accenturefederalcyber.com,jira.xdrtest.accenturefederalcyber.com
  18. export https_proxy=$HTTPS_PROXY
  19. export http_proxy=$HTTP_PROXY
  20. export no_proxy=$NO_PROXY
  21. path: /etc/profile.d/proxy.sh
  22. - content: |
  23. master: ${salt_master}
  24. path: /etc/salt/minion
  25. - content: |
  26. grains:
  27. environment: ${ environment }
  28. aws_region: ${ aws_region }
  29. aws_partition: ${ aws_partition }
  30. aws_partition_alias: ${ aws_partition_alias }
  31. path: /etc/salt/minion.d/cloud_init_grains.conf
  32. #yum_repos:
  33. # epel-release:
  34. # baseurl: http://download.fedoraproject.org/pub/epel/7/$basearch
  35. # enabled: false
  36. # failovermethod: priority
  37. # gpgcheck: true
  38. # gpgkey: http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
  39. # name: Extra Packages for Enterprise Linux 7 - Release
  40. packages:
  41. - vim
  42. package_update: true # Always patch
  43. growpart:
  44. mode: auto
  45. devices: [ '/', '/var', '/var/log', '/var/log/audit', '/var/tmp', '/tmp', '/home' ]
  46. ignore_growroot_disabled: false
  47. bootcmd:
  48. - "INSTANCE_ID=`/usr/bin/curl -f --connect-timeout 1 --silent http://169.254.169.254/latest/meta-data/instance-id | tail -c 3`"
  49. - "/bin/hostnamectl set-hostname customer-portal-$INSTANCE_ID'.${zone}'"
  50. - "echo customer-portal-$INSTANCE_ID'.${zone}' > /etc/salt/minion_id"
  51. runcmd:
  52. - /bin/systemctl restart salt-minion
  53. - /bin/systemctl enable salt-minion
  54. - /bin/systemctl start amazon-ssm-agent
  55. - /bin/systemctl enable amazon-ssm-agent
  56. - /usr/sbin/aide --update --verbose=0
  57. - /bin/cp /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
  58. # Allow Salt to setup Portal for autoscaling group
  59. - "/bin/echo MARKER: START SALT SYNC"
  60. - /bin/salt-call saltutil.sync_all refresh=True
  61. # Chicken/egg problem. We need pillars to get correct grains, and grains to get correct pillars.
  62. # Sleep needs to be this long due to the magical forces inside of the salt master that govern pillars.
  63. # It takes 30 minutes to fully start portal docker container.
  64. - /bin/sleep 420
  65. - /bin/salt-call --refresh-grains-cache saltutil.refresh_modules
  66. - /bin/sleep 60
  67. - /bin/salt-call --refresh-grains-cache saltutil.refresh_grains
  68. - /bin/sleep 60
  69. - /bin/salt-call --refresh-grains-cache saltutil.refresh_pillar
  70. - /bin/sleep 60
  71. # Recording our initial values is useful for troubleshooting
  72. - /bin/salt-call pillar.get aws_registry_account --out=text > /root/pillar.aws_registry_account.yml
  73. - /bin/salt-call pillar.items > /root/pillars.initial_highstate.yml
  74. - /bin/salt-call grains.items > /root/grains.initial_highstate.yml
  75. - "/bin/echo MARKER: START FIRST HIGHSTATE"
  76. - /bin/salt-call state.highstate
  77. - "/bin/echo MARKER: END FIRST HIGHSTATE"
  78. - "/bin/echo MARKER: START SECOND HIGHSTATE"
  79. - /bin/salt-call state.highstate
  80. - "/bin/echo MARKER: END SECOND HIGHSTATE"
  81. # Either final message or power state, but probably not both
  82. final_message: "The system is up after $UPTIME seconds"
  83. #power_state:
  84. # delay: "+30"
  85. # mode: reboot
  86. # message: "System configured after $UPTIME seconds"
  87. # timeout: 300
  88. # condition: true