-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebian-docker-only-install.yml
76 lines (66 loc) · 1.94 KB
/
debian-docker-only-install.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
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
- name: install Docker
hosts: all
become: true
tasks:
- name: Install apt-transport-https
ansible.builtin.apt:
name:
- apt-transport-https
- ca-certificates
- lsb-release
- gnupg
- curl
state: latest
update_cache: true
- name: Add signing key
ansible.builtin.apt_key:
url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
state: present
- name: Add repository into sources list
ansible.builtin.apt_repository:
repo: "deb [arch={{ 'amd64' if ansible_architecture == 'x86_64' else ansible_architecture }}] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
state: present
filename: docker
- name: Update all packages to the latest version
apt:
upgrade: dist
- name: Install Docker
ansible.builtin.apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: latest
update_cache: true
- name: Ensure group "docker" exists
ansible.builtin.group:
name: docker
state: present
- name: adding ubuntu to docker group
user:
name: "{{ user_name }}"
groups: docker
append: yes
- name: "Create .ssh dir"
ansible.builtin.file:
path: ".ssh"
state: directory
owner: "{{ user_name }}"
- name: generate SSH key id_rsa
become: no
openssh_keypair:
path: "~/.ssh/id_rsa"
type: rsa
size: 4096
state: present
force: no
- name: "Read a ssh file content"
shell: |
cat ~/.ssh/id_rsa.pub
register: file_content
become: no
- name: "Print ssh key"
debug:
msg: "{{ file_content.stdout }}"