Ansible-AWS resource


#1

Ansible and AWS Resource

Create a user
$ su ansible
$ passwd ansible

Install boto on the master server
$sudo pip install boto3
$sudo vim .boto
aws_secret_key_id= ******
aws_access_key_id= *******

Switch to the user
$ su ansible
cd /etc/ansible/

Create a directory
$ mkdir playbooks
$ cd playbooks

Copying of files from gitHub repository to the local instance
$ sudo git clone https://github.com/ncodeitgithub1/dvos10sd01.git

AWS ec2 instance communication shell command example
$ cat awsshell.yml
$ ansible-playbook awsshell.yml

Gather ec2 facts from my remote instance
$ cat awsec2facts.yml
$ ansible- playbook awsec2facts.yml

Creating a newkey pair
$ cat awsec2key.yml
$ ansible-playbook awsec2key.yml

Managing EC2 instance state
$ cat awsec2-state.yml
$ ansible-playbook awsec2-state.yml

Provisioning new EC2 instance
$ cat awsec2.yml
$ ansible-playbook awsec2.yml

Basic provisiong of an AMI from our instance
$ cat awsami.yml
$ ansible-playbook awsami.yml

Copying an AMI from one region to another region
$ cat awsamifind.yml
$ ansible-playbook awsamifind.yml

Gathering facts of all running instances
$ cat awsec2_remote_facts
$ ansible-playbook awsec2_remote_facts

creating a EC2 volume
$ ansible-playbook awsec2_vol.yml

Labeling an existing volume
$ ansible-playbook awsec2_vol_tags.yml

Security group creation
cat awsgroup.yml
ansible-playbook awsgroup.yml

Basic creation of VPC
$ ansible-playbook awsecs_vpc.yml

Creating IAM user
$ ansible-playbook awsiam.yml

$ cd deploy

Deploying a static website( installing httpd server and deploying a static webpage)
$ cat apache_deploy.yml
$ ansible-playbook apache_deploy.yml