Update (& fix) dockerd role.
This commit is contained in:
parent
853d1b20bb
commit
4c3f1404a1
2 changed files with 36 additions and 15 deletions
3
roles/dockerd/files/override.conf
Normal file
3
roles/dockerd/files/override.conf
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[Service]
|
||||||
|
Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_NET=slirp4netns"
|
||||||
|
Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=slirp4netns"
|
|
@ -1,6 +1,7 @@
|
||||||
- name: Make sure required packages are installed
|
- name: Make sure required packages are installed
|
||||||
apt:
|
apt:
|
||||||
name:
|
name:
|
||||||
|
- dbus-user-session
|
||||||
- docker.io
|
- docker.io
|
||||||
- docker-compose
|
- docker-compose
|
||||||
- rootlesskit
|
- rootlesskit
|
||||||
|
@ -8,23 +9,26 @@
|
||||||
- uidmap
|
- uidmap
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Make sure system-wide Docker daemon is stopped & disabled
|
- name: Make sure system-wide Docker daemon & socket are stopped & disabled
|
||||||
service:
|
service:
|
||||||
name: docker
|
name: "{{ item }}"
|
||||||
state: stopped
|
state: stopped
|
||||||
enabled: false
|
enabled: false
|
||||||
|
loop:
|
||||||
|
- docker
|
||||||
|
- docker.socket
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Make sure system-wide Docker socket is stopped & disabled
|
- name: Get docker user service status
|
||||||
service:
|
stat:
|
||||||
name: docker.socket
|
path: "{{ ansible_env['HOME'] }}/.config/systemd/user/docker.service"
|
||||||
state: stopped
|
register: dockerd_user_service_file_result
|
||||||
enabled: false
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Run dockerd-rootless-setuptool.sh script
|
- name: Run dockerd-rootless-setuptool.sh script
|
||||||
command:
|
command:
|
||||||
cmd: /usr/share/docker.io/contrib/dockerd-rootless-setuptool.sh install
|
cmd: /usr/share/docker.io/contrib/dockerd-rootless-setuptool.sh install
|
||||||
|
# Don't run install script everytime
|
||||||
|
when: not dockerd_user_service_file_result.stat.exists
|
||||||
|
|
||||||
- name: Make sure /usr/share/docker.io/contrib is in PATH variable
|
- name: Make sure /usr/share/docker.io/contrib is in PATH variable
|
||||||
lineinfile:
|
lineinfile:
|
||||||
|
@ -43,21 +47,35 @@
|
||||||
cmd: "loginctl enable-linger {{ ansible_env['USER'] }}"
|
cmd: "loginctl enable-linger {{ ansible_env['USER'] }}"
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: "Create directory {{ ansible_env['HOME'] }}/.config/systemd/user/docker.service.d to override environment variables"
|
- name: "Create directory {{ ansible_env['HOME'] }}/.config/systemd/user/docker.service.d"
|
||||||
file:
|
file:
|
||||||
path: "{{ ansible_env['HOME'] }}/.config/systemd/user/docker.service.d"
|
path: "{{ ansible_env['HOME'] }}/.config/systemd/user/docker.service.d"
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: Add environment variables to Docker user service to use slirp4netns RootlessKit port driver, which enables source IP propagation
|
# Set port driver to slirp4netns to enable source IP propagation, which is required for coturn to work.
|
||||||
|
- name: "Copy systemd service override.conf to {{ ansible_env['HOME'] }}/.config/systemd/user/docker.service.d/override.conf"
|
||||||
copy:
|
copy:
|
||||||
|
src: "{{ role_path }}/files/override.conf"
|
||||||
dest: "{{ ansible_env['HOME'] }}/.config/systemd/user/docker.service.d/override.conf"
|
dest: "{{ ansible_env['HOME'] }}/.config/systemd/user/docker.service.d/override.conf"
|
||||||
content: |
|
register: dockerd_copy_override_conf_result
|
||||||
[Service]
|
|
||||||
Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_NET=slirp4netns"
|
- name: Edit some sysctl entries for Redis & Syncthing
|
||||||
Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=slirp4netns"
|
sysctl:
|
||||||
|
name: "{{ item.key }}"
|
||||||
|
value: "{{ item.value }}"
|
||||||
|
loop:
|
||||||
|
- key: vm.overcommit_memory
|
||||||
|
value: 1
|
||||||
|
- key: net.core.wmem_max
|
||||||
|
value: 2500000
|
||||||
|
- key: net.core.rmem_max
|
||||||
|
value: 2500000
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: Start/restart & enable Docker user service
|
- name: Start/restart & enable Docker user service
|
||||||
service:
|
service:
|
||||||
name: docker
|
name: docker
|
||||||
state: restarted
|
scope: user
|
||||||
|
# Restart only if config file(s) changed
|
||||||
|
state: "{{ (dockerd_copy_override_conf_result.changed) | ternary('restarted', 'started') }}"
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
Loading…
Reference in a new issue