diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2022-02-07 21:13:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-07 21:13:40 +0100 |
commit | be19863e44cc6b78706147b25489a73d7c8fbcb5 (patch) | |
tree | cb02b864e38bc51ed6e5edf04483e1a21cdc5ecc /test/integration/targets/delegate_to | |
parent | Temporarily remove RHEL 9.0b from test matrix. (diff) | |
download | ansible-be19863e44cc6b78706147b25489a73d7c8fbcb5.tar.xz ansible-be19863e44cc6b78706147b25489a73d7c8fbcb5.zip |
ssh connection: use 'correct' host in all cases (#76017)
ssh plugin, use 'correct' information source in all cases
* still fallback to pc
* added inventory to new test
* undef var can still show as parser error on pc
now task_exectuer has a more accurate error handling
Diffstat (limited to 'test/integration/targets/delegate_to')
4 files changed, 34 insertions, 2 deletions
diff --git a/test/integration/targets/delegate_to/delegate_facts_loop.yml b/test/integration/targets/delegate_to/delegate_facts_loop.yml index 90a25676dd..142c82ce1e 100644 --- a/test/integration/targets/delegate_to/delegate_facts_loop.yml +++ b/test/integration/targets/delegate_to/delegate_facts_loop.yml @@ -18,4 +18,4 @@ that: - "'test' in hostvars[item]" - hostvars[item]['test'] == 123 - loop: "{{ groups['all'] | difference(['localhost']) }}" + loop: "{{ groups['all'] | difference(['localhost'])}}" diff --git a/test/integration/targets/delegate_to/inventory b/test/integration/targets/delegate_to/inventory index f7ad0a33da..ebc332544c 100644 --- a/test/integration/targets/delegate_to/inventory +++ b/test/integration/targets/delegate_to/inventory @@ -7,3 +7,11 @@ testhost5 ansible_connection=fakelocal [all:vars] ansible_python_interpreter="{{ ansible_playbook_python }}" + +[delegated_vars] +testhost6 myhost=127.0.0.3 +testhost7 myhost=127.0.0.4 + +[delegated_vars:vars] +ansible_host={{myhost}} +ansible_connection=ssh diff --git a/test/integration/targets/delegate_to/runme.sh b/test/integration/targets/delegate_to/runme.sh index c262f8d168..1bdf27cfb2 100755 --- a/test/integration/targets/delegate_to/runme.sh +++ b/test/integration/targets/delegate_to/runme.sh @@ -48,7 +48,7 @@ ANSIBLE_SSH_ARGS='-C -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHos # this test is not doing what it says it does, also relies on var that should not be available #ansible-playbook test_loop_control.yml -v "$@" -ansible-playbook test_delegate_to_loop_randomness.yml -v "$@" +ansible-playbook test_delegate_to_loop_randomness.yml -i inventory -v "$@" ansible-playbook delegate_and_nolog.yml -i inventory -v "$@" diff --git a/test/integration/targets/delegate_to/test_delegate_to.yml b/test/integration/targets/delegate_to/test_delegate_to.yml index 05b0536e68..dcfa9d0351 100644 --- a/test/integration/targets/delegate_to/test_delegate_to.yml +++ b/test/integration/targets/delegate_to/test_delegate_to.yml @@ -56,3 +56,27 @@ - name: remove test file file: path={{ output_dir }}/tmp.txt state=absent + + +- name: verify delegation with per host vars + hosts: testhost6 + gather_facts: yes + tasks: + - debug: msg={{ansible_facts['env']}} + + - name: ensure normal facts still work as expected + assert: + that: + - '"127.0.0.3" in ansible_facts["env"]["SSH_CONNECTION"]' + + - name: Test delegate_to with other host defined using same named var + setup: + register: setup_results + delegate_to: testhost7 + + - debug: msg={{setup_results.ansible_facts.ansible_env}} + + - name: verify ssh plugin resolves variable for ansible_host correctly + assert: + that: + - '"127.0.0.4" in setup_results.ansible_facts.ansible_env["SSH_CONNECTION"]' |