69472a5f8d
Change: - Refactoring to make it harder to get wrong and easier to read. - Generalize become_unprivileged tests and fix some that never worked but also never failed. Test Plan: - CI, new units/integration tests Signed-off-by: Rick Elrod <rick@elrod.me>
36 lines
887 B
YAML
36 lines
887 B
YAML
- name: Tests for ANSIBLE_COMMON_REMOTE_GROUP functionality
|
|
hosts: ssh
|
|
gather_facts: yes
|
|
remote_user: unpriv1
|
|
|
|
tasks:
|
|
- name: foo
|
|
action: tmpdir
|
|
register: tmpdir
|
|
become_user: unpriv2
|
|
become: yes
|
|
|
|
- name: run whoami with become
|
|
command: whoami
|
|
register: whoami
|
|
become_user: unpriv2
|
|
become: yes
|
|
|
|
- set_fact:
|
|
stat_cmd: stat -c '%U %G' {{ tmpdir.tmpdir }}/*
|
|
when: ansible_distribution not in ['MacOSX', 'FreeBSD']
|
|
|
|
- set_fact:
|
|
stat_cmd: stat -f '%Su %Sg' {{ tmpdir.tmpdir }}/*
|
|
when: ansible_distribution in ['MacOSX', 'FreeBSD']
|
|
|
|
- name: Ensure we tested the right fallback
|
|
shell: "{{ stat_cmd }}"
|
|
register: stat
|
|
become_user: unpriv2
|
|
become: yes
|
|
|
|
- assert:
|
|
that:
|
|
- whoami.stdout == "unpriv2"
|
|
- stat.stdout == 'unpriv1 commongroup'
|