Ansible doesn't return correct group_vars, why? -
deploy.yaml
--- - name: test hosts: host_a tasks: - name: debug debug: var: demo
inventory
[host_a] localhost [host_a:vars] demo=aaa [host_b] localhost [host_b:vars] demo=bbb
when run playbook, want variable demo
return aaa
, returns bbb
.
why?
ansible doesn't return correct group_vars, why?
because variable defined in inventory treated fact, , fact bound host in ansible. define 1 host, named localhost
, first value gets overwritten.
confirm with:
[host_a] 127.0.0.1 [host_a:vars] demo=aaa [host_b] 127.0.0.2 [host_b:vars] demo=bbb
or
[host_a] localhost1 ansible_ssh_host=localhost [host_a:vars] demo=aaa [host_b] localhost2 ansible_ssh_host=localhost [host_b:vars] demo=bbb
Comments
Post a Comment