Configuring Docker with Ansible

Kalla kruparaju

--

Hello connections !!!!

Iam back with one more article. In this article i will give complete overview to Configuration of Docker using Ansible….

What is Docker??

Docker is a opensource product which used to launch operating system(container) with in one second. Docker is a CLI interface product. Docker works on existing container technology which it is minimize it to cli commands.

What is Ansible?

Ansble is a tool for configuration management of operating system. Python is the base language for Ansible and Ansible is a Declarative language product works with idempotent nature. Ansible works on ssh protocol.

Installing docker using ansible

Docker comes with two differnet edition one of it is Community Edition(CE) and Enterprise Edition(EE). Now I am installing the docker with Community Edition(CE).
Steps to install Docker

👉 Configure the Yum repository of the Docker
👉 Install the docker with the docker-ce command using Yum
👉 Start the services of the docker

Configuring the yum repository of the Docker

- name: yum configuration
yum_repository:
baseurl: "https://download.docker.com/linux/centos/7/x86_64/stable/"
name: "docker-ce"
description: "Docker-ce repo"
gpgcheck: no

In the above task configure the yum reposistory with the name docker-ce with the above baseurl. after running this task you can see that one file created with .repo extension with name docker-ce (docker-ce.repo) in the /etc/yum.repos.d directory.

Installing the docker with the docker-ce command using Yum

- name: installing docker
command: "yum install docker-ce --nobest"

In the above task installing the docker with the docker-ce command using yum. In the above command you can — nobest where you are asking to install lastest stable version where Community Edition(CE) is opensource where as Enterprise Edition(EE) is not a opensource we have to purchase it.

- name: installing docker sdk
pip:
name: "docker-py"

In the above task you can we installed some docker sdk software to run the docker using the ansible it is compulsory to install it other while running the playbook it will raises the error and terminated the.

- name: starting docker services
service:
name: "docker"
state: started
enabled: yes

And the final step we will starting the docker services and enabling the services permanently.

- name: Dynamic Docker Configuration
hosts: localhost
tasks:
- name: yum configuration
yum_repository:
baseurl: "https://download.docker.com/linux/centos/7/x86_64/stable/"
name: "docker-ce"
description: "Docker-ce repo"
gpgcheck: no
- name: installing docker
command: "yum install docker-ce --nobest"
- name: installing docker sdk
pip:
name: "docker-py"
- name: starting docker services
service:
name: "docker"
state: started
enabled: yes

That’s all by running the complete playbook docker will success configured in our system….

--

--

No responses yet