Semaphore-UI w/ Ansible in Docker

I recently deployed Ansible at work for our Infrastructure team along side with Semaphore UI. It’s been fantastic however we recently wanted to move the Ansible platform to a Docker container setup. We deployed the semaphoreui/semaphore image which I found out is an all-in-one image for ansible, semaphore, bash and etc…

My problem is when I setup Semaphore UI to run a playbook from my private Github repo, I get access denied likely due to SSH keypair Ansible is using in the container. I can’t find the ansible.cfg when I exec into the semaphore container which has Ansible as well. I’m unclear how I can tell the docker containers Ansible what private key pair to use for ssh when cloning a repo.

Has anyone set this up in Docker that can explain what I need to do? Appreciate it.

1 Like

Try to pass extra argument to the task in semaphore

["--ssh-common-args", "-o StrictHostKeyChecking=accept-new"]

Another option could be to mount the .ssh/known_hosts from the semaphore runner in the container to the host to make it persistent. But I’m not 100% sure, because I don’t run semaphore in a container environment.

1 Like

You can use the Key Store built into Semaphore to store SSH keys. Automate that with Ansible tasks like these: api/tasks/credentials

1 Like