Deploying Apache webserver In Docker container by Ansible
In this article, I am going to show how to deploy apache webserver in docker container by using ansible.

Here I am using an AWS ec2 instance as a target node coz it is a fresh new operating system and there is nothing preconfigured. Now start the task:

Configure your local system:-

# pip3 install boto

# pip3 install boto3

-----------------------

Download ec2.py and ec2.ini file by wget <below_url>from the given URL: https://raw.githubusercontent.com/ansible/ansible/stable-2.9/contrib/inventory/ec2.py https://raw.githubusercontent.com/ansible/ansible/stable-2.9/contrib/inventory/ec2.ini -------------------------------

Create a folder(e.g. /etc/ansible/hosts) and move these files to this folder. Make these files executable: # chmod +x ec2.py

# chmod +x ec2.ini

-----------------------------------

Now export the credentials in your system: # export AWS_REGION=’ap-south-1'

# export AWS_ACCESS_KEY_ID=’XXXXXXXXXXXXXXX’

# export AWS_SECRET_ACCESS_KEY=’XXXXXXXXXXXXXXXX’

------------------------------------

Put your aws key in your localsystem and provide the path of the key in ansible.cfg file.

Then change the format type of the key.

# chmod 600 <keyname.pem>

The ansible.cfg file should be as:

# cat ansible.cfg

[defaults]

host_key_checking=False

remote_user=ec2-user

ask_pass=False

private_key_file=/etc/ansible/key/firstkey.pem

roles_path=/etc/ansible/roles [privilege_escalation]

become=True

become_user=root

become_method=sudo

become_ask_pass=False

For more info about connectivity with AWS instance by using ansible, you can go through my previous articles:
['Lalit Yadav']
['Vimal Daga', 'Http Server', 'Ansible', 'Docker', 'Automation']