Hello guys,
I am not quite sure how to describe this.
I have a simple task, which executes a shell command and register a variable.
- name: execute ovs-vsctl show command
shell: ovs-vsctl show
register: output
This will give me stdout with different ports like this:
Port “7da0c92dc […]”
Port “[479401901[…]”
[…]
But some Ports will have an error:
“could not open network device 5b574[…]”
Now I need to get all the Ports with an error (with a loop i guess (?)). Then execute a command to delete this faulty ports in subsuquent task :
- name: delete faulty ports
shell: ovs-vsctl del-port 5b574[…]
I was thinking about something like this:
- shell: ’ ovs-vsctl del-port “{{item}}” ’
with_items:
- 5b574 […]
- xxxx […]
Or what is the best way to realize this? (Probably by using a python/shell script, but it should be done with Ansible)
I have a hard time to realize this.
How can I filter for all those specific strings with faulty ports?
I probably need to save those strings in a list or something, by using a loop, right?
I would be grateful for any help / some ideas regarding the best way to proceed with this.