Configure Docker Using Ansible on AWS Part-1.

Ansible is a configuration management system written in Python using a declarative markup language to describe configurations. It is used to automate the software configuration and deployment.
AWS (Amazon Web Services) is a comprehensive, evolving cloud computing platform provided by Amazon that includes a mixture of infrastructure as a service (IaaS), platform as a service (PaaS) and packaged software as a service (SaaS) offerings.
To know more about AWS visit my blog- Introduction to AWS.
Docker is a software for deployment automating and management of applications in a virtualization environment on the operating system level.
There are two Node(system) we are going to use:
- Controller Node: from where we run our Ansible playbook.(In my case its my localhost)
- Managed Node: where we configure the Docker.(and it will be AWS EC2)
Setup on Managed Node.
- Launch the AWS EC2 instance.

- Enter its IP Address in the hosts file(inventory) at the controller node shown below.
- Add rule in the security group: Protocol: ssh, Port: 22

That’s all in Managed Node side.
SetUp on Controller Node.
Before that we first need to install Ansible and for that Python should be installed in your system. To check if python is available in your system or not. We are here using python3.
python3 --version

If not available then install python3 and ansible using yum command.
yum install python3
yum install ansible -y
To check ansible installed or not.
ansible --version

After Ansible is installed, we go to the home directory of Ansible i.e.,
cd /etc/ansible/
ls

You will see here a file named hosts, this file is known as default Inventory file. Here you can enter the lists of the Managed Node IP Address where you want to perform all the tasks.

You have to add few things in the Inventory file:
- IP Address: Managed Node IP Address.
- ansible_ssh_user: Username of the Managed Node.
- ansible_ssh_pass: Password of the Managed Node.
Now finally we write the playbook:
- Update the Managed Node
- Install Python
- Install Docker
- Start Docker Service
- Enable Docker Service

Now its time to run the playbook:


Here I have have attached the GitHub Repository link.
Bonus:Interview Questions.
- Which module is used to install the software or package?
- Which module is used to enable and start the services?
- What is the use of command module?
- What is the difference between command, shell and raw modules?
If it is helpful, please give some claps, it encourage me write more. Thanks for reading.
In next part we look how to pull the image and run the container and configure the WebServer using Ansible.
Stay Tunned!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!