Skip to content

Commit

Permalink
fix subuid/subgid checks
Browse files Browse the repository at this point in the history
"find" module only checks that files exist in a directory.
In this case it did not fail since the path was a file but there was
a warning:

  TASK [ikke_t.podman_container_systemd : check if user is in subuid file] ***********************
  [WARNING]: Skipped '/etc/subuid' path due to this access issue: '/etc/subuid' is not a directory
  ok: [hostname]
  • Loading branch information
Johannes Aalto committed Dec 16, 2021
1 parent 1db8536 commit 05e11de
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions tasks/check_subid.yml
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -23,7 +19,7 @@
mode: '0644'
owner: root
group: root
when: (not skip_subgid_change) and 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:
Expand All @@ -34,4 +30,4 @@
mode: '0644'
owner: root
group: root
when: (not skip_subgid_change) and 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

0 comments on commit 05e11de

Please sign in to comment.