Sorry, I should also mention that I'm on the devel branch. I tried it using 
stable-2.0 but it did the same thing.

On Thursday, January 14, 2016 at 1:49:28 PM UTC-8, Guy Knights wrote:
>
> I have a variable defined in group_vars that I'm trying to use in a task 
> but it is failing for me. So I created a debug task to dump the contents of 
> this variable so I can see what ansible thinks is defined. If I try the 
> following:
>
> - debug: var=mysql
>
> It outputs "mysql": "VARIABLE IS NOT DEFINED!". I changed the above debug 
> task to:
>
> - debug: var=hostvars[inventory_hostname]['mysql']
>
> When I run it with the change above I get instead:
>
> "hostvars[inventory_hostname]['mysql']": {
>         "dbs": [
>             {
>                 "backup": {
>                     "retention": 3,
>                     "window": "06:00-06:30"
>                 },
>                 "name": "db1",
>                 "size": 100,
>                 "type": "rds",
>                 "users": [
>                     {
>                         "host": "127.0.0.1",
>                         "name": "db1user",
>                         "password": "userpass",
>                         "privs": [
>                             "db1.*:ALL"
>                         ]
>                     }
>                 ]
>             },
>             {
>                 "name": "db2",
>                 "type": "mysql",
>                 "users": [
>                     {
>                         "host": "127.0.0.1",
>                         "name": "root",
>                         "password": "testpass",
>                         "privs": [
>                             "*.*:ALL"
>                         ]
>                     },
>                     {
>                         "host": "::1",
>                         "name": "root",
>                         "password": "testpass",
>                         "privs": [
>                             "*.*:ALL"
>                         ]
>                     },
>                     {
>                         "host": "localhost",
>                         "name": "root",
>                         "password": "testpass",
>                         "privs": [
>                             "*.*:ALL"
>                         ]
>                     },
>                     {
>                         "host": "{{ 
> hostvars[inventory_hostname][ansible_hostname] }}",
>                         "name": "root",
>                         "password": "testpass",
>                         "privs": [
>                             "*.*:ALL"
>                         ]
>                     },
>                     {
>                         "host": "127.0.0.1",
>                         "name": "db2user",
>                         "password": "userpass",
>                         "privs": [
>                             "db2.*:ALL"
>                         ]
>                     }
>                 ]
>             },
>             {
>                 "name": "db3",
>                 "type": "mysql",
>                 "users": [
>                     {
>                         "host": "127.0.0.1",
>                         "name": "root",
>                         "password": "testpass",
>                         "privs": [
>                             "*.*:ALL"
>                         ]
>                     },
>                     {
>                         "host": "::1",
>                         "name": "root",
>                         "password": "testpass",
>                         "privs": [
>                             "*.*:ALL"
>                         ]
>                     },
>                     {
>                         "host": "localhost",
>                         "name": "root",
>                         "password": "testpass",
>                         "privs": [
>                             "*.*:ALL"
>                         ]
>                     },
>                     {
>                         "host": "{{ 
> hostvars[inventory_hostname][ansible_hostname] }}",
>                         "name": "root",
>                         "password": "testpass",
>                         "privs": [
>                             "*.*:ALL"
>                         ]
>                     },
>                     {
>                         "host": "127.0.0.1",
>                         "name": "db3user",
>                         "password": "userpass",
>                         "privs": [
>                             "db3.*:ALL"
>                         ]
>                     }
>                 ]
>             }
>         ]
>     }
>
> So, it works when I reference the var from the hostvars, but when I 
> reference it as a standalone variable it doesn't. I also checked with some 
> other vars that are defined in the exact same way within my group_vars, and 
> they output fine whichever method I use.
>
> What's the issue here? Am I missing something?
>

-- 
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/32540179-5182-4db9-b644-ddeea19854fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to