How to install SSM Agent on Multiple Linux Servers using Ansible

Ansible Playbook to Install SSM Agent on Multiple Linux Servers

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
    - name: Install unzip (required for SSM agent installation)
        name: unzip
        state: present

    - name: Download SSM agent installer
        url: ""  # Replace with the URL for the appropriate SSM agent installer for your Linux distribution
        dest: /tmp/amazon-ssm-agent.rpm

    - name: Install SSM agent
        name: /tmp/amazon-ssm-agent.rpm
        state: present
      notify: restart ssm-agent

    - name: restart ssm-agent
        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

Your email address will not be published. Required fields are marked *