I want to connect to a host from which I will run ansible playbook using screen. Using screen allows me to have the playbook finish in case my ssh connection gets interrupted or terminated. So far no problem here.
My ansible host needs password or ssh key to connect to the hosts in the inventory file. So instead of creating a new private key, I use ssh agent forwarding when I connect to my ansible instance.
# from my macOS
ssh -A ansible-host
# from ansible-host
screen -R run-playbook-example
ansible-playbook -i inventory/hosts my-playbook.yml
Everything works great so far. Until I simulate losing connection. That also means the agent forwarding no longer works, and ansible-host cannot authenticate to any of the hosts. Which defeats the whole point of using screen.
Is there anyway to do both? 1) Avoid creating a new ssh private key and storing it on ansible host and use ssh agent forwarding or some other trick 2) Be able to run in screen without worrying if you lose ssh connection to ansible-host and have your playbook run regardless if you disconnect.
Something tells me it is not possible. But I really hate to have to store a private key that several people will have access to just so I can use screen and be immune to ssh connection issues. Any ideas, tips, different ways of approaching this problem?