Skip to content

Instantly share code, notes, and snippets.

@scuerda
Last active November 5, 2015 21:28
Show Gist options
  • Save scuerda/610f3120bd997ccc8d9b to your computer and use it in GitHub Desktop.
Save scuerda/610f3120bd997ccc8d9b to your computer and use it in GitHub Desktop.
Ansible play for dealing with private git repos
---
- name: Confirms directory for repo is present
file: path={{ project_path }} state=directory owner={{ ckan_user }}
- name: Creates directory
file: path=/home/{{ ckan_user }}/.ssh state=directory
### The key used here needs to not have a password associated with it ###
- name: Create the Github SSH public key file
copy: src="~/.ssh/ansibleid.pub"
dest="/home/{{ ckan_user }}/.ssh/id_rsa.pub"
mode=0644
owner={{ ckan_user }}
when: setup_git_repo
- name: Create the Github SSH private key file
copy: src="~/.ssh/ansibleid"
dest="/home/{{ ckan_user }}/.ssh/id_rsa"
mode=0600
owner={{ ckan_user }}
when: setup_git_repo
- name: Setup the Git repo
sudo: no
git: repo={{ git_repo }}
version={{ git_branch }}
dest={{ project_path }}
accept_hostkey=True
force=yes
key_file="/home/{{ ckan_user}}/.ssh/id_rsa"
when: setup_git_repo is defined and setup_git_repo
tags: git
- name: Delete all .pyc files
command: find . -name '*.pyc' -delete
args:
chdir: "{{ project_path }}"
tags: git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment