Created
December 1, 2018 17:43
-
-
Save mkubenka/f234bc17b693c513feddcb565265212e to your computer and use it in GitHub Desktop.
Ansible Sparse Checkout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
vars: | |
repo_url: ssh://[email protected]/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 }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?