summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2015-01-05 23:15:53 +0200
committerPaul Sokolovsky <paul.sokolovsky@linaro.org>2015-01-05 23:25:09 +0200
commitbfdee84a5718acfe02222c92a052ddba373a50a0 (patch)
treee305bc76d69e38027bb562490e87b71549f724c5
parentb6706114f96bb1688d5a131a346e7da97daf737e (diff)
git-servers.cronjobs: Refactor per out latest "literal crontab" convention.
For idempotency. Change-Id: Ib0ded93e759c3147483d0cf41347a354814de454
-rw-r--r--per-service/git-servers/roles/cronjobs/tasks/main.yml65
-rw-r--r--per-service/git-servers/roles/cronjobs/templates/gitserver17
2 files changed, 19 insertions, 63 deletions
diff --git a/per-service/git-servers/roles/cronjobs/tasks/main.yml b/per-service/git-servers/roles/cronjobs/tasks/main.yml
index 26403ff9..87feefaf 100644
--- a/per-service/git-servers/roles/cronjobs/tasks/main.yml
+++ b/per-service/git-servers/roles/cronjobs/tasks/main.yml
@@ -1,17 +1,11 @@
---
# All the necessary cron jobs.
-# This is a hack since ansible cron module does not support defining the MAILTO
-# variable. Basically: create the file that will hold the crontab entries with
-# just the MAILTO line, then define the crontab entries as normal. The cron
-# module is smart enough to not remove what is there already.
-# Drawback: the cron file will always be re-created from scratch.
-- name: Setup MAILTO file
- copy: dest=/etc/cron.d/gitserver
+- name: Install crontab
+ template: src=gitserver dest=/etc/cron.d/gitserver
owner=root
group=root
mode=0644
- content="MAILTO={{ mailto_address }}"
tags:
- cron
- install
@@ -19,61 +13,6 @@
- android
- git
-- name: Setup cron for updating server info
- cron: name="Create git update hooks to run git update-server-info"
- job="{{ tools_checkout_dir }}/linaro-git-tools/create-git-hooks.sh"
- minute=*/15
- user={{ git_user }}
- cron_file=gitserver
- when: hosttype == "git-android"
- tags:
- - android
- - cron
- - git
- - install
- - update
-
-- name: Setup fallback git-update-server-info cron
- cron: name="Fallback git update-server-info cronjob"
- job="{{ tools_checkout_dir }}/linaro-git-tools/update-server-info-fallback.sh"
- minute=55
- user={{ git_user }}
- cron_file=gitserver
- when: hosttype == "git-android"
- tags:
- - android
- - cron
- - git
- - install
- - update
-
-- name: Setup cron to clean trash repositories
- cron: name="Clean trashed repositories"
- job="{{ tools_checkout_dir }}/linaro-git-tools/clean-trash-repo.py"
- minute=2
- hour=5
- user={{ git_user }}
- cron_file=gitserver
- when: hosttype == "git-main"
- tags:
- - git
- - cron
- - install
- - update
-
-- name: Setup cront to create clone.bundle files (git-android)
- cron: name="Create clone bundles"
- job="{{ tools_checkout_dir }}/linaro-git-tools/bundles/create-bundle.py --exclude-list {{ tools_checkout_dir }}/git-android-bundle-exclude.txt"
- minute=3
- hour=3
- weekday=0
- user={{ git_user }}
- cron_file=gitserver
- when: hosttype == "git-android"
- tags:
- - cron
- - android
-
- name: Setup exclude file list for Android bundle
copy: src=git-android-bundle-exclude.txt
dest={{ tools_checkout_dir }}/git-android-bundle-exclude.txt
diff --git a/per-service/git-servers/roles/cronjobs/templates/gitserver b/per-service/git-servers/roles/cronjobs/templates/gitserver
new file mode 100644
index 00000000..aa6f6650
--- /dev/null
+++ b/per-service/git-servers/roles/cronjobs/templates/gitserver
@@ -0,0 +1,17 @@
+MAILTO=linaro-infrastructure-errors@lists.linaro.org
+
+{% if hosttype == "git-android" %}
+#Ansible: Create git update hooks to run git update-server-info
+*/15 * * * * {{git_user}} {{tools_checkout_dir}}/linaro-git-tools/create-git-hooks.sh
+
+#Ansible: Fallback git update-server-info cronjob
+55 * * * * {{git_user}} {{tools_checkout_dir}}/linaro-git-tools/update-server-info-fallback.sh
+
+#Ansible: Create clone bundles
+3 3 * * 0 {{git_user}} {{tools_checkout_dir}}/linaro-git-tools/bundles/create-bundle.py --exclude-list {{tools_checkout_dir}}/git-android-bundle-exclude.txt
+{% endif %}
+
+{% if hosttype == "git-main" %}
+#Ansible: Clean trashed repositories
+2 5 * * * {{git_user}} {{tools_checkout_dir}}/linaro-git-tools/clean-trash-repo.py
+{% endif %}