Hi all;

Our company has 150+ files in an ansible repository, written by many 
authors over years.

I'd like to reformat them into a canonical format, so that we can write 
utilities to update them without having to handle all the variations.

I tried to use the python version of `yq <https://kislyuk.github.io/yq/>` 
to do it: 
-----
cat input.yml \
  | sed 's/^\( *mode: \)\([^" ]*\)/\1"\2"/; s/^ *\(#.*\)/- "\1"/; s/^---/- 
"#---"/' \
| yq -Y . \
| sed 's/^\( *- name:\)/\n\1/; s/^- "#---"/---/; s/^- "\(#.*\)"/\1/' \
> output.yml 

diff input.yml output.yml
-----
but that feels like a hack (had to work around comments being stripped, 
file permissions changing from octal to decimal, etc).

Ideally, ansible-playbook would have a `--dump-playbook-file=output.yml` to 
do this, since Ansible is the ultimate judge of what a playbook means, but 
my RFE <https://github.com/ansible/ansible/issues/75696> was redirected to 
the mailing list.   :-)

Any ideas?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7ba68c08-b728-480f-9d5f-090eaa2f1982n%40googlegroups.com.

Reply via email to