ansible/playbooks/05_install_docker.yml

60 lines
1.9 KiB
YAML
Raw Normal View History

2023-12-05 12:21:17 +01:00
- hosts: datacenter
name: Install docker1
2022-12-14 02:23:34 +01:00
become: true
become_user: root
2024-10-15 13:05:43 +02:00
gather_facts: false
2022-12-14 02:23:34 +01:00
tasks:
- name: Install docker
ansible.builtin.apt:
2024-11-14 10:23:44 +01:00
name:
- ca-certificates
- curl
- telnet
- net-tools
2022-12-14 02:23:34 +01:00
- python3-pip
- python3-dev
2024-11-14 10:23:44 +01:00
state: present
2024-11-18 08:39:43 +01:00
update_cache: yes
2024-11-14 10:23:44 +01:00
- name: Get keys for raspotify
ansible.builtin.shell:
install -m 0755 -d /etc/apt/keyrings
- name: Get keys for raspotify
ansible.builtin.shell:
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
- name: Get keys for raspotify
ansible.builtin.shell:
chmod a+r /etc/apt/keyrings/docker.asc
- name: Get keys for raspotify
2024-11-14 10:25:27 +01:00
ansible.builtin.shell: echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
2024-11-14 10:23:44 +01:00
- name: Install docker
ansible.builtin.apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
2024-11-18 08:36:04 +01:00
update_cache: yes
2024-11-14 10:23:44 +01:00
2023-12-05 12:21:17 +01:00
- name: Create a directory docker.service.d
ansible.builtin.file:
path: /etc/systemd/system/docker.service.d/
state: directory
mode: '0755'
- name: Creating a file with content
copy:
dest: "/etc/systemd/system/docker.service.d/override.conf"
content: |
[Service]
2024-11-18 08:33:34 +01:00
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375
2024-11-14 10:05:24 +01:00
2024-11-14 10:26:38 +01:00
- name: Just force systemd to reread configs
2024-11-14 10:32:18 +01:00
ansible.builtin.systemd:
2024-11-14 10:26:38 +01:00
daemon_reload: true
2024-10-15 13:10:31 +02:00
- name: Restart docker service
ansible.builtin.service:
name: docker.service
state: restarted