Kitware / gobig

Provisioning big data applications with Resonant
Apache License 2.0
5 stars 3 forks source link

Incorporate the play_hosts ansible variable in roles that target groups #29

Open opadron opened 9 years ago

opadron commented 9 years ago

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 form XYZ_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 from play_hosts instead of looking up any particular group.

haroldTlan commented 8 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 “????” ?

haroldTlan commented 8 years ago

thank you your explanation,i decide to use "{{ ansible_eth0.ipv4.address }}"