group_vars/vars.yml 

[root@master mywork]# cat  group_vars/vars
---
MyVariable:
  var1: 'hello'
  var2: 'world'



inventory file:
[mylocal]
localhost

[docker_con]
con1
con2


[ofsaavar:children]
mylocal
docker_con

[ofsaavar:vars]
ansible_host=con1
ansible_host=con2
ansible_ssh_user=root




to access group_vars dictionary key is not working . please check the 
following playbook

test.yml 

---
- hosts: docker_con
  remote_user: root
  gather_facts: False

  tasks:
    - debug:
         msg: "{{MyVariable.var1}}"



error:

task path: /root/mywork/stat.yml:9
fatal: [con1]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The 
error was: 'MyVariable' is undefined\n\nThe error appears to have been in 
'/root/mywork/stat.yml': line 9, column 7, but may\nbe elsewhere in the 
file depending on the exact syntax problem.\n\nThe offending line appears 
to be:\n\n  tasks:\n    - debug:\n      ^ here\n"
}
fatal: [con2]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The 
error was: 'MyVariable' is undefined\n\nThe error appears to have been in 
'/root/mywork/stat.yml': line 9, column 7, but may\nbe elsewhere in the 
file depending on the exact syntax problem.\n\nThe offending line appears 
to be:\n\n  tasks:\n    - debug:\n      ^ here\n"
}


-- 
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/0b4877ed-1b17-4360-a3d0-05dab7803c76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to