Open opadron opened 9 years ago
Please forgive my disturb,play_hsots is all ip address if I want to get single ip address when I using one of the inventory.
eg:
$ cat hosts
[temp]
192.168.2.[100:110]
$ cat temp.yml
- hosts: "{{ temp}}"
remote_user: root
vars_files:
- vars/server.yml
tasks:
#- name: print all hosts
#shell: echo ""{{ play_hosts }}"" >> ~/temp.sh
- name: print single hosts
shell: echo "?????" >> ~/temp.sh
I want to get the result that there just a temp.sh
in each target machine
$ cat temp.sh
single ip adreess
I do not know what should I do in “????” ?
thank you your explanation,i decide to use "{{ ansible_eth0.ipv4.address }}"
Inspired from discussion in #27.
The
play_hosts
ansible variable is a magic ansible variable that expands to a list of the hosts participating in the current play. The various roles that target a particular ansible group (i.e.: require parameters of the formXYZ_ansible_group
) are often used to target the same hosts as those participating in the current play. These roles should be reworked so that their ansible group parameters are no longer required, but instead default to some internal logic that pulls the hosts fromplay_hosts
instead of looking up any particular group.