Skip to content

Commit a53e8b1

Browse files
authored
Merge pull request #13 from colinhoglund/master
add support for managed instance registration
2 parents 037779e + 7e8bf9a commit a53e8b1

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
---
22
# defaults file for aws-ssm
33
url: 'amd64'
4+
#aws_ssm_activation_code:
5+
#aws_ssm_activation_id:
6+
#aws_ssm_ec2_region: "{{ec2_region}}"

handlers/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
---
2-
# handlers file for aws-ssm
2+
3+
- name: restart amazon-ssm-agent
4+
service:
5+
name: amazon-ssm-agent
6+
state: restarted

tasks/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
deb: "https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_{{ url }}/amazon-ssm-agent.deb"
2727
when: ansible_os_family == 'Debian'
2828

29+
- include: register.yml
30+
when: aws_ssm_activation_code is defined and aws_ssm_activation_id is defined
31+
2932
- name: Register to service
3033
become: yes
3134
become_user: root

tasks/register.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
3+
- name: Check if node is registered
4+
stat:
5+
path: /var/lib/amazon/ssm/registration
6+
register: stat_result
7+
8+
- name: Register managed instance
9+
command: amazon-ssm-agent -register -clear -code '{{aws_ssm_activation_code}}' -id '{{aws_ssm_activation_id}}' -region '{{aws_ssm_ec2_region}}' -y
10+
notify: restart amazon-ssm-agent
11+
when: not stat_result.stat.exists

0 commit comments

Comments
 (0)