ansible-role-yedit
ansible-role-yedit copied to clipboard
Better support of comments
Take this file.yml
:
variables:
var1: VAR1
#This is another definition
other:
var2: VAR2
Use this task:
- name: add variable
yedit:
src: file.yml
key: variables.var3
value: VAR3
You end up with file.yml
:
variables:
var1: VAR1
#This is another definition
var3: VAR3
other:
var2: VAR2
It's correct in a functional point of view but ugly. It would be better to have:
variables:
var1: VAR1
var3: VAR3
#This is another definition
other:
var2: VAR2
I suspect this is related to the ruamel.yaml
module, not in this one.
Upstream report: https://bitbucket.org/ruamel/yaml/issues/323/enhancement-insert-new-dict-keys-right
In my case it removes all the comments in the YAML file. @dr4Ke Has it happened to you?
I don't remember such a thing, but I have not used it in a while, so…
@Xtigyro same to me. it removed all comments and empty lines.