ansible variable in host_vars not read

Viewed 27

Ι have the following

hosts

[server1]
192.168.1.1

and the following file structure

├── hosts
├── host_vars
│   └── server1
├── playbook.yaml

in hosts_vars the variable is defined

my_variable: test

if I run the playbook

ansible-playbook playbook.yaml --limit server1

i get following error

fatal: [192.168.1.1]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'my_variable' is undefined"}

It seems the host_vars is not read Someone knows what I am missing? Many Thanks!!

0 Answers
Related