-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_install_role.yml
41 lines (37 loc) · 1.33 KB
/
docker_install_role.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
- name: Install Docker
vars:
dockerExists: false
block:
- name: Check if Docker Exists
command: docker ps
ignore_errors: true
register: diff_cmd
- name: Set dockerExists
set_fact:
dockerExists: true
when: diff_cmd.rc == 0
# - name: Install Docker with apt
# ansible.builtin.apt: docker
# state: present
- name: Start Install
block:
- name: One way to avoid apt_key once it is removed from your distro
block:
- name: docker |no apt key
ansible.builtin.get_url:
url: https://download.docker.com/linux/ubuntu/gpg
dest: /etc/apt/keyrings/docker.asc
- name: docker | apt source
ansible.builtin.apt_repository:
repo: "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
- name: apt get docker
ansible.builtin.apt:
pkg:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: latest
when: dockerExists == true