Table of Contents

, ,

Clone remote repository with ansible git module using ssh key

You can use your ssh agent to forward the keys to the remote server, however when running ansible on one remote host and deploying to another, for example when triggering ansible from a Rundeck job easiest is to copy the private key file on the remote host. e.g. in the playbook add task

...
- name: Ensure ssh deploy key is present on the server.
  copy:
    content: "{{ deploy_private_key }}"
    dest: /tmp/deploy_key
    mode: 0600
 ...

- name: 'Delete private key'
  file:
    path: "/tmp/deploy_key"
    state: absent
  tags: deploy_artifact

Tested on

See also

References