Introduction: This Ansible playbook automates the installation of the AWS Systems Manager (SSM) agent on multiple Linux servers. The SSM agent enables you to remotely manage your Linux instances in the AWS environment using AWS Systems Manager. Follow the steps below to use this playbook:
1. Ensure Ansible is Installed: Make sure Ansible is installed on your system. You can install Ansible using package managers like apt or yum or follow the official documentation for installation instructions.
2. Create Ansible Playbook: Create a playbook file (e.g., install_ssm_agent.yml
) with the following content:
---
- name: Install SSM agent on Linux servers
hosts: your_server_group # Replace with the group name or list of servers where you want to install SSM agent
become: true # To escalate privileges for installation
tasks:
- name: Install unzip (required for SSM agent installation)
package:
name: unzip
state: present
- name: Download SSM agent installer
get_url:
url: "https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm" # Replace with the URL for the appropriate SSM agent installer for your Linux distribution
dest: /tmp/amazon-ssm-agent.rpm
- name: Install SSM agent
yum:
name: /tmp/amazon-ssm-agent.rpm
state: present
notify: restart ssm-agent
handlers:
- name: restart ssm-agent
service:
name: amazon-ssm-agent
state: restarted
3. Run the Playbook:
Run the playbook using the
ansible-playbook
command:
ansible-playbook -i inventory_file install_ssm_agent.yml
Note: Replace inventory_file
with the path to your Ansible inventory file or specify the hosts directly in the playbook.
Make sure to replace your_server_group
with the appropriate group name or list of servers where you want to install the SSM agent.
Also, ensure that the SSM agent installer URL (url
parameter) is correct for your Linux distribution.
This playbook will install the SSM agent on the specified servers, ensuring that the unzip
package is installed (required for installation), downloading the SSM agent installer, and then installing it using the appropriate package manager (yum
in this case). After installation, it will restart the SSM agent service.
Leave a Reply