When conditional does not work with ios_config module. Why is it so?

1st playbook uses ios_command module and gets executed as intended (to display the output when hostname of device contains router1).

However 2nd playbook uses ios_config module and fails when i use the ‘when’ conditional. Am i do something wrong or is it that ‘when’ conditional is not supposed to work with ios_config module? (please ignore the formatting)

1st playbook uses ios_command module and gets executed as intended (to display the output when hostname of device
contains router1).

However 2nd playbook uses ios_config module and fails when i use the 'when' conditional. Am i do something wrong or is
it that 'when' conditional is not supposed to work with ios_config module? (please ignore the formatting)

First of all output.stdout is not a list but a string.

Can you provide sample output?

Regards
        Racke

Hi,

Thanks for your assistance. Please find output for both the playbooks as you requrested:

OUTPUT FOR 1ST PLAYBOOK (WORKING ONE):

TASK [debug] ***************************************************************************************************************************
ok: [R1] => {
“output”: {
“ansible_facts”: {
“discovered_interpreter_python”: “/usr/bin/python”
},
“changed”: false,
“deprecations”: [
{
“msg”: “Distribution Ubuntu 18.04 on host R1 should use /usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information”,
“version”: “2.12”
}
],
“failed”: false,
“stdout”: [
“hostname router28”
],
“stdout_lines”: [
[
“hostname router28”

Hi,

Thanks for your assistance. Please find output for both the playbooks as you requrested:

So if you have "hostname router28" in output.stdout, you can use the following when condition:

when: output.stdout is search('router28$')

This condition is true when the string "router28" is at the end of output.stdout.

Regards
         Racke

Hi Racke,

Thanks for the tip. But iam wondering if there is any restriction in ios_config module that my config line wouldn’t work and your config is compatable with this module?

Regards,
Vikram