playbook-docker/playbook.yml
2021-06-07 22:44:54 +02:00

47 lines
1.2 KiB
YAML
Executable File

---
- name: Install docker
hosts: webservers
become: yes
tasks:
- name: Install required system packages
apt:
name: [
'apt-transport-https',
'ca-certificates',
'software-properties-common',
]
state: present
- name: Add Docker GPG apt Key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
- name: Update apt and install docker-ce
apt:
name: [
'docker-ce',
'docker-ce-cli',
'containerd.io',
]
state: latest
update_cache: yes
- name: Install docker-compose
get_url:
url : https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose
mode: 'u+x,g+x'
group: docker
- name: Add user to docker group
user:
name: "{{ user }}"
group: docker