Ansible install docker
Ansible script to install docker
Installing docker on virtual machines and fresh linux installations is a frequently
encountered problem. To automate this boring job I have prepared an ansible role
to install docker. Initially the role was written to support only debian based
linux distributions, hence the name docker_debian. But later it was modified
to make it generic for any linux distribution.
Install ansible
Prerequisite for running any ansible script is to install ansible using following command in Ubuntu:
sudo apt update sudo apt install ansible
Install ansible galaxy role
The ansible role is published in ansible galaxy and need to be downloaded:
ansible-galaxy role install abhisheksafui.docker_debian
Execute the ansible script
Create a file named install_docker.yml with the following content:
---
- name: "Test docker installation in a debian system"
hosts: localhost
become: true
roles:
- role: abhisheksafui.docker_debian
Execute the following command to install docker in the localhost.
ansible-playbook test.yml
This will install docker and add the user(that executes the above command) to
the docker group. To install docker in a remote machine replace localhost with
inventory name and use inventory file to describe the inventory IP and login
credentials as per ansible guidelines.