Installing AWS SSM agents in EC2 instances using Ansible 2.0.

Posted By : Ankit Arora | 25-Sep-2017

Installing AWS SSM agents in EC2 instances using Ansible 2.0.

AWS SSM also provides us a service to provision the servers from AWS dashboard.

To work with SSM, we need to install SSM agents first on EC2 instances.

 

Writing inventory file:

[testserver]

255.255.255.255

 

Writing ssm-playbook.yml

---

 - hosts: belfrics

   user: ubuntu

   roles:

     - ssm

 

Writing vars.yml

---

 

## Variables for installing SSM agent on Ubuntu

 

# Directory in which package will be installed


temp_ssm: "/tmp/ssm" # URL from package will be downloaded. ssm_url: "https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb"

 

 

Writing roles/ssm/tasks/main.yml file:

---

 - name: Creating SSM directory  in tmp

   file:

    path: "{{ temp_ssm }}"

    state: directory

   

 - name: Install deb file for Debian family 32/64-bit

   become: yes

   become_user: root

   apt:

    deb: "https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb"


 - name: Starting SSM service    service:     name: amazon-ssm-agent     enabled: yes     state: started

 

Finally,

ansible-playbook -i inventory ssm-playbook.yml

 

About Author

Author Image
Ankit Arora

Ankit is a Redhat Certified Engineer and Cloud Engineer.

Request for Proposal

Name is required

Comment is required

Sending message..