Use function in role to set docker daemon options

Also install RC of compose plugin
This commit is contained in:
Roxedus 2021-08-16 23:52:40 +02:00
parent 45dd331dba
commit ae7575d508
Signed by: Roxedus
GPG Key ID: 9B4E311961C63639
2 changed files with 28 additions and 2 deletions

View File

@ -1,3 +1,7 @@
docker_install_compose: false docker_install_compose: false
docker_users_obj: "{{ users|selectattr('docker', 'defined') }}" docker_users_obj: "{{ users|selectattr('docker', 'defined') }}"
docker_users: "{{ docker_users_obj|map(attribute='username') }}" docker_users: "{{ docker_users_obj|map(attribute='username') }}"
docker_daemon_options:
log-driver: "journald"
log-opts: { "mode": "non-blocking" }

View File

@ -67,7 +67,7 @@
- hosts: docker - hosts: docker
become: yes become: yes
tags: [never, init, docker] tags: [docker]
vars_files: vars_files:
- "vars/vault.yml" - "vars/vault.yml"
post_tasks: post_tasks:
@ -75,7 +75,29 @@
ansible.builtin.pip: ansible.builtin.pip:
name: name:
- docker - docker
- docker-compose
- name: Get DEB architecture
shell: dpkg --print-architecture
register: deb_architecture
- name: Create plugin directory if not present
ansible.builtin.file:
path: "/home/{{ item.username }}/.docker/cli-plugins/"
state: directory
owner: "{{ item.username }}"
group: "{{ item.groupname }}"
mode: "0775"
loop: "{{ docker_users_obj }}"
- name: Install compose plugin
ansible.builtin.get_url:
url: "https://github.com/docker/compose-cli/releases/download/v2.0.0-rc.1/docker-compose-linux-{{ deb_architecture.stdout }}"
dest: "/home/{{ item.username }}/.docker/cli-plugins/docker-compose"
mode: "0755"
owner: "{{ item.username }}"
group: "{{ item.groupname }}"
loop: "{{ docker_users_obj }}"
roles: roles:
- role: geerlingguy.docker - role: geerlingguy.docker