I have a role that pulls in the correct variable depending on the type of 
server (eg web vs perl). If I set the variable within an inventory file, I 
can't get my task to access the variable in question. I think my issue is 
the FQDN isn't being used.

# Inventory file

[web_servers]
myweb001.phl.domain.local
myweb004.phl.domain.local
myweb005.phl.domain.local

[perl_servers]
myperl011.phl.domain.local
myperl001.phl.domain.local
myperl010.phl.domain.local

[web_servers:vars]
server_type=web
some_random_variable=20

[perl_servers:vars]
server_type=perl
some_random_variable=40


# task

- hosts: localhost

tasks:
  - debug: var={{ server_type }}


# output

PLAY [localhost]    
***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "'server_type' is 
undefined"}

NO MORE HOSTS LEFT *************************************************************
to retry, use: --limit @test.retry

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1


-- 
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/d46e6b7c-17a2-4e60-b1fa-ac9329ffbc5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to