tread
tread

Reputation: 11098

How do you give a Newly Provisioned Server access to a Private Git Repo with Ansible?

I have provisioned a server with ansible and now I would like to clone a private git repo (not github).

So my local machine's ssh key is authorized on the private git repo and what I have done up till now is copy my local public and private ssh key to the server.

But I feel this is not the best way to go about it.

I know if you are using github you can use the API to create a deploy key. But I am not.

So the only other way I can see is:

  1. Generate ssh key-pair on new server
  2. Copy that newly created ssh key-pair locally with fetch
  3. ssh-copy-id or use authorized_keys to add the servers key to the private git repo

Is there something I am missing, can it be done in another easier way?

Upvotes: 0

Views: 111

Answers (1)

Marc
Marc

Reputation: 854

You haven't described what your constraints are, and haven't mentioned if you're comfortable creating additional keys and managing them within your private git repo.

Another possible option:

  1. Setup ssh-agent and add your personal key to it before running ansible, and forward your agent to the remote host when you run ansible.

For that solution: SSH Agent Forwarding with Ansible for more details.

Upvotes: 1

Related Questions