Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip subgid check #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not drop to shell for things ansible can handle natively

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: 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: 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