-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathansible_playbook.yaml
113 lines (100 loc) · 2.72 KB
/
ansible_playbook.yaml
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
- name: Docker Installation
become: true
hosts: slave
remote_user: ubuntu
tasks:
- name: Install packages
ansible.builtin.apt:
update_cache: true
name:
- ca-certificates
- curl
- gnupg
- lsb-release
- apt-transport-https
- git
- wget
- software-properties-common
become: true
become_method: sudo
- name: Create keyrings directory
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
become: true
become_method: sudo
- name: Check Docker on System
ansible.builtin.command:
cmd: docker --version
register: docker_check
ignore_errors: true
- name: Debug
ansible.builtin.debug:
msg: "{{ docker_check }}"
- name: Get docker gpg key
ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
keyring: /etc/apt/keyrings/docker.gpg
state: present
become: true
become_method: sudo
when: docker_check is failed
- name: Get Architecture
ansible.builtin.shell: dpkg --print-architecture
register: system_arch
- name: Add docker repo
ansible.builtin.apt_repository:
repo: >
deb [arch={{system_arch.stdout}} signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_facts['lsb']['codename'] }} stable
filename: docker
state: present
become: true
become_method: sudo
when: docker_check is failed
- name: Install Docker Engine
ansible.builtin.apt:
update_cache: true
name:
- docker-ce
become: true
become_method: sudo
when: docker_check is failed
- name: Restart docker.service
systemd:
name: docker
daemon_reload: yes
state: started
become: true
become_method: sudo
when: docker_check is failed
- name: Update apt cache
apt:
update_cache: yes
become: true
become_method: sudo
- name: Install containerd.io
apt:
name: containerd.io
state: present
become: true
become_method: sudo
- name: Configure containerd to start using systemd as cgroup
ansible.builtin.shell:
cmd: "{{ item }}"
with_items:
- "containerd config default | sudo tee /etc/containerd/config.toml >/dev/null 2>&1"
- "sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml"
- name: Restart containerd service
ansible.builtin.systemd:
name: containerd
state: restarted
become: true
become_method: sudo
- name: Enable containerd service
ansible.builtin.systemd:
name: containerd
enabled: yes
become: true
become_method: sudo