Output of changed_when: true is green
pierrehenrymuller opened this issue · 3 comments
Hi,
Very compact callback plugin, thanks.
I use actionable by default which filters messages without changes. When I need to visualize information I use a task like this one:
- debug:
msg: "{{variable}}"
changed_when: true
But with this callback debug message with changed_when true is always in ok state not on changed state.
Other little question, there is an option to filter ok state like in actionnable? When I launch playbook on many hosts there is too much ok state.
Thanks
Hello @pierrehenrymuller ,
I have created #13 to track you second demand.
As for your first issue, I would like to understand that a bit better:
You would like this:
- debug:
msg: "{{variable}}"
changed_when: true
To actually display the variable
everytime?
As a starter, could you give me a simple playbook and the actual vs expected output? Thanks!
Hi @octplane,
Thanks for take this request.
By default Ansible without callback print all actions, ok in green, changed in yellow, skip in blue.
When we enable "stdout_callback = actionable" in ansible.cfg one of standard callback plugin, all OK or skipped action are not printed. Only changed and summary at the end.
With this behaviour, most code use changed_when to switch on stdout of information or action.
In my exemple with debug and callback set to actionable we can see result.
- hosts: all
gather_facts: no
tasks:
- local_action:
module: debug
msg: "test debug not printed"
- local_action:
module: debug
msg: "test debug printed"
changed_when: true
With actionable we have this in changed yellow mode :
changed: [hostname -> localhost] => {
"msg": "test debug printed"
}
PLAY RECAP *************************************************************************************************************************************************************************
hostname : ok=2 changed=1 unreachable=0 failed=0
But with anstomlog I have more informations and it's in green text seems like OK mode but it's changed in summary :
[18:10:41] debug | hostname -> localhost | SUCCESS | 55ms
{
- msg: test debug not printed
- _ansible_delegated_vars: {
- ansible_delegated_host: localhost
- ansible_host: localhost
}
}
[18:10:41] debug | hostname -> localhost | SUCCESS | 55ms
{
- msg: test debug printed
- _ansible_delegated_vars: {
- ansible_delegated_host: localhost
- ansible_host: localhost
}
}
[18:10:42] system | -- Play recap --
hostname : ok=2 changed=1 unreachable=0 failed=0
I would expect to have only changed status with filter for ok message with yellow color for changed status only :
[18:10:41] debug | hostname -> localhost | SUCCESS | 55ms
{ msg: test debug printed }
[18:10:41] system | -- Play recap --
hostname : ok=1 changed=1 unreachable=0 failed=0
If it possible to make changed status in yellow color, option to filter OK status without changed and more compact output for debug to see only msg variable?