diff --git a/tests/ansible/integration/runner/_etc_environment_global.yml b/tests/ansible/integration/runner/_etc_environment_global.yml new file mode 100644 index 00000000..e24a038a --- /dev/null +++ b/tests/ansible/integration/runner/_etc_environment_global.yml @@ -0,0 +1,35 @@ +# /etc/environment + +- file: + path: /etc/environment + state: absent + become: true + +- shell: echo $MAGIC_ETC_ENV + register: echo + +- assert: + that: echo.stdout == "" + +- copy: + dest: /etc/environment + content: | + MAGIC_ETC_ENV=555 + become: true + +- shell: echo $MAGIC_ETC_ENV + register: echo + +- assert: + that: echo.stdout == "555" + +- file: + path: /etc/environment + state: absent + become: true + +- shell: echo $MAGIC_ETC_ENV + register: echo + +- assert: + that: echo.stdout == "" diff --git a/tests/ansible/integration/runner/_etc_environment_user.yml b/tests/ansible/integration/runner/_etc_environment_user.yml new file mode 100644 index 00000000..ca1dc5cc --- /dev/null +++ b/tests/ansible/integration/runner/_etc_environment_user.yml @@ -0,0 +1,32 @@ +# ~/.pam_environment + +- file: + path: ~/.pam_environment + state: absent + +- shell: echo $MAGIC_PAM_ENV + register: echo + +- assert: + that: echo.stdout == "" + +- copy: + dest: ~/.pam_environment + content: | + MAGIC_PAM_ENV=321 + +- shell: echo $MAGIC_PAM_ENV + register: echo + +- assert: + that: echo.stdout == "321" + +- file: + path: ~/.pam_environment + state: absent + +- shell: echo $MAGIC_PAM_ENV + register: echo + +- assert: + that: echo.stdout == "" diff --git a/tests/ansible/integration/runner/etc_environment.yml b/tests/ansible/integration/runner/etc_environment.yml index 0037698a..7eb405cb 100644 --- a/tests/ansible/integration/runner/etc_environment.yml +++ b/tests/ansible/integration/runner/etc_environment.yml @@ -3,78 +3,13 @@ # but less likely to brick a development workstation - name: integration/runner/etc_environment.yml - hosts: test-targets + hosts: test-targets[0] any_errors_fatal: true gather_facts: true tasks: - # ~/.pam_environment + - include_tasks: _etc_environment_user.yml + when: ansible_system == "Linux" and is_mitogen - - file: - path: ~/.pam_environment - state: absent - - - shell: echo $MAGIC_PAM_ENV - register: echo - - - assert: - that: echo.stdout == "" - - - copy: - dest: ~/.pam_environment - content: | - MAGIC_PAM_ENV=321 - - - shell: echo $MAGIC_PAM_ENV - register: echo - - - assert: - that: echo.stdout == "321" - - - file: - path: ~/.pam_environment - state: absent - - - shell: echo $MAGIC_PAM_ENV - register: echo - - - assert: - that: echo.stdout == "" - - - # /etc/environment - - meta: end_play - when: ansible_virtualization_type != "docker" - - - file: - path: /etc/environment - state: absent - become: true - - - shell: echo $MAGIC_ETC_ENV - register: echo - - - assert: - that: echo.stdout == "" - - - copy: - dest: /etc/environment - content: | - MAGIC_ETC_ENV=555 - become: true - - - shell: echo $MAGIC_ETC_ENV - register: echo - - - assert: - that: echo.stdout == "555" - - - file: - path: /etc/environment - state: absent - become: true - - - shell: echo $MAGIC_ETC_ENV - register: echo - - - assert: - that: echo.stdout == "" + - include_tasks: _etc_environment_global.yml + # Don't destroy laptops. + when: ansible_virtualization_type == "docker"