I need to modify a yaml file (schleuder configuration) and I'd like to do this from an ansible playbook - is there a module to do so? Hard to google for this, everything that turns up is how to write playbooks.
Ansible uses YAML syntax for expressing Ansible playbooks. This chapter provides an overview of YAML. Ansible uses YAML because it is very easy for humans to understand, read and write when compared to other data formats like XML and JSON.
This page provides a basic overview of correct YAML syntax, which is how Ansible playbooks (our configuration management language) are expressed. We use YAML because it is easier for humans to read and write than other common data formats like XML or JSON.
I also have the need to config manage yaml files. I have written an ansible module that attempts to be idempotent while editing yaml files.
I call it yedit (yaml-edit). https://github.com/kwoodson/ansible-role-yedit
Please let me know if you find it useful. I'll be adding features when our team runs into the need, by request, or by pull-request.
Here is a simple playbook example:
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
Should produce something that looks like this:
foo: bar a: b: c: d: e: f: This is a test
Edit: 5/27/2018
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With