Skip to content

Instantly share code, notes, and snippets.

@jmjf
Created November 16, 2013 00:24
Show Gist options
  • Save jmjf/7494124 to your computer and use it in GitHub Desktop.
Save jmjf/7494124 to your computer and use it in GitHub Desktop.
An Ansible playbook and sparse-checkout file to test sparse checkout functionality
mu-plugins/
README.md
---
- hosts: all
vars:
project_repo_uri: "https://github.com/jmjf/test-site.git"
project_version: "HEAD"
project_name: "test"
tasks:
# Ensure the target deployment directory path exists
- file: path=/srv/deploy/{{ project_name }}-sparse/baseline/release state=directory
# I was trying to use synchronize to move the template directory, but kept getting
# permission failures. Probably key issues, but I'm not going to deal with that right
# now because I only need a single file--create directory and copy is adequate.
# Ensure the git template directory structure is ready to receive the sparse-checkout file
- file: path=/srv/deploy/{{ project_name }}-sparse/git_template/info state=directory
# For testing, sparse-checkout includes the following two lines (minus comment markers)
# mu-plugins/
# README.md
# Ensure the git template directory includes info/sparse-checkout
- copy:
src=git_template/info/sparse-checkout
dest=/srv/deploy/{{ project_name }}-sparse/git_template/info/sparse-checkout
# Test the sparse checkout function. The test repo contains a directory (mu-plugins) and
# three files. The sparse checkout should get mu-plugins and README.md, but ignore
# test.txt and wp-tests-config.php
# Ensure the repo is checked out (sparse) on the remote
- git: repo={{ project_repo_uri }}
dest=/srv/deploy/{{ project_name }}-sparse/baseline/release
version="{{ project_version }}"
template_path=/srv/deploy/{{ project_name }}-sparse/git_template
config=core.sparsecheckout=true
# A couple of other tests to verify the changes aren't causing any problems.
# Ensure the target deployment directory path exists
- file: path=/srv/deploy/{{ project_name }}-normal/baseline/release state=directory
# Ensure the repo is checked out (normal) on the remote
- git: repo={{ project_repo_uri }}
dest=/srv/deploy/{{ project_name }}-normal/baseline/release
version="{{ project_version }}"
# Ensure the target deployment directory path exists
- file: path=/srv/deploy/{{ project_name }}-bare/baseline/release state=directory
# Ensure the repo is checked out (bare) on the remote
- git: repo={{ project_repo_uri }}
dest=/srv/deploy/{{ project_name }}-bare/baseline/release
version="{{ project_version }}"
bare=yes
@kanapuli
Copy link

kanapuli commented May 8, 2018

git module doesn't support parameters like template_path and config now :(

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