Automation is a crucial element in IT since it directly affects the time of completion and efficiency of production. Automation simplifies complex and risky tasks and hence helps the developers manage the system more easily by allowing them to focus on other tasks that add value to the organization. Ansible, ‘the darling’ of automation is a widely used open-source software automation tool in the industry. Studies show that Intel, Evernote, Hootsuite, and even Apple have adopted Ansible to their development lifecycle.

What is Ansible?

Ansible is an open-source IT Configuration Management, Deployment & Orchestration tool. It aims to provide large productivity gains to a wide variety of automation challenges. This tool is very simple to use yet powerful enough to automate complex multi-tier IT application environments. It includes its own declarative language to describe system configuration.

What is Ansible Playbook?

Ansible Playbooks are the files where Ansible code is written. These files are written in the language, YAML, which is a funny acronym for, “YAML Ain’t no Markup Language.”

Playbooks contain one or more Plays. Plays map a group of computers to a few well-defined roles known as Tasks. **Tasks **can be defined as Ansible scripts.

Project Description:

Write an Ansible PlayBook that does the following operations in the managed nodes:

  • Configure Docker & Install it.
  • Start and enable Docker services.
  • Pull the httpd server image from the Docker Hub.
  • Copy the html code to the directory in the container.
  • Run the httpd container and expose it to the public.

Prerequisites:

  • Python 3 must be installed
  • Ansible must be installed and configured

Solution:

Step 1: Install Ansible using pip command

command :

pip3 install ansible

Check whether ansible is installed or not using

command :

ansible --version

Image for post

**Step 2: **Configure the Ansible

Save the IP address of Managed Node in <file.txt> and also give username and password for login purposes.

#docker #devops #automation #yaml #ansible

Ansible and Docker Integration
1.35 GEEK