Git Product home page Git Product logo

ansible_aws_assignment's Introduction

Ansible module to modify ec2 serial console access

This module can be used to enable or disable ec2 serial console access for an AWS account. You can refer more details about serial console access at this AWS documentation.

Pre-requisites

To run the library you will need ansible and python installed locally. You will also need boto3 and botocore libraries. You will also need an AWS account (free tier).

Versions

Software Version
Python >=3.6
Ansible >=2.9
boto3 >=1.22.0
botocore >=1.25.0

AWS Credentials

Create an IAM user with minimum below policy attached to it.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ec2:GetSerialConsoleAccessStatus",
        "ec2:EnableSerialConsoleAccess",
        "ec2:DisableSerialConsoleAccess"
      ],
      "Resource": "*"
    }
  ]
}

Enable programatic access for this user and get AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY generated. You will also need the AWS Region where you want to set ec2 serial console access.

Set below environment variables for ansible to connect to your AWS account.

export AWS_ACCESS_KEY_ID=''
export AWS_SECRET_ACCESS_KEY=''
export AWS_DEFAULT_REGION=''

You may also pass the AWS credentials via other methods as referenced in Ansible AWS module documentation.

Install dependencies

Optionally, you can install all the required dependencies using below command.

pip install -r requirements.txt

Run the module

Clone this repo to your local. The module is kept inside the library folder. Use the example_playbook.yml as reference to run the module. You may modify the state to enabled|disabled to see different actions.

---
- name: Test Playbook
  hosts: localhost
  connection: local
  tasks:
    - name: Enabling Serial Console
      ec2_serial_console:
        state: disabled
      register: r
    - name: Debugging
      debug:
        msg: "The state of the serial console for account {{ r.account_id }} is {{ r.serial_console_status }}"

Run playbook

ansible-playbook example_playbook.yml

View ansible doc

ansible-doc -M ./library -t module ec2_serial_console

ansible_aws_assignment's People

Contributors

jagadishrajr avatar

Watchers

 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.