diff --git a/README.md b/README.md index 37f4b1e..11f3cbb 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,8 @@ add this label to container_cmd_args: ```--label "io.containers.autoupdate=image Never use `ansible.builtin.import_role` to execute this role if you intend to use it more than once per playbook, or you will fall in [this anti-pattern](https://medium.com/opsops/ansible-anti-pattern-import-role-task-with-task-level-vars-a9f5c752c9c3). +Alternatively, you could use the "roles" block on top level of play and specify the variables +[without "vars" block](https://medium.com/opsops/role-parameters-in-ansible-946386f32e77). Dependencies ------------ diff --git a/defaults/main.yml b/defaults/main.yml index 879fd31..294c5b2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -32,6 +32,9 @@ service_name: "{{ container_name }}-container-pod-{{ container_run_as_user }}.se # to sepped up you can disable always checking if podman is installed. skip_podman_install: true +# Usually not needed since useradd adds subuid and subgid automatically +skip_subgid_change: true + podman_dependencies_rootless: - fuse-overlayfs - slirp4netns diff --git a/tasks/check_subid.yml b/tasks/check_subid.yml index d9bcd63..f2b9a4b 100644 --- a/tasks/check_subid.yml +++ b/tasks/check_subid.yml @@ -1,16 +1,12 @@ --- - name: check if user is in subuid file - find: - path: /etc/subuid - contains: '^{{ container_run_as_user }}:.*$' + shell: "grep -i '^{{ container_run_as_user}}:.*' /etc/subuid" register: uid_line_found when: container_run_as_user != 'root' - name: check if group is in subgid file - find: - path: /etc/subgid - contains: '^{{ container_run_as_group }}:.*$' + shell: "grep -i '^{{ container_run_as_group }}:.*' /etc/subgid" register: gid_line_found when: container_run_as_group != 'root' @@ -23,7 +19,7 @@ mode: '0644' owner: root group: root - when: container_run_as_user != 'root' and not uid_line_found.matched + when: (not skip_subgid_change) and container_run_as_user != 'root' not uid_line_found.rc - name: ensure group is in subgid file, if it was missing lineinfile: @@ -34,4 +30,4 @@ mode: '0644' owner: root group: root - when: container_run_as_group != 'root' and not gid_line_found.matched + when: (not skip_subgid_change) and container_run_as_group != 'root' and gid_line_found.rc