Hi, I am trying to work out how to iterate through some results from a command I am running on a network device. the idea is when I find the line that matches what I am looking for based on a regexp I want to store it.
`
tasks:
-
name: get the existing access-list
ios_command:
provider: “{{ cli }}”
commands: -
show access-list mgtaccess
register: result -
debug: var=result.stdout_lines
-
name: Do something with each result
debug:
msg: “{{ item }}”
with_items: -
“{{ result.stdout_lines }}”
`
This is the output from the task
`
ok: [172.16.1.135] => (item=[u’Standard IP access list mgtaccess’, u’ 20 permit 10.1.1.1’, u’ 10 permit 192.168.0.1’, u’ 30 permit any (2566 matches)']) => {
“changed”: false,
“failed”: false,
“item”: [
“Standard IP access list mgtaccess”,
" 20 permit 10.1.1.1",
" 10 permit 192.168.0.1",
" 30 permit any (2566 matches)"
],
“msg”: [
“Standard IP access list mgtaccess”,
" 20 permit 10.1.1.1",
" 10 permit 192.168.0.1",
" 30 permit any (2566 matches)"
]
}
`
I'm confused shouldn't I be seeing multiple individual 'msg's??
Many thanks.