Last active
October 13, 2018 20:51
-
-
Save amercader/6193383 to your computer and use it in GitHub Desktop.
Ansible playbook for updating a source-installed CKAN site
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
# Ansible playbook for updating a source-installed CKAN site | |
# | |
# Generally used to update beta.ckan.org and master.ckan.org on the staging | |
# server (currently s084), but it can be easily adapted to your own deployment | |
# needs. | |
# | |
# Add the staging server IP tp your /etc/ansible/hosts file (check if the IP | |
# is up to date): | |
# | |
# [staging] | |
# 50.56.81.219 | |
# | |
# Install ansible and run this playbook: | |
# | |
# ansible-playbook update_source.yml -u amercader -s | |
# | |
# If no variables are passed, the site "master" is updated with the latest | |
# "master" branch. To update another CKAN site and/or version pass the | |
# following variables: | |
# | |
# ansible-playbook update_source.yml -u amercader -s --extra-vars="site=beta version=release-v2.1" | |
# | |
--- | |
- hosts: staging | |
vars: | |
site: "master" | |
version: "master" | |
tasks: | |
- name: Discard local changes | |
action: command chdir=/usr/lib/ckan/{{ site }}/src/ckan/ git clean -dfx | |
- name: Checkout version | |
action: git repo=https://github.com/okfn/ckan dest=/usr/lib/ckan/{{ site }}/src/ckan version={{ version }} force=yes | |
- name: Pull code | |
action: command chdir=/usr/lib/ckan/{{ site }}/src/ckan/ git pull | |
register: update | |
- name: Run setup.py develop for ckan | |
action: command chdir=/usr/lib/ckan/{{ site }}/src/ckan/ ../../bin/python setup.py develop | |
when: update.changed | |
- name: Upgrade db | |
action: command /usr/lib/ckan/{{ site }}/bin/paster --plugin=ckan db upgrade -c /etc/ckan/{{ site }}/production.ini | |
when: update.changed | |
- name: Rebuild search index | |
action: command /usr/lib/ckan/{{ site }}/bin/paster --plugin=ckan search-index rebuild -c /etc/ckan/{{ site }}/production.ini | |
when: update.changed | |
- name: Rebuild front end | |
action: command /usr/lib/ckan/{{ site }}/bin/paster --plugin=ckan front-end-build -c /etc/ckan/{{ site }}/production.ini | |
when: update.changed | |
- name: Restart Apache | |
action: service name=apache2 state=restarted | |
when: update.changed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment