kwoodson.yedit
yedit Repository
This is a simple guide for using the Yedit Ansible role, which allows you to edit YAML files.
What is Yedit?
Yedit is an Ansible module designed to modify YAML files easily. I created this because I couldn't find an effective way to manage YAML files using Ansible.
Installation
To install Yedit, you can use Ansible Galaxy with the following command:
$ ansible-galaxy install kwoodson.yedit
It's also a good idea to create a requirements.yml
file so that others who use your playbook know which dependencies to install:
---
- src: kwoodson.yedit
You can use Yedit in your playbooks by adding it under roles like this:
roles:
- kwoodson.yedit
- role-that-uses-yedit
Examples
You might need to manage .yml
files with Ansible. Here’s an example playbook:
- hosts: localhost
gather_facts: no
roles:
- kwoodson.yedit
tasks:
- name: Manage YAML files
yedit:
src: /tmp/test.yaml
key: a.b.c
value:
d:
e:
f:
this is a test
- name: Get a specific value
yedit:
src: /tmp/test.yaml
state: list
key: a.b.c.d.e.f
register: yeditout
- debug: var=yeditout
Development
To develop or customize Yedit, just copy it to any roles directory that Ansible recognizes. For more information, check the Ansible documentation.
Documentation
You can find the complete documentation here.
A yaml/json editing module for idempotent edits.
ansible-galaxy install kwoodson.yedit