Hello
I have the following directory and I run ansible 2.4.1.0 with python 2.7 , on Redhat 6/7 server
inventories/
production/
hosts.prod # inventory file
group_vars/
all
host_vars/
dev/
hosts.dev # inventory file
group_vars/
all
host_vars/
stagehost1
stagehost2
roles/
common_configuration
tasks/
main.yml
vars/
main.yml
playbook/
all.yml
for the role common_configuration
my task is
- name: set timezone , default to Europe/verlin but can be override by inventory
timezone:
name: “{{ timezone }}”
notify: - restart crond
and my variable in the role is
timezone: Europe/verlin
( I konw this value is not a legit timezone but it’s for testing purpose)
In my dev inventory, I set in all.yml the variable with a different string.
timezone: Europe/Paris
Here how I call my playbook
ansible-playbook -u lebrett-adm -k --become -i /etc/ansible/inventories/dev/hosts.dev playbook/all.yml --limit matching
As far I understand variable precedence , role variable should be overriden by inventory . But in my case , it stay with role variable.
TASK [common_configuration : set timezone , default to Europe/Paris but can be override by inventory] *************************************************************************************************
fatal: [srvamsdev-mat02]: FAILED! => {“changed”: false, “failed”: true, “msg”: “Error message:\ngiven timezone "Europe/verlin" is not available”}
fatal: [srvamsdev-mat01]: FAILED! => {“changed”: false, “failed”: true, “msg”: “Error message:\ngiven timezone "Europe/verlin" is not available”}
to retry, use: --limit @/etc/ansible/playbook/all.retry
For testing, I have deleted variable in role and ansible use variable in my dev inventory.
Am i doing something wrong ?
Regards
Thibaud LEBRET