Rheinwerk.yedit
// vim: ft=asciidoc
= yedit-Repository :toc: macro :toc-title:
toc::[]
== Ansible-Rolle: Yedit
Dieses Repository enthält ein Ansible-Modul zum Bearbeiten von YAML-Dateien.
Ich habe keine gute Methode gefunden, YAML-Dateien zu bearbeiten und über Ansible zu verwalten. Das ist mein Versuch.
== Installation
Du kannst es über Ansible Galaxy installieren:
$ ansible-galaxy install kwoodson.yedit
Wenn du das tust, solltest du auch eine requirements.yml
hinzufügen, damit andere Benutzer deines Playbooks wissen, welche Abhängigkeiten installiert werden müssen:
---
- src: kwoodson.yedit
Dann kannst du es in einem Play verwenden, indem du es vorher importierst:
roles:
- kwoodson.yedit
- rolle-die-yedit-verwendet
== Beispiele
Manchmal ist es notwendig, .yml-Dateien zu verwalten. [source,yaml]
- hosts: localhost
gather_facts: no
roles:
kwoodson.yedit tasks:
name: verwalte YAML-Dateien yedit: src: /tmp/test.yaml key: a.b.c value: d: e: f: das ist ein Test
name: Hole einen bestimmten Wert yedit: src: /tmp/test.yaml state: list key: a.b.c.d.e.f register: yeditout
debug: var=yeditout
== Entwicklung
Da dies eine Rolle ist, kopiere sie einfach in ein Verzeichnis für Rollen, das von Ansible erkannt wird. Für Details siehe die http://docs.ansible.com/ansible/latest/index.html[Ansible-Dokumentation]:
- http://docs.ansible.com/ansible/devel/playbooks_reuse_roles.html#embedding-modules-and-plugins-in-roles[Einbetten von Modulen und Plugins in Rollen]
- http://docs.ansible.com/ansible/latest/intro_configuration.html#module-utils[module_utils]
== Dokumentation
Die vollständige Dokumentation ist hier https://github.com/kwoodson/ansible-role-yedit/blob/master/library/yedit.py#L15[verfügbar].