Hi all. I was redirected here from the Ansible issue tracker on Github. I am having difficulties with a specific use case I’m hoping to get help with.
I am trying to find a way to programatically change SSH credentials in an Ansible play between tasks and / or between hosts. Here is my most basic use case: When bootstrapping a new server that has no LDAP configuration, user profiles, etc. I need to authenticate as root. However, in the first play I want to set up a limited user with sudo permissions (presumably while logged in as root), then I want to disable remote logins for root and continue running the rest of the plays as my newly created user.
For bootstrapping purposes, the root users typically just have password enabled authentication using a known default password… however the user created by this first play is being configured with an SSH key to facilitate passwordless logins for the remainder of the plays.
Can someone tell me how I might orchestrate this seemingly simple sequence of events? I’ve read up on ssh_args, ansible_pass, remote_user, and many other ways of defining credentials for tasks but none of them seem to allow the modification of the user and password in the way I’ve described above. So any help / suggestions anyone has in this regard would be appreciated.
We run our ansible plays on various Linux OSes and Mac OS X, and we’re using the latest version of Ansible in case that helps at all.