From a717c5406cec70c2a3d0f250e2870aeabfb0ef1e Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 6 Nov 2018 04:43:56 +0000 Subject: [PATCH] tests: split etc_environment test in two Turns out nobody supports ~/.pam_environment any more. Keep the behaviour around for the time being. --- .../runner/_etc_environment_global.yml | 35 +++++++++ .../runner/_etc_environment_user.yml | 32 ++++++++ .../integration/runner/etc_environment.yml | 77 ++----------------- 3 files changed, 73 insertions(+), 71 deletions(-) create mode 100644 tests/ansible/integration/runner/_etc_environment_global.yml create mode 100644 tests/ansible/integration/runner/_etc_environment_user.yml 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"