Friday, January 8, 2016

Ansible on AWS using Pem files quick and Dirty

At the time of writing this I found that blogger is no longer doing it for me.  I am a little upset with the performance of adding pictures and diagrams.  So I hope to be deploying my own wordpress in the cloud soon.

For this example I am going to be lazy so you can follow quickly.  No thought into security just getting you started quickly

Without further ado...




I bring you Ansible on AWS using a pem file utilizing an adhoc command.


Prerequisite:

Install Ansible <-- I have a good write up on how to install Ansible on Redhat if you search my blog.

Run this command in terminal:

mkdir -p /etc/ansible/corey_albright_is_cool/pem_files


Step 1: Download your pem file into a known location


Our example will be located in (so create it if its not there make the folders if you need to):

  /etc/ansible/corey_albright_is_cool/pem_files

Step 2: Next type these commands in terminal (These files are essential):


sudo touch /etc/ansible/ansible.cfg

sudo touch /etc/host


Step 3: Now we need to populate the files by giving them instructions:

sudo nano /etc/ansible/host

Step 4: Now put the machine your gonna connect to in here (Substitute the following entries written in yellow with your own):

111.222.333.444
some_other_host_name_with_FQDN

Step 5: Save(WriteOut) and Exit


Step 6: Next type this:


sudo nano /etc/ansible/ansible.cfg

Step 7: Paste the following into the file and change then Save(WriteOut) and exit



[defaults]

# some basic default values...

inventory      = /etc/ansible/hosts
forks          = 5
remote_user = ec2-user
private_key_file=  /etc/ansible/corey_albright_is_cool/pem_files/yourmachine.pem


Step 8: Run this command in the Terminal & you should get should get success >>


ansible all -m ping -i /etc/ansible/host -vvv


Step 9:  Enjoy you are now ready to learn playbooks