Possibly linux to linuxmemesEnglish • 1 year agoAnsible casually administering hundreds or thousands of deviceslemmy.zipimagemessage-square53fedilinkarrow-up1221arrow-down19
arrow-up1212arrow-down1imageAnsible casually administering hundreds or thousands of deviceslemmy.zipPossibly linux to linuxmemesEnglish • 1 year agomessage-square53fedilink
minus-square@rtxnMlinkEnglish4•edit-21 year agoYou can use JSON to write the playbooks, then use a program like yq (which is a Yaml wrapper for jq) to convert it to Yaml. Something like cat playbook.json | yq --yaml-output > .temp_playbook.yml ansible-playbook .temp_playbook.yml
minus-square@MeanEYElink1•1 year agoI did not know that. That’s a useful one. Does it work the other way around?
minus-square@rtxnMlinkEnglish2•1 year agoYes, both yq and jq are fantastic programs. yq can take either JSON or Yaml (or maybe others, I haven’t checked) as input, then it converts it to JSON before passing it to jq. yq outputs JSON by default, or Yaml if you pass it the --yaml-output option.
You can use JSON to write the playbooks, then use a program like
yq
(which is a Yaml wrapper forjq
) to convert it to Yaml. Something likecat playbook.json | yq --yaml-output > .temp_playbook.yml ansible-playbook .temp_playbook.yml
I did not know that. That’s a useful one. Does it work the other way around?
Yes, both
yq
andjq
are fantastic programs.yq
can take either JSON or Yaml (or maybe others, I haven’t checked) as input, then it converts it to JSON before passing it tojq
.yq
outputs JSON by default, or Yaml if you pass it the--yaml-output
option.