Someone kindly help me on this. Im using ansible version 2.5.5 and Ive 
followed Ansible best practices for directory structure and went through 
many docs and I feel Im correct here, but still things are not working.

--- ansible.cfg
--- inventory/
    --- qa/
        --- group_vars/
              --- all.yml
        --- hosts.ini
--- playbook.yml
--- roles
     --- myrole
         --- tasks
             ---  main.yml
      --- vars
             --- ctr1.yml
             --- ctr2.yml
             --- ctr3.yml
    --- templates
             --- ctr1.yml.j2
             --- ctr2.yml.j2
             --- ctr3.yml.j2


Inventory/qa/hosts has below.

[Myapps]
Ctr1
Ctr2
Ctr3

[Ctr1:vars]
app=ctrl1
Appname="{{ app }}-{{ ansible-host }}-{{ type }}"

[Ctr2:vars]
appp=ctrl2
Appname="{{ app}}-{{ ansible-e to }}-{{ type }}"

[Ctr2]
app=ctrl3
Server1/dynt ansible-host=server1 type=dynt
Server1/splunk ansible-host=server2 type=splunk


Roles/tasks/main.yml ( I have customcli)
Command: customcli --host {{ ansible-host }} --appname {{ Appname }}



ansible-playbook -i inventory/qa/hosts myrole.yml throws an error stating 
Appname, ansible-host, type is undefined. It doesnt  pick any variables in 
hostsfile nor in group_vars.





On Friday, May 24, 2019 at 8:42:13 PM UTC+5:30, Saranya N wrote:
>
> My structure looks like below.
>
> Inventory/qa folder has below.
>
>   hosts # inventory file
>   Check # inventory file
>  group_vars/
>   all.yml
>   myrole.yml
>
> myrole folder has below
>
> myrole/
>
>  tasks/main.yml
>  Vars/
>    ctr1.yml
>    Ctr2.yml
>    Ctr 3.yml
>    main.yml
>  Templates/
>    Ctr1.yml.j2
>    Ctr2.yml.j2
>    Ctr3.yml.j2
>
> My roles/tasks/main.yml decides which vars Ctrl file to load depending on 
> my extravars c=1 or c=2 or c=3 .
>
> Inventory/qa/Check file has below.
>
> [Myapps]
> Ctr1
> Ctr2
> Ctr3
>
> [Ctr1:vars]
> Appname="{{ app }}-{{ ansible-host }}-{{ type }}"
>
> [Ctr2:vars]
> Appname="{{ app}}-{{ ansible-e to }}-{{ type }}"
>
> [Ctr2]
> Server1/dynt ansible-host=server1 type=dynt
> Server1/splunk ansible-host=server2 type=splunk
>
>
> Roles/tasks/main.yml ( I have customcli)
> Command: customcli --host {{ ansible-host }} --appname {{ Appname }}
>
>
> Roles tasks don't pick any variables defined under Check inventory file
>
> Can someone please help??
>
> I did research a lot in ansible docs and I'm unable to figure out my 
> mistake.
>
> Can someone please guide me why it's not picking inventory variables 
>
>

-- 
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/611e09f5-22af-4167-b435-7c81ec198152%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to