Last active
November 28, 2016 15:59
-
-
Save erral/daf5799de32e52a5eb54807b4842a4bd to your computer and use it in GitHub Desktop.
Ansible playbook to install Plone patch tomorrow. It makes several assumptions, such as: 1. Your buildout is named plone.buildout and it is hosted on 'plone' user's $HOME/plone.buildout 2. The tar file PloneHotfix20161129.tgz exists on the same path as this playbook and can be untarred to a ${buildout:directory}/products folder as an 'old-style-…
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
--- | |
# README: | |
# This playbook uploads a tarball to the $HOME/plone.buildout/products directory | |
# of each server and restarts the Supervisor process | |
# | |
# This playbook can be used to install Plone Hotfixes. | |
# | |
# The playbook searches for folders with names starting with 'plone.buildout' | |
# at the home folder. It uploads the tarfile stated in the vars that must | |
# be prepared beforehand, and then reloads the supervisor | |
# | |
# This playbook asumes that your buildout has a top-most 'products' folder | |
# that will be included in your zope instance's configuration | |
# | |
- hosts: all | |
become: true | |
become_user: plone | |
remote_user: plone | |
vars: | |
patch_tar_file: PloneHotfix20161129.tgz | |
patch_directory_name: PloneHotfix20161129 | |
tasks: | |
- name: Find if this is a Plone site | |
find: paths="{{ansible_env.HOME}}" file_type="directory" patterns="^plone\.buildout(\..*)?$" use_regex=True | |
register: filepaths | |
- name: Check if products folder exists | |
stat: path="{{ item.path }}/products" | |
register: products_folder | |
with_items: "{{ filepaths.files }}" | |
- name: Remove old version of the patch | |
file: path="{{item.stat.path}}/{{patch_directory_name}}" state="absent" | |
when: item.stat.exists | |
with_items: "{{ products_folder.results }}" | |
- name: Copy and untar | |
unarchive: src={{patch_tar_file}} dest={{item.stat.path}} | |
when: item.stat.exists | |
with_items: "{{ products_folder.results }}" | |
- name: Restart the services | |
command: "{{item.item.path}}/bin/supervisorctl reload" | |
when: item.stat.exists | |
with_items: "{{ products_folder.results }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ansible playbook to install Plone patches. It makes several assumptions, such as:
Your buildout is named plone.buildout and it is hosted on 'plone' user's $HOME/plone.buildout
The tar file PloneHotfix20161129.tgz exists on the same path as this playbook and can be untarred to a ${buildout:directory}/products folder as an 'old-style-product'
supervisor is used to manage the services