我需要修改一个yaml文件(schleuder configuration),我想从一个ansible playbook中做到这一点 - 是否有一个模块可以这样做?很难谷歌这一点,所有出现的是如何写剧本。
我还需要配置管理yaml文件。我编写了一个ansible模块,在编辑yaml文件时尝试是幂等的。
我称之为yedit(yaml-edit)。 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
编辑:5/27/2018
没有这样的模块。你可以通过查看https://docs.ansible.com/ansible/list_of_all_modules.html来查看
你最好的选择是使用lineinfile或template或copy模块。