Skip to content

Commit

Permalink
Add amazon ssm agent and the ability to provision on boot through /bo…
Browse files Browse the repository at this point in the history
…ot/ssm
  • Loading branch information
mattsoftware committed Mar 12, 2018
1 parent 8af78a3 commit 21237a6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stage2/03-msw-tweaks/00-packages
Original file line number Diff line number Diff line change
@@ -1 +1 @@
vim tmux git bc jq locate gawk fbi
vim tmux git bc jq locate gawk fbi awscli ansible python-lxml
5 changes: 5 additions & 0 deletions stage2/03-msw-tweaks/01-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

install -m 644 files/msw_provision.service ${ROOTFS_DIR}/etc/systemd/system/msw_provision.service
install -m 644 files/msw_provisioned.service ${ROOTFS_DIR}/etc/systemd/system/msw_provisioned.service
install -m 644 files/ssmsetup.service ${ROOTFS_DIR}/etc/systemd/system/ssmsetup.service

on_chroot << EOF
curl https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_arm/amazon-ssm-agent.deb -o /root/amazon-ssm-agent.deb
dpkg -i /root/amazon-ssm-agent.deb
systemctl disable amazon-ssm-agent
systemctl enable msw_provision
systemctl enable msw_provisioned
systemctl enable ssmsetup
EOF

16 changes: 16 additions & 0 deletions stage2/03-msw-tweaks/files/ssmsetup.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Tells the system that it wants to use SSM with the configuration in the /boot/ssm file
ConditionPathExists=/boot/ssm
Before=amazon-ssm-agent.service
Requires=amazon-ssm-agent.service
Wants=network-online.service
After=network-online.service

[Service]
Type=oneshot
ExecStart=/bin/bash -c "set -a && source /boot/ssm && amazon-ssm-agent --register --code \"$SSM_CODE\" --id \"$SSM_ID\" --region \"$SSM_REGION\" -y"
ExecStart=/bin/rm -f /boot/ssm
ExecStartPost=/bin/systemctl try-restart amazon-ssm-agent

[Install]
WantedBy=multi-user.target

0 comments on commit 21237a6

Please sign in to comment.