Ansible is an amazing piece of configuration management software. Among its amazing features is that it’s totally agentless and the only 2 packages that it needs on any host are python and an SSH server.
Today we will create a playbook that will do the following:
- Add the stable docker repository to the software sources
- Add the gpg key
- install docker-ce package
It’s assumed that you have already added all required hosts to /etc/ansible/hosts and I’m naming this group “swarm”
- hosts: hostname
remote_user: domain\user
gather_facts: no
tasks:
- name: add docker repo
apt_repository:
repo="deb https://download.docker.com/linux/ubuntu xenial stable"
state=present
- name: install repo gpg key
apt_key:
url="https://download.docker.com/linux/ubuntu/gpg"
state=present
- name: refresh cache and install docker-ce
apt:
name=docker-ce
update_cache=yes
state=latest
Enjoy!
Sources: Ansible Documentation