From 633cd888a07c9a273b5349aeac24af66d27601da Mon Sep 17 00:00:00 2001 From: David Wilson Date: Thu, 12 Apr 2018 12:24:00 +0100 Subject: [PATCH] issue #182: test for previous commit. --- .../integration/playbook_semantics/all.yml | 1 + .../playbook_semantics/with_items.yml | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/ansible/integration/playbook_semantics/with_items.yml diff --git a/tests/ansible/integration/playbook_semantics/all.yml b/tests/ansible/integration/playbook_semantics/all.yml index 40fa70b7..6c8dd065 100644 --- a/tests/ansible/integration/playbook_semantics/all.yml +++ b/tests/ansible/integration/playbook_semantics/all.yml @@ -1,3 +1,4 @@ - import_playbook: become_flags.yml - import_playbook: delegate_to.yml - import_playbook: environment.yml +- import_playbook: with_items.yml diff --git a/tests/ansible/integration/playbook_semantics/with_items.yml b/tests/ansible/integration/playbook_semantics/with_items.yml new file mode 100644 index 00000000..35c4b3c5 --- /dev/null +++ b/tests/ansible/integration/playbook_semantics/with_items.yml @@ -0,0 +1,32 @@ +# Verify with_items that modifies the execution environment still executes in +# the correct context. + +- hosts: all + any_errors_fatal: true + tasks: + - name: integration/playbook_semantics/with_items.yml + assert: + that: true + + - name: Spin up a few interpreters + shell: whoami + become: true + vars: + ansible_become_user: "mitogen__user{{item}}" + with_sequence: start=1 end=3 + register: first_run + + - name: Reuse them + shell: whoami + become: true + vars: + ansible_become_user: "mitogen__user{{item}}" + with_sequence: start=1 end=3 + register: second_run + + - name: Verify first and second run matches expected username. + assert: + that: + - first_run.results[item|int].stdout == ("mitogen__user%d" % (item|int + 1)) + - first_run.results[item|int].stdout == second_run.results[item|int].stdout + with_sequence: start=0 end=2