1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# flake8: noqa
# pylint: skip-file
DOCUMENTATION = '''
---
module: yedit
short_description: Create, modify, and idempotently manage yaml files.
description:
- Modify yaml files programmatically.
options:
state:
description:
- State represents whether to create, modify, delete, or list yaml
required: true
default: present
choices: ["present", "absent", "list"]
aliases: []
debug:
description:
- Turn on debug information.
required: false
default: false
aliases: []
src:
description:
- The file that is the target of the modifications.
required: false
default: None
aliases: []
content:
description:
- Content represents the yaml content you desire to work with. This
- could be the file contents to write or the inmemory data to modify.
required: false
default: None
aliases: []
content_type:
description:
- The python type of the content parameter.
required: false
default: 'dict'
aliases: []
key:
description:
- The path to the value you wish to modify. Emtpy string means the top of
- the document.
required: false
default: ''
aliases: []
value:
description:
- The incoming value of parameter 'key'.
required: false
default:
aliases: []
value_type:
description:
- The python type of the incoming value.
required: false
default: ''
aliases: []
update:
description:
- Whether the update should be performed on a dict/hash or list/array
- object.
required: false
default: false
aliases: []
append:
description:
- Whether to append to an array/list. When the key does not exist or is
- null, a new array is created. When the key is of a non-list type,
- nothing is done.
required: false
default: false
aliases: []
index:
description:
- Used in conjunction with the update parameter. This will update a
- specific index in an array/list.
required: false
default: false
aliases: []
curr_value:
description:
- Used in conjunction with the update parameter. This is the current
- value of 'key' in the yaml file.
required: false
default: false
aliases: []
curr_value_format:
description:
- Format of the incoming current value.
choices: ["yaml", "json", "str"]
required: false
default: false
aliases: []
backup:
description:
- Whether to make a backup copy of the current file when performing an
- edit.
required: false
default: true
aliases: []
author:
- "Kenny Woodson <kwoodson@redhat.com>"
extends_documentation_fragment: []
'''
EXAMPLES = '''
# Simple insert of key, value
- name: insert simple key, value
yedit:
src: somefile.yml
key: test
value: somevalue
state: present
# Results:
# test: somevalue
# Multilevel insert of key, value
- name: insert simple key, value
yedit:
src: somefile.yml
key: a#b#c
value: d
state: present
# Results:
# a:
# b:
# c: d
'''
|