Git Product home page Git Product logo

cloud-aws-training / run-ansible-playbook-from-ssm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from miztiik/run-ansible-playbook-from-ssm

0.0 2.0 0.0 188 KB

Execute configuration management directives using Ansible on your instances using State Manager.

Home Page: https://www.udemy.com/course/aws-cloud-development-kit-from-beginner-to-professional/?referralCode=E15D7FB64E417C547579&couponCode=AWS_4U_MAY

run-ansible-playbook-from-ssm's Introduction

Running Ansible playbook using AWS Systems Manager

AWS Systems Manager lets you run Ansible Playbook on any number of servers(without Ansible Tower), without an SSH connection. We will see how to execute configuration management directives using Ansible on your instances using State Manager and Run Command, and the new AWS-RunAnsiblePlaybook public document.

Fig : Serverless AWS KMS Sentry

Follow this article in Youtube

  1. Pre-Requisities

    1. IAM Role - i.e ManagedInstanceRole - with managed permissions Get Help for setting up IAM Role
      • AmazonEC2RoleforSSM - To allow Lambda to log events
  2. Prepare Target Instances

    Lets use a RedHat 7.x Linux instances as our target instance.

    1. Assign the IAM Role created in the prerequisite
    2. Install SSM Agent
      sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
      sudo systemctl enable amazon-ssm-agent
      sudo systemctl start amazon-ssm-agent
      sudo systemctl status amazon-ssm-agent
    3. Install Ansible in Redhat 7
      sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
      sudo yum -y install ansible
    4. Tag the instance
      TagKey:OS
      TagValue:RedHat
      
  3. Create SSM State Manager

    • Choose State Manager from the System Manager Services
    • Click on Create Association
    • Select the AWS-RunAnsiblePlaybook
    • For Targets Choose Specifying tags
    • Choose appropriate schedule.
    • In the Parameters Section, paste the playbook YAML directly.
    • Define the max errors as 1. This means that if the execution encounters 1 error it will stop on the remaining targets.
  4. Testing the solution

    Create an adhoc run using the Run Command manually, check the S3 Logs for execution results.

  5. ToDo

    1. Load the playbook into CodeCommit and bring it under version control.
    2. or Use S3 version control for the playbook(s) to be stored.
References

[1] - AWS Docs - Ansible from SSM

run-ansible-playbook-from-ssm's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.