I want to create a file that shows the execution progress and what is being done when I run tasks. Now I want to generate a JSON format when I have done it through local_action
and lineinfile
.
This is my playbook
- name: The module that Set the progress and details
block:
- name: Set the progress and details
shell: echo "10"
register: progress_result
delegate_to: localhost
- name: Set the progress and details
shell: echo "update docker script"
register: message_result
delegate_to: localhost
- name: Save progress
delegate_to: localhost
local_action:
module: lineinfile
path: "{{playbook_dir}}/scheduler/plan.yaml"
regexp: "progress:"
line: "progress:{{progress_result.stdout}},step:{{message_result.stdout}}"
create: yes
The current results of operation is
# cat scheduler/plan.yaml
progress:10,step:update docker script
But I would like to have the results in JSON format
{"progress":"10","step":"update docker script"}
Who can help me?