Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit fff2d35

Browse files
committed
setup cron error email
1 parent 6f824bc commit fff2d35

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ This will deploy the build of https://git.example.org/website.git by
2323
using rsync as rsync_user on www.example.org, copying in /var/www/html.
2424

2525
The script will not sync if build failed, and will not send email (that's on the
26-
TODO list, see end of the file)
26+
TODO list, see end of the file). Nevertheless, failures caught by Cron can be
27+
sent to an email address if specified by `cron_error_email`; if you setup
28+
multiple builders using the same UNIX user, then beware only the latest email
29+
defined will be taken into account.
2730

2831
# Handling multiple repositories
2932

tasks/main.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@
8181
job: "/usr/local/bin/build_deploy.py /srv/builder/{{ name }}.yml"
8282
user: "{{ builder_username }}"
8383

84+
- name: Setup cron email
85+
cronvar:
86+
user: "{{ builder_username }}"
87+
name: MAILTO
88+
value: "{{ cron_error_email }}"
89+
when: cron_error_email is defined
90+
8491
# TODO add ip restriction
8592
- name: Copy the key on the other side
8693
authorized_key:
@@ -95,7 +102,7 @@
95102
set_fact:
96103
remote_user: "{{ rsync_user }}"
97104
remote_host: "{{ rsync_server }}"
98-
when: rsync_url
105+
when: rsync_url != ''
99106

100107
- name: Compute SSH config for openshift sync
101108
block:
@@ -111,7 +118,7 @@
111118
# seen pattern: <user>@<host> or ssh://<user>@<host>/<path>
112119
remote_user: "{{ site.openshift | regex_replace('^.*?([^/]+)@.*$', '\\1') }}"
113120
remote_host: "{{ site.openshift | regex_replace('^.*@([^/]+).*$', '\\1') }}"
114-
when: not rsync_url
121+
when: rsync_url == ''
115122

116123
- name: Create SSH config
117124
blockinfile:

0 commit comments

Comments
 (0)