Ansible strip white space

Question:

When I try to run some commands on nxos devices, the output has a white space at the end. I have to compare the output to an existing variable list. The whitespace at the end is causing the comparison to go false. How to make use of .strip() function in a list of strings?

The output of this comes up like this:

When I compare this line with my desired variables, I can’t get it matched because of the white space on the first line at the end.

Answer:

To apply a function to list elements use map filter. To strip whitespace use trim filter.

Leave a Reply