How do ansible host_vars work? -



How do ansible host_vars work? -

i created repo reproduce scenario.

essentially loading inventory our hosts, can override values per-host via inventory without issue seek , utilize host_vars.

i'm not 100% clear on how host vars matched host. read ansible repo examples cannot seem work documented i'm looking scrutiny of our setup.

when run command ansible-playbook -i ansible.inventory site.yml -clocal in illustration repo expect host_vars/{{ ansible_hostname }} file read , override set in vars not appear happening.

can please point me @ working illustration can see going wrong?

since documentation not specific on topic here order of precedence vars in current version of ansible:

vars set on command line -e foo=set_on_cmd_line vars set in vars_files: block in play vars set in vars: block in play vars set in host_vars/ vars set in group_vars/ role default vars roles/.../defaults/main.yml

you should think of host_vars , group_vars more defaults rather overrides defaults. if have same var set in vars_files: block like in example take precedence.

ansible ansible-playbook

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -