在运行 Python 3.12.4 (通过 homebrew) 的 Mac (M1) 上的 Ansible 2.16.8 中,我尝试设置一个全局 group_vars/all.yml,如果需要,可以通过 inventory/x/group_vars/all.yml 覆盖该 group_vars/all.yml。但是,似乎全局文件正在覆盖库存特定值。
给定以下文件:
# group_vars/all.yml
level: global all
# inventory/x/group_vars/all.yml
level: inventory all
# inventory/x/group_vars/test.yml
level: inventory group
并运行:
ansible all -i inventory/x -m debug -a "var=level" -o
我得到:
test-host | SUCCESS => { "changed": false, "level": "inventory group" }
non-test-host | SUCCESS => { "changed": false, "level": "global all" }
但我期望得到:
test-host | SUCCESS => { "changed": false, "level": "inventory group" }
non-test-host | SUCCESS => { "changed": false, "level": "inventory all" }