Deployment of Webserver on Docker Using Ansible
Concepts Used :
- Ansible : It is simple open source IT engine which automates application deployment, intra service orchestration, cloud provisioning and many other IT tools.
- Ansible-Playbook : A playbook is a file where users write Ansible code, an organized collection of scripts defining the work of a server configuration.
- Docker : It is an open-source project for automating the deployment of applications as portable, self-sufficient containers that can run on the cloud or on-premises.
- Controller Node : A controller node(CN) is a Linux server that has Ansible installed on it and is used for managing remote hosts or nodes.
- Managed Node : The remote systems managed by the controller node are known as Managed Hosts or Managed Node(MN).
Check the following things in CN :
- Ansible version by the command :- ansible — version
- Create a inventory file that contains managed node IP , username and password. So that CN can manage the configuration of MN.
- Add the path of inventory in configuration file of ansible -/etc/ansible/ansible.cfg
- Get all manage nodes by the command : ansible all — list-hosts
- Check the connectivity by the command : ansible all -m ping
Now the setup of the Ansible is done . So, we can go to the next step that is creating a playbook. Ansible Support YAML language , Hence I have created the dockercode.yml ansible-playbook.
This playbook performs following tasks at MN :
1. Configures yum for Docker
2. Installs Docker Software
3. Starts Docker services
4. Installs Docker SDK
5. Creates directory at MN
6. Copies Webpages from CN to MN
7. Pulls httpd server image
8. Launches Docker container
- Run the playbook by the command : ansible-playbook dockercode.yml
- check all the things in MN , that we have done from CN.