Skip to content

Commit 97a1ec3

Browse files
committed
tests: Make effective config check work for container runs
In linux-system-roles/tox-lsr#191 we added `ansible_become=false` to our container (podman/buildah) inventories. This disables `become_user`, and thus the test was silently running as root and thus failing. This isn't important for the stat tests (they are fine to run as root), but `ssh` must actually run as the desired target user. This is just a test, so we can call `su` directly.
1 parent 38e7879 commit 97a1ec3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tests/tests_user_config.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,9 @@
100100
- config_mode.stat.mode == '0600'
101101

102102
- name: Test the effective configuration using ssh
103-
become: true
104-
become_user: "{{ username }}"
105-
become_method: "{{ __become_method }}"
106-
command: ssh -vvv -G example
103+
# don't use become_user, does not work in containers due to
104+
# https://github.com/linux-system-roles/tox-lsr/pull/191
105+
command: "su -c 'ssh -vvv -G example' {{ username }}"
107106
register: effective
108107
when:
109108
- ansible_facts['distribution'] not in ['CentOS', 'RedHat'] or

0 commit comments

Comments
 (0)