Skip to content

Commit

Permalink
Add support for systemd timers and add /.well-known access on http
Browse files Browse the repository at this point in the history
  • Loading branch information
mjanser committed Nov 1, 2016
1 parent 597f647 commit a9d7564
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ echo "specified vendor: $VENDOR"
curl -s --insecure -H "Host: example.com" https://localhost/login | grep -qi "$VENDOR" && echo "curl request for vendor was successful" || { echo "curl request for vendor failed" && exit 1; }
curl -s --insecure -H "Host: example.com" https://localhost/login | grep -qi "username" && echo "curl request for login was successful" || { echo "curl request for login failed" && exit 1; }
mkdir /var/www/$VENDOR/.well-known
echo foo > /var/www/$VENDOR/.well-known/foo.txt
curl -s --max-redirs 0 -H "Host: example.com" http://localhost/.well-known/foo.txt | grep -q "foo" && echo "curl request for well-known was successful" || { echo "curl request for well-known failed" && exit 1; }
cd /vagrant/
ansible-playbook playbook.yml --limit $(hostname) --inventory-file /tmp/vagrant-ansible/inventory/vagrant_ansible_local_inventory 2>&1 | tee /tmp/ansible.log
Expand Down
12 changes: 5 additions & 7 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@
- include: install.yml
- include: apps.yml

- name: ensure cron job is installed
cron:
name: "{{ owncloud_vendor }} cron"
cron_file: "{{ owncloud_vendor }}"
user: apache
minute: "*/15"
job: "php -f {{ owncloud_destination }}/cron.php"
- include: timer/cron.yml
when: ansible_service_mgr != 'systemd'

- include: timer/systemd.yml
when: ansible_service_mgr == 'systemd'
8 changes: 8 additions & 0 deletions tasks/timer/cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: ensure cron job is installed
cron:
name: "{{ owncloud_vendor }} cron"
cron_file: "{{ owncloud_vendor }}"
user: apache
minute: "*/15"
job: "php -f {{ owncloud_destination }}/cron.php"
16 changes: 16 additions & 0 deletions tasks/timer/systemd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: ensure systemd service is installed
template:
src: systemd.service.j2
dest: "/etc/systemd/system/{{ owncloud_vendor }}.service"

- name: ensure systemd timer is installed
template:
src: systemd.timer.j2
dest: "/etc/systemd/system/{{ owncloud_vendor }}.timer"

- name: ensure systemd timer is enabled
service:
name: "{{ owncloud_vendor }}.timer"
state: started
enabled: yes
10 changes: 9 additions & 1 deletion templates/nginx_vhost.conf.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
server {
listen 80;
server_name {{ owncloud_server_name }};
return 301 https://$server_name$request_uri;
root {{ owncloud_destination }}/;

location ^~ /.well-known/ {
allow all;
}

location / {
return 301 https://$server_name$request_uri;
}
}

server {
Expand Down
6 changes: 6 additions & 0 deletions templates/systemd.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=Perform {{ owncloud_vendor }} tasks

[Service]
Type=oneshot
ExecStart=/usr/bin/php -f {{ owncloud_destination }}/cron.php
5 changes: 5 additions & 0 deletions templates/systemd.timer.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Unit]
Description=Perform {{ owncloud_vendor }} tasks

[Timer]
OnCalendar=*:0/15

0 comments on commit a9d7564

Please sign in to comment.