Need assistance how to filter output and run additional tasks based on the previous task in ansible.
I am writing a task which check metrics configuration is enabled/disabled. If disabled need to run enable task.
- name: Verify insights configuration
shell: dsetool -h `hostname` -a username -b {{ password }} insights_config --
show_config
register: insight_output
- name: Print status
debug:
msg: "{{ insight_output.stdout }}"
- name: Filter Mode
shell: dsetool -h `hostname` -a username -b {{ password }} insights_config --
show_config | python -m json.tool | jq '.mode' | tr -d '"'
register: mode_status
Output of print status will be like below
msg:
config_refresh_interval_in_seconds: 30
data_dir_max_size_in_mb: 1024
metric_sampling_interval_in_seconds: 30
mode: ENABLED_WITH_LOCAL_STORAGE
node_system_info_report_period: PT1H
TASK [cassandra : Print mode]
msg: ENABLED_WITH_LOCAL_STORAGE
How can I accomplish running additional tasks if output shows DISABLED.