Ansible: overriding dictionary variables in extra-vars [duplicate]

故事扮演 提交于 2019-11-29 11:35:11

To merge dicts, you need to set hash_behaviour=merge in your ansible.cfg. But it is not recommended to do this since pretty much all roles you find on Ansible Galaxy do expect the default value replace and might run crazy.

See hash_behaviour in the docs.

I once had a similar problem and wrote an action plugin to solve it: include_vars_merged. It is no out-of-the-box solution for your problem because Ansible in any case will override the dict with the one from --extra-vars and using my plugin, you would again override that single value you passed in --extra-vars. But it should not be too hard to modify the plugin and only add new values instead of overriding values. I think switching parameters in line 34 & 40 in include_vars_merged.py should already do it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!