【发布时间】:2020-04-21 18:42:05
【问题描述】:
我想将此配置与库存插件一起使用
# test_inventory_xxx.yml
plugin: cloudscale # or openstack or ...
inventory_hostname: &inventory_hostname_value uuid
compose:
setting_of_inventory_hostname: *inventory_hostname_value
我没有收到错误,但未设置该值。它是有效的 yaml。 (至少我的检查员和我自己都看到了错误。
所以我决定使用标准的构造插件来简化它:
# inventory_constructed.yaml
plugin: constructed
# add variables to existing inventory
keyed_groups:
- key: from_inventory
prefix: inventory
parent_group: &common_parent_group test_group_1
compose:
var_from_constructed: 1233456789
also_from_constr: "'also'" # must be in quotes 2x!
some_from_constr: &ref1 1234567777
ref_from_constr: *ref1 # this works fine
ref_to_test: *common_parent_group # <--- this line returns an error
strict: yes
现在我收到错误消息:Could not set ref_to_test for host my_host: 'test_group_1' is undefined
但是当我取消注释标记的行时它通过了。 (引用 &common_parent_group 仍然被定义,但没有与 *common_parent_group 一起使用。)为什么 test_group_1 在一种情况下未定义,而在另一种情况下没有?
如何复现:ansible -i some_of/your_inventory -i inventory_constructed.yaml -m debug -a var=vars
我做错了什么?或者还有什么问题?
(我认为这是一个缺失的功能,所以https://github.com/ansible/ansible/issues/69043中的原始信息)
【问题讨论】:
标签: ansible yaml ansible-inventory