Posts

Showing posts from July 8, 2017

Ansible Dynamic Inventory

Getting started with Ansible Dynamic Inventory for AWS Cloud Install Python Boto : ################## # yum install Python-pip #pip install python-boto AWS CLI  Installation  : ###################         # pip  install  awscli          AWS CLI  CONFIGURATION : ########################      # aws configure        AWS Access Key ID [****************W5UQ]:        AWS Secret Access Key [****************0QTW]:        Default region name [us-west-2]:        Default output format [None]:  Downloading  Ec2.py and  Ec2.ini  file  for Dynamic  Inventory : ################################################# #   cd  /etc/ansible/ #  wget  https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.py #  wget  https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.ini #  chmod  +x   ec2.py  ec2.ini Exporting some variables : ####################### # export ANSIBLE_HOSTS = / etc / ansible / ec2 . py # export ANSIBLE

Cloud Provisioning

AWS Cloud Provisioning using Ansible Launching EC2 Instances Ansible Playbook  ################## /etc/ansible/playbooks/ec2_launch.yml ---   - name: Provision an EC2 Instance     hosts: local     connection: local     gather_facts: False     tags: provisioning     # Necessary Variables for creating/provisioning the EC2 Instance     vars:       instance_type: t2.micro       security_group: s2 # Change the security group name here       image: ami-b55a51cc # Change the AMI, from which you want to launch the server       region: us-west-2 # Change the Region       keypair: key1 # Change the keypair name       count: 1       hosts: webserver     # Task that will be used to Launch/Create an EC2 Instance     tasks:       - name: Launch the new EC2 Instance         local_action: ec2                        group={{ security_group }}                        instance_type={{ instance_type}}                        image={{ image }}