DevOps/Ansible/manage AWS infrastructure using Ansible

Configuration
Configure your computer for use Ansible to manage your Amazon AWS infrastructure.
 * 1) Install aws cli, python, apt-get install python-pip and python pip boto
 * 2) Install Ansible, macOS:
 * 3) Configure your local aws cli installation to allow you to make operation on your AWS infrastructure.

Installation one line:

Basic Operations

 * Start a AWS EC2 machine:

We will use ansible EC2 module. Create a new file, for example. Put your instance_ids and region values, (execute   to obtain them or   to obtain only InstanceIds) and execute your newly created script, chmod +x aws_start_machine.yml; ./aws_start_machine.yml

Example. Start and already created EC2 instance. file:
 * (Remember just to use spaces and not tabulator for your YML file)


 * 1) !/usr/bin/env ansible-playbook

- name: Starting AWS machine hosts: localhost gather_facts: false connection: local vars: instance_ids: - 'i-09999999999'    # you will have to modify this line with the InstanceId of your server region: us-east-2           # you will have to change this line to region where your machine was created tasks: - name: Starting AWS Machine. It Will take some time. ec2: instance_ids: '' region: '' state: running wait: True

Getting information from a AWS machine:

Example  file:
 * 1) !/usr/bin/env ansible-playbook

- name: Status ec2 instance hosts: localhost connection: local tasks: - ec2_instance_facts: instance_ids: - i-0bd3xx999999999 register: ec2_facts - debug: msg=""