|
1 | 1 | - name: integration/playbook_semantics/delegate_to.yml |
2 | 2 | hosts: test-targets |
| 3 | + vars: |
| 4 | + local_path: "/tmp/delegate_to.{{ inventory_hostname }}.txt" |
3 | 5 | tasks: |
4 | 6 | # |
5 | 7 | # delegate_to, no sudo |
6 | 8 | # |
7 | 9 | - name: "delegate_to, no sudo" |
8 | 10 | copy: |
9 | | - dest: /tmp/delegate_to.yml.txt |
| 11 | + dest: "{{ local_path }}" |
10 | 12 | content: "Hello, world." |
11 | | - register: out |
| 13 | + mode: u=rw,go=r |
12 | 14 | delegate_to: localhost |
13 | 15 |
|
14 | 16 | - name: "delegate_to, no sudo" |
15 | 17 | assert: |
16 | | - that: "lookup('file', '/tmp/delegate_to.yml.txt') == 'Hello, world.'" |
| 18 | + that: |
| 19 | + - lookup('file', local_path) == 'Hello, world.' |
| 20 | + fail_msg: "{{ lookup('file', local_path) }}" |
17 | 21 |
|
18 | 22 | - name: "delegate_to, no sudo" |
19 | 23 | file: |
20 | | - path: /tmp/delegate_to.yml.txt |
| 24 | + path: "{{ local_path }}" |
21 | 25 | state: absent |
22 | 26 | delegate_to: localhost |
23 | 27 |
|
|
27 | 31 | # |
28 | 32 | - name: "connection:local, no sudo" |
29 | 33 | copy: |
30 | | - dest: /tmp/delegate_to.yml.txt |
| 34 | + dest: "{{ local_path }}" |
31 | 35 | content: "Hello, world." |
32 | | - register: out |
| 36 | + mode: u=rw,go=r |
33 | 37 | connection: local |
34 | 38 |
|
35 | 39 | - name: "connection:local, no sudo" |
36 | 40 | assert: |
37 | | - that: "lookup('file', '/tmp/delegate_to.yml.txt') == 'Hello, world.'" |
| 41 | + that: |
| 42 | + - lookup('file', local_path) == 'Hello, world.' |
| 43 | + fail_msg: "{{ lookup('file', local_path) }}" |
38 | 44 |
|
39 | 45 | - name: "connection:local, no sudo" |
40 | 46 | file: |
41 | | - path: /tmp/delegate_to.yml.txt |
| 47 | + path: "{{ local_path }}" |
42 | 48 | state: absent |
43 | 49 | connection: local |
44 | 50 |
|
|
47 | 53 | # delegate_to, sudo |
48 | 54 | # |
49 | 55 | - name: "delegate_to, sudo" |
50 | | - shell: whoami > /tmp/delegate_to.yml.txt |
| 56 | + shell: | |
| 57 | + whoami > "{{ local_path }}" |
| 58 | + args: |
| 59 | + creates: "{{ local_path }}" |
51 | 60 | delegate_to: localhost |
52 | 61 | become: true |
53 | 62 | tags: |
54 | 63 | - requires_local_sudo |
55 | 64 |
|
56 | 65 | - name: "delegate_to, sudo" |
57 | 66 | assert: |
58 | | - that: "lookup('file', '/tmp/delegate_to.yml.txt') == 'root'" |
| 67 | + that: |
| 68 | + - lookup('file', local_path) == 'root' |
| 69 | + fail_msg: "{{ lookup('file', local_path) }}" |
59 | 70 | tags: |
60 | 71 | - requires_local_sudo |
61 | 72 |
|
62 | 73 | - name: "delegate_to, sudo" |
63 | 74 | file: |
64 | | - path: /tmp/delegate_to.yml.txt |
| 75 | + path: "{{ local_path }}" |
65 | 76 | state: absent |
66 | 77 | delegate_to: localhost |
67 | 78 | become: true |
|
73 | 84 | # connection:local, sudo |
74 | 85 | # |
75 | 86 | - name: "connection:local, sudo" |
76 | | - shell: whoami > /tmp/delegate_to.yml.txt |
| 87 | + shell: | |
| 88 | + whoami > "{{ local_path }}" |
| 89 | + args: |
| 90 | + creates: "{{ local_path }}" |
77 | 91 | connection: local |
78 | 92 | become: true |
79 | 93 | tags: |
80 | 94 | - requires_local_sudo |
81 | 95 |
|
82 | 96 | - name: "connection:local, sudo" |
83 | 97 | assert: |
84 | | - that: "lookup('file', '/tmp/delegate_to.yml.txt') == 'root'" |
| 98 | + that: |
| 99 | + - lookup('file', local_path) == 'root' |
| 100 | + fail_msg: "{{ lookup('file', local_path) }}" |
85 | 101 | tags: |
86 | 102 | - requires_local_sudo |
87 | 103 |
|
88 | 104 | - name: "connection:local, sudo" |
89 | 105 | file: |
90 | | - path: /tmp/delegate_to.yml.txt |
| 106 | + path: "{{ local_path }}" |
91 | 107 | state: absent |
92 | 108 | connection: local |
93 | 109 | become: true |
|
0 commit comments