Cisco Router Configuration - match when description is <word> Conditional Check Failed

I have written this play to run over a Cisco Router- then create a list of interfaces and the idea is to only apply a config to an interface based on the value or not of the descrption.

The play works fine up until the last point.

  • block:
  • name: write config to interface
    with_indexed_items: " {{ my_list }} "
    ios_config:
    lines: description CHANGED
    parents: GigabitEthernet{{ item.1 }}
    provider: “{{ cli }}”
    match: none
    when: “’ description ANSIBLE’ in output.results[{{ item.0 }}].stdout_lines”

It just says conditional check failed

skipping: [CSR-02] => (item=(1, u'GigabitEthernet2')) => { "changed": false, "item": [ 1, "GigabitEthernet2" ], "skip_reason": "Conditional check failed", "skipped": true

All I want to do is for the interface that has a description of Ansible to perform a config change.

What am I doing wrong?

TASK [show output] *************************************************************
task path: /etc/ansible/playbooks/skip_int.yaml:36
ok: [CSR-02] => (item=(1, u’GigabitEthernet2’)) => {
“invocation”: {
“module_args”: {
“var”: “output.results[1].stdout_lines”
},
“module_name”: “debug”
},
“item”: [
1,
“GigabitEthernet2”
],
“output.results[1].stdout_lines”: [
[
“Building configuration…”,
“”,
“Current configuration : 69 bytes”,
“!”,
“interface GigabitEthernet2”,
" ip address dhcp",
" negotiation auto",
“end”,
“”
]
]
}
ok: [CSR-02] => (item=(0, u’GigabitEthernet1’)) => {
“invocation”: {
“module_args”: {
“var”: “output.results[0].stdout_lines”
},
“module_name”: “debug”
},
“item”: [
0,
“GigabitEthernet1”
],
“output.results[0].stdout_lines”: [
[
“Building configuration…”,
“”,
“Current configuration : 98 bytes”,
“!”,
“interface GigabitEthernet1”,
" description ANSIBLE",
" no ip address",
" shutdown",
" negotiation auto",
“end”,
“”
]
]
}
ok: [CSR-02] => (item=(2, u’GigabitEthernet3’)) => {
“invocation”: {
“module_args”: {
“var”: “output.results[2].stdout_lines”
},
“module_name”: “debug”
},
“item”: [
2,
“GigabitEthernet3”
],
“output.results[2].stdout_lines”: [
[
“Building configuration…”,
“”,
“Current configuration : 95 bytes”,
“!”,
“interface GigabitEthernet3”,
" description test interface",
" no ip address",
" negotiation auto",
“end”,
“”
]
]
}

Don't use curly brackets in when:, they are implied.
If you do you can get all kind of strange behavior.

when: "' description ANSIBLE' in output.results[item.0].stdout_lines"

Thanks, tried that but it still skips the conditional check.

After checking the variable output I see that the
output.results[item.0].stdout_lines
contains a list of lists so you need to use

output.results[item.0].stdout_lines.0