I’ll give your play shot (I prefer having the keys setup as I have also made the playbooks available via Jenkins for automation!) and if that doesn’t work I’ll use the password authentication for Prod and Keys for the other environments!
I’ll give Kai’s play above a shot (I prefer having the keys setup as I have also made the playbooks available via Jenkins for automation!) and if that doesn’t work I’ll use the password authentication for Prod and Keys for the other environments!
Just starting to use Ansible but wouldn't this be better solved using a separate ssh key for prod systems that requires a password that only authorized personnel have access to and loading that key into ssh agent before running plays? Depending on you naming scheme, you may even be able to specify production hosts via wildcard in ~/.ssh/config file. This not only limits the ability to push to production but adds additional security.
Note: Ansible's user module can be used to push out new ssh authorized keys.
Apologies if this solution is off the mark but my background is in information security.
I’ve integrated the playbook with Jenkins - so it doesn’t work on there. I get the following error: [WARNING]: Not waiting from prompt as stdin is not interactive
But I suppose that’s not a problem as we can run DEV/UAT via Jenkins (GUI) and the PROD environment via CLI.