playbook的yml格式转换成json 发表于 2016-10-07 | playbook的yml格式转换成json 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162import ymlplaybook = yaml.load(file(playbook).read())playbook.yml- pattern: '*' tasks: - do: - update apache - command - [/usr/bin/yum, update, apache] onchange: - do: - restart apache - command - [/sbin/service, apache, restart] - do: - run bin false - command - [/bin/false]-----[ { "pattern": "*", "tasks": [ { "do": [ "update apache", "command", [ "/usr/bin/yum", "update", "apache" ] ], "onchange": [ { "do": [ "restart apache", "command", [ "/sbin/service", "apache", "restart" ] ] }, { "do": [ "run bin false", "command", [ "/bin/false" ] ] } ] } ] }]