yedit 3.4 KB

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