Debian Codegraph @

ansible_collections/containers/podman/playbooks/examples/podman_multiuser_tasks.yml

raw
1 ---
2 - name: Run tasks as different users inside containers
3 hosts: all
4 gather_facts: false
5 vars:
6 ansible_connection: containers.podman.podman
7 tasks:
8 - name: Who am I (root default)
9 raw: id -u
10 register: uid_root
11
12 - name: Display root uid
13 debug:
14 msg: "root uid={{ uid_root.stdout }}"
15
16 - name: Run as nobody (if exists)
17 vars:
18 ansible_user: nobody
19 raw: "sh -lc 'id -u && touch /tmp/nobody_was_here'"
20 register: uid_nobody
21 failed_when: false
22
23 - name: Display nobody uid
24 debug:
25 msg: "nobody uid={{ uid_nobody.stdout | default('N/A') }}"
26
27 - name: Run with numeric uid 1000 (common)
28 vars:
29 ansible_user: "1000"
30 raw: "sh -lc 'id -u || true'"
31 register: uid_1000
32 failed_when: false
33
34 - name: Show marker files (root)
35 raw: "sh -lc 'ls -l /tmp/*was_here || true'"
36
37