Created
July 6, 2021 10:48
-
-
Save u1735067/fa4511befdb6cf4bd34de3d58bca5dad to your computer and use it in GitHub Desktop.
Why ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# ---Setup: | |
# > ansible-playbook -i mytest.ini mytest.yml --limit test2 | |
# ./mytest.ini: | |
# test1 site=ams | |
# test2 site=ams | |
# test3 site=blg | |
# | |
# ---Result: | |
# PLAY [TEST] ******************************************************************** | |
# | |
# TASK [ansible.builtin.debug] *************************************************** | |
# fatal: [test2]: FAILED! => {"msg": "'my_host' is undefined"} | |
# | |
# NO MORE HOSTS LEFT ************************************************************* | |
# | |
# PLAY RECAP ********************************************************************* | |
# test2 : ok=0 changed=0 unreachable=0 failed=1 | |
# skipped=0 rescued=0 ignored=0 | |
- name: TEST | |
hosts: all | |
connection: local | |
vars: | |
ansible_connection: local | |
run_once: true | |
tasks: | |
- ansible.builtin.debug: | |
msg: "{{ my_host }}" | |
vars: | |
ansible_connection: ansible.netcommon.httpapi | |
ansible_host: "{{ my_host }}" | |
ansible_httpapi_host: "{{ my_host }}" | |
loop_control: | |
loop_var: my_host | |
label: "{{ my_host }}" | |
loop: "{{ hostvars.values() | map(attribute='inventory_hostname') }}" | |
delegate_to: localhost | |
# delegate_facts: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment