Playbook:
---
- hosts: "{{hostList}}"
  vars_files:
      - "{{file}}"
  tasks:
     - debug: var=inventory_hostname


Inventory
[servers]
one ansible_connection=local
two ansible_connection=local



vars.yaml (type 1)
hostList:
   - one
   - two



Result with type 1 vars (ansible-playbook -i host test.yaml  -e 
file=vars.yaml)
PLAY [[u'one', u'two']] 
*****************************************************************************************************************************************************************************

TASK [Gathering Facts] 
******************************************************************************************************************************************************************************
ok: [two]
ok: [one]

TASK [debug] 
****************************************************************************************************************************************************************************************
ok: [one] => {
    "inventory_hostname": "one"
}
ok: [two] => {
    "inventory_hostname": "two"
}

PLAY RECAP 
******************************************************************************************************************************************************************************************
one                        : ok=2    changed=0    unreachable=0    failed=0
two                        : ok=2    changed=0    unreachable=0    failed=0



vars.yaml (type 2)
hostList: one, two





Now, result with type 2 vars (ansible-playbook -i host test.yaml  -e 
file=vars.yaml)
PLAY [one, two] 
*************************************************************************************************************************************************************************************

TASK [Gathering Facts] 
******************************************************************************************************************************************************************************
ok: [one]
ok: [two]

TASK [debug] 
****************************************************************************************************************************************************************************************
ok: [one] => {
    "inventory_hostname": "one"
}
ok: [two] => {
    "inventory_hostname": "two"
}

PLAY RECAP 
******************************************************************************************************************************************************************************************
one                        : ok=2    changed=0    unreachable=0    failed=0
two                        : ok=2    changed=0    unreachable=0    failed=0




The only difference between specifying the host list as comma separated 
list and as a proper list is this line at the start:

PLAY [[u'one', u'two']] 
*****************************************************************************************************************************************************************************


Though everything runs fine, i am just curious about the differences 
between the two ways of specifying hosts.





-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/eff5696e-cba3-415d-924b-b3c6ce8410a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to