Debian Codegraph @

test/integration/targets/delegate_to/has_hostvars.yml

raw
1 - name: ensure delegated host has hostvars available for resolving connection
2 hosts: testhost
3 gather_facts: false
4 tasks:
5
6 - name: ensure delegated host uses current host as inventory_hostname
7 assert:
8 that:
9 - inventory_hostname == ansible_delegated_vars['testhost5']['inventory_hostname']
10 delegate_to: testhost5
11
12 - name: Set info on inventory_hostname
13 set_fact:
14 login: invaliduser
15 mypass: badpassword
16
17 - name: test fakelocal
18 command: ls
19 ignore_unreachable: True
20 ignore_errors: True
21 remote_user: "{{ login }}"
22 vars:
23 ansible_password: "{{ mypass }}"
24 ansible_connection: fakelocal
25 register: badlogin
26
27 - name: ensure we skipped do to unreachable and not templating error
28 assert:
29 that:
30 - badlogin is unreachable
31
32 - name: delegate but try to use inventory_hostname data directly
33 command: ls
34 delegate_to: testhost5
35 ignore_unreachable: True
36 ignore_errors: True
37 remote_user: "{{ login }}"
38 vars:
39 ansible_password: "{{ mypass }}"
40 register: badlogin
41
42 - name: ensure we skipped do to unreachable and not templating error
43 assert:
44 that:
45 - badlogin is not unreachable
46 - badlogin is failed
47 - "'undefined' in badlogin['msg']"
48
49 - name: delegate ls to testhost5 as it uses ssh while testhost is local, but use vars from testhost
50 command: ls
51 remote_user: "{{ hostvars[inventory_hostname]['login'] }}"
52 delegate_to: testhost5
53 ignore_unreachable: True
54 ignore_errors: True
55 vars:
56 ansible_password: "{{ hostvars[inventory_hostname]['mypass'] }}"
57 register: badlogin
58
59 - name: ensure we skipped do to unreachable and not templating error
60 assert:
61 that:
62 - badlogin is unreachable
63 - badlogin is not failed
64 - "'undefined' not in badlogin['msg']"