how can I pull a string from the stdout and use it for failed_when? I run a command on a switch and then I want to match a string w/in that output to determine if it failed or not.
Here's what the playbook looks like: --- - name: Check the ssh keypair on a Nexus 9k hosts: all gather_facts: false connection: network_cli tasks: - block: - name: show keypair nxos_command: commands: "show username someuser keypair" ignore_unreachable: true register: print_output failed_when: ("could not retrieve rsa key information" in print_output.stdout) - debug: var=print_output Here's what the debug output looks like. I want to match on the 3rd line of the stdout_lines. ok: [switchB] => { "print_output": { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "failed": false, "failed_when_result": false, "stdout": [ "**************************************\n\ncould not retrieve rsa key information\n**************************************\n\ncould not retrieve dsa key information\n**************************************\n\ncould not retrieve ecdsa key information\n**************************************" ], "stdout_lines": [ [ "**************************************", "", "could not retrieve rsa key information", "**************************************", "", "could not retrieve dsa key information", "**************************************", "", "could not retrieve ecdsa key information", "**************************************" ] ] } } -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/407fe665-42a8-4264-9c77-e40099cdb525%40googlegroups.com.