# Service data below the top level stays with whatever uid its container runs as. - name: Let aurbis create services in /opt file: path: /opt state: directory owner: root group: aurbis mode: "02775" - name: Give aurbis every /opt service directory ansible.builtin.command: argv: [find, /opt, -mindepth, "1", -maxdepth, "1", -type, d, "!", -name, containerd, "!", "(", -group, aurbis, -perm, "-2070", ")", -print, -exec, chgrp, aurbis, "{}", "+", -exec, chmod, g+rwxs, "{}", "+"] register: aurbis_opt_dirs changed_when: aurbis_opt_dirs.stdout != "" - name: Give aurbis the top-level files of every /opt service ansible.builtin.command: argv: [find, /opt, -mindepth, "2", -maxdepth, "2", -type, f, "!", -path, "/opt/containerd/*", "!", "(", -group, aurbis, -perm, -g+rw, ")", -print, -exec, chgrp, aurbis, "{}", "+", -exec, chmod, g+rw, "{}", "+"] register: aurbis_opt_files changed_when: aurbis_opt_files.stdout != "" - name: Keep /opt .env files from other users ansible.builtin.command: argv: [find, /opt, -mindepth, "2", -maxdepth, "2", -type, f, -name, .env, -perm, /o+rwx, -print, -exec, chmod, o-rwx, "{}", "+"] register: aurbis_opt_env changed_when: aurbis_opt_env.stdout != "" - name: Look up the docker group getent: database: group key: docker fail_key: false - name: Let aurbis members run docker user: name: "{{ item }}" groups: docker append: true loop: "{{ users | default([]) }}" when: ansible_facts.getent_group.docker is not none