Skip to content

Latest commit

 

History

History
48 lines (38 loc) · 1.24 KB

README.md

File metadata and controls

48 lines (38 loc) · 1.24 KB

yedit repository

Ansible Role: Yedit

This repository contains an ansible module for modifying yaml files.

I didn’t see a good method of editing yaml files and config managing them through ansible. This is my attempt.

Install

As yedit is not a listed Ansible module, have to install it manually by placing lib_yaml_editor directory in a location recognized by Ansible. For details, see Ansible documentation: * Embedding Modules and Plugins In Roles * module_utils

Examples

Sometimes it is necesarry to config manage .yml files.

- hosts: localhost
  gather_facts: no
  roles:
  - roles/lib_yaml_editor
  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