From ff38d04b555947a9a1ddae59857894e758c62bb6 Mon Sep 17 00:00:00 2001 From: Chris Croome <chris@webarchitects.co.uk> Date: Fri, 7 Jul 2017 12:21:14 +0100 Subject: [PATCH] Update code crontab added --- roles/live2dev/tasks/main.yml | 18 ++++++++++++++++++ roles/live2dev/templates/cron.j2 | 10 ++++++++++ 2 files changed, 28 insertions(+) create mode 100644 roles/live2dev/templates/cron.j2 diff --git a/roles/live2dev/tasks/main.yml b/roles/live2dev/tasks/main.yml index b556c63..dcd95db 100644 --- a/roles/live2dev/tasks/main.yml +++ b/roles/live2dev/tasks/main.yml @@ -26,6 +26,24 @@ group: "{{ item }}" with_items: "{{ users }}" +- name: Cron script config in place + template: + src: templates/cron.j2 + dest: "/home/{{ item }}/bin/cron" + mode: 0755 + owner: "{{ item }}" + group: "{{ item }}" + with_items: "{{ users }}" + +- name: Crontab in place + cron: + name: "Update code" + minute: "*" + hour: "*" + user: "{{ item }}" + job: "/home/{{ item }}/bin/cron" + with_items: "{{ users }}" + - name: favicon.ico file in place copy: src: files/favicon.ico diff --git a/roles/live2dev/templates/cron.j2 b/roles/live2dev/templates/cron.j2 new file mode 100644 index 0000000..cab448e --- /dev/null +++ b/roles/live2dev/templates/cron.j2 @@ -0,0 +1,10 @@ +#!/bin/bash + +cd ~/sites + +GIT_PULL=$(git pull | grep -v "up-to-date") + +if [[ ${GIT_PULL} != "" ]]; then + ~/bin/update +fi + -- GitLab