konono.easyconf.ezconf (1.0.3) — module

easy yaml and json config editor

| "added in version" 2.11 of konono.easyconf"

Authors: Yuki Yamashita (@konono)

preview | supported by community

Install collection

Install with ansible-galaxy collection install konono.easyconf:==1.0.3


Add to requirements.yml

  collections:
    - name: konono.easyconf
      version: 1.0.3

Description

This is a module that makes it easy to configure a config file with a data structure

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: 'Test add pattern 1 yaml'
  konono.easyconf.easyconf:
    src: '{{ playbook_dir }}/tests/test.yml'
    key: 'config.d'
    value: 30
    state: 'present'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: 'Test add pattern 2 yaml'
  konono.easyconf.easyconf:
    src: '{{ playbook_dir }}/tests/test.yml'
    key: 'config.a-b'
    value: 'c'
    state: 'present'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: 'Test add pattern 3 yaml'
  konono.easyconf.easyconf:
    src: '{{ playbook_dir }}/tests/test.yml'
    key: 'config.e'
    value: [1,2,3,4]
    state: 'present'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: 'Test add pattern 4 yaml'
  konono.easyconf.easyconf:
    src: '{{ playbook_dir }}/tests/test.yml'
    key: 'config.f'
    value: [{a: 1, b: 2},{c: 3, d: 4}]
    state: 'present'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: 'Test add pattern 5 yaml'
  konono.easyconf.easyconf:
    src: '{{ playbook_dir }}/tests/test.yml'
    key: 'lists[2]'
    value: 100
    state: 'present'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: 'Test modify pattern 1 yaml'
  konono.easyconf.easyconf:
    src: '{{ playbook_dir }}/tests/test.yml'
    key: 'config.a'
    value: 100
    state: 'present'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: 'Test modify pattern 2 yaml'
  konono.easyconf.easyconf:
    src: '{{ playbook_dir }}/tests/test.yml'
    key: 'lists[0]'
    value: 100
    state: 'present'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: 'Test delete pattern 1 yaml'
  konono.easyconf.easyconf:
    src: '{{ playbook_dir }}/tests/test.yml'
    key: 'lists[0]'
    value: 0
    state: 'absent'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: 'Test delete pattern 2 yaml'
  konono.easyconf.easyconf:
    src: '{{ playbook_dir }}/tests/test.yml'
    key: 'lists[0]'
    value: 100
    state: 'absent'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: 'Test check pattern 1 yaml'
  konono.easyconf.ezconf:
    src: '{{ playbook_dir }}/tests/test.yml'
    key: 'my'
    state: 'check'
  register: res

Inputs

    
key:
    description:
    - Set the key you want to edit. The input should be in json format.
    required: true

src:
    description:
    - Set the path to the config target.
    required: true

state:
    description:
    - Set the state taht present or absent, check.
    required: false

value:
    description:
    - Set the value to be assigned to key.
    required: false

backup:
    description:
    - Set the true if you need src file backup.
    required: false

Outputs

value:
  description: Return the value of the key that was matched if set check to the state.
  returned: success
  sample: value
  type: raw