Skip to content

Instantly share code, notes, and snippets.

@mkubenka
Created December 1, 2018 17:43
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mkubenka/f234bc17b693c513feddcb565265212e to your computer and use it in GitHub Desktop.
Save mkubenka/f234bc17b693c513feddcb565265212e to your computer and use it in GitHub Desktop.
Ansible Sparse Checkout
---
- hosts: all
vars:
repo_url: ssh://git@github.com/user/repo.git
base_dir: /var/www
sparse_checkout:
- folder1
tasks:
- name: prepare sparse git repository
shell: |
git init
git config core.sparsecheckout true
git remote add origin {{ repo_url }}
args:
chdir: "{{ base_dir }}"
creates: "{{ base_dir }}/.git"
- name: configure sparse-checkout
copy:
dest: "{{ base_dir }}/.git/info/sparse-checkout"
content: '{{ sparse_checkout | join("\n") }}'
- name: clone code
shell: git pull origin master
args:
chdir: "{{ base_dir }}"
creates: "{{ base_dir }}/{{ sparse_checkout | first }}"
@akashbhaskar2907
Copy link

It asked for username and password at "clone code" step. How to configure it so that I dont have to manually enter username and password?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment