Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@toddlers
Created October 28, 2017 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toddlers/bde37535c042456e91e237daf8a6cf68 to your computer and use it in GitHub Desktop.
Save toddlers/bde37535c042456e91e237daf8a6cf68 to your computer and use it in GitHub Desktop.
Solution for `git clone` using Ansible for repos with private submodules with github deploy keys
# Problem:
#
# If you use git submodules linking two private github repos, you'll need to create a separate deploy key for each.
# Multiple keys are not supported by Ansible, nor does ansible (when running git module) resort to your `.ssh/config` file.
# This means your ansible playbook will hang in this case.
#
# You can however use the ansible git module to checkout your repo in multiple steps, like this:
#
- hosts: webserver
vars:
- destination: /your/dest/path
tasks:
- name: App | Cloning repos + submodules
git: repo=git@github.com:Organisation/{{ item.repo }}.git
dest={{ item.dest }}
accept_hostkey=yes
force=yes
recursive=no
key_file=/home/user/.ssh/id_rsa.github-{{ item.repo }}
with_items:
-
dest: "{{ destination }}"
repo: PrimaryRepo
-
dest: "{{ destination }}/app/core"
repo: SubmoduleRepo
#
# The key part is that `recursive` is set to `no`.
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment