first post here, I got a situation, i'm trying to assign variables which are stored in roles, in my case : /var/lib/awx/projects/test/playbooks/roles/<< my roles >>/vars/main.yml but I want them to be assign by host, so I tried to assign them in my hosts files like this :
[test]
10.102.32.42 id=1 station=red ...
but that don't work, my variables are not defined.
I tried with host_vars/ ansible-playbook test_role.yml -i host -f 5 -e guest_vars_file=host_vars/test but same thing, it doesn't take my variables.
my test file:
id: 1
station: red
I tried with group_vars/ ansible-playbook test_role.yml -i host -f 5 -e guest_vars_file=group_vars/test I don't know if it's the good way to do it.
I tried a simple ansible-playbook test_role.yml -i host and files in good place but no
I tried with AWX by assign variables in my hosts, didn't worked.
When I'm passing variables with -e, it's working but my variables have to change by hosts.
Any way to do it ? or it's not possible ? I'm using ansible 2.4.3.0
I was wondering if when I launch the task, ansible overrited my variables by what it is in my vars/main.yml
where I only put
id:
station:
Edit: So the solution is to put the right name in host_vars AND ! not to put variables in roles/my_role/vars/main.yml because it will override your vars that are stock in host_vars . Thanks