playbook-docker/playbook.yml
2020-11-17 22:45:00 +01:00

52 lines
1.2 KiB
YAML
Executable File

---
- name: Setup docker
hosts: webservers
become: yes
tasks:
- name: Install required system packages
apt:
name: [
'apt-transport-https',
'ca-certificates',
'curl',
'gnupg-agent',
'software-properties-common',
]
state: latest
update_cache: yes
- 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 https://download.docker.com/linux/ubuntu focal 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.27.4/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: ubuntu
groups: docker
append: yes