Creating playbook to deal with multiple possible login names (Fallback login)

I need to run automation against many hosts. Some use login “A”, some use login “B”. Passwords are the same.

  1. How can I get ansible to try a secondary login based on login failure?

  2. I’ve written a playbook to try multiple logins, and set ansible_user according to success or failure, but it stops at the first authentication failure. I excute an innocuous command to verify ability to sudo to root to verify success. I Need it to continue after the initial authentication failure. Note that the first llogin actually works, but it all craps out after being unable to authenticate.

Below is my script, and execution output follows:

auth_desprawl.yml

Why don’t you just make them separate play books? Simplify your task.

A fair answer, Brad.

We can actually run the same playbook multiple times by setting “-u” at runtime.

While the tasks may be executed, I’d have multiple logs of the tasks, I have other scripts that parse the output for success/failure rates.

Having three similar logfiles becomes messy to reconcile, sort out and parse.

would rather have one script that is more tolerant of failures.