我需要修改 yaml 文件(施洛德配置 http://schleuder2.nadir.org/documentation/v2.2/index.html)并且我想从 ansible 剧本中执行此操作 - 是否有模块可以执行此操作?很难用谷歌搜索这个,出现的一切都是如何编写剧本。
我还需要配置管理 yaml 文件。我编写了一个 ansible 模块,尝试在编辑 yaml 文件时实现幂等。
我称之为 yedit(yaml-edit)。https://github.com/kwoodson/ansible-role-yedit https://github.com/kwoodson/ansible-role-yedit
如果您觉得有用,请告诉我。当我们的团队遇到需要时,我将根据请求或拉取请求添加功能。
这是一个简单的剧本示例:
roles:
- lib_yaml_editor
tasks:
- name: edit some yaml
yedit:
src: /path/to/yaml/file
key: foo
value: bar
- name: more complex data structure
yedit:
src: /path/to/yaml/file
key: a#b#c#d
value:
e:
f: This is a test
应该产生类似这样的东西:
foo: bar
a:
b:
c:
d:
e:
f: This is a test
编辑:2018 年 5 月 27 日
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)