File: with_items.yml

package info (click to toggle)
python-mitogen 0.3.26-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,456 kB
  • sloc: python: 22,134; sh: 183; makefile: 74; perl: 19; ansic: 18
file content (38 lines) | stat: -rw-r--r-- 1,186 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Verify with_items that modifies the execution environment still executes in
# the correct context.

- name: integration/playbook_semantics/with_items.yml
  hosts: test-targets
  gather_facts: true
  tasks:
    - block:
        - name: Spin up a few interpreters
          become: true
          vars:
            ansible_become_user: "mitogen__user{{ item }}"
          command:
            cmd: whoami
          with_sequence: start=1 end=3
          register: first_run
          changed_when: false

        - name: Reuse them
          become: true
          vars:
            ansible_become_user: "mitogen__user{{ item }}"
          command:
            cmd: whoami
          with_sequence: start=1 end=3
          register: second_run
          changed_when: false

        - name: Verify first and second run matches expected username.
          vars:
            user_expected: "mitogen__user{{ item | int + 1 }}"
          assert:
            that:
              - first_run.results[item | int].stdout == user_expected
              - second_run.results[item | int].stdout == user_expected
          with_sequence: start=0 end=2
      when:
        - become_unpriv_available