use a single script/service/timer

This commit is contained in:
Pig Monkey 2016-11-24 13:39:42 -08:00
parent fc8496e145
commit 3e9e43b9eb
6 changed files with 25 additions and 23 deletions

View file

@ -1,4 +1,3 @@
---
- name: restart cryptshot
service: name=cryptshot-{{ item.name }}.timer state=restarted
with_items: "{{ cryptshot }}"
service: name=cryptshot.timer state=restarted

View file

@ -4,20 +4,3 @@
- name: Push {{ target.name }} cryptshot config
template: src=cryptshot.conf.j2 dest=/usr/local/etc/cryptshot/{{ target.name }}.conf
- name: Push {{ target.name }} cryptshot script
template: src=cryptshot.sh.j2 dest=/usr/local/bin/cryptshot-{{ target.name }} mode=0755
- name: Push {{ target.name }} cryptshot service file
template: src=cryptshot.service.j2 dest=/etc/systemd/system/cryptshot-{{ target.name }}.service
notify:
- reload systemd config
- name: Push {{ target.name }} cryptshot timer file
template: src=cryptshot.timer.j2 dest=/etc/systemd/system/cryptshot-{{ target.name }}.timer
notify:
- reload systemd config
- restart cryptshot
- name: Enable and start cryptshot timer
service: name=cryptshot-{{ target.name }}.timer enabled=yes state=started

View file

@ -21,3 +21,20 @@
with_items: "{{ cryptshot }}"
loop_control:
loop_var: target
- name: Push cryptshot execution script
template: src=cryptshot.sh.j2 dest=/usr/local/bin/cryptshot-execute mode=0755
- name: Push cryptshot service file
template: src=cryptshot.service.j2 dest=/etc/systemd/system/cryptshot.service
notify:
- reload systemd config
- name: Push cryptshot timer file
template: src=cryptshot.timer.j2 dest=/etc/systemd/system/cryptshot.timer
notify:
- reload systemd config
- restart cryptshot
- name: Enable and start cryptshot timer
service: name=cryptshot.timer enabled=yes state=started

View file

@ -1,7 +1,7 @@
Description=Cryptshot Backup Service: {{ target.name|capitalize }}
Description=Cryptshot Backup Service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/cryptshot-{{ target.name }}
ExecStart=/usr/local/bin/cryptshot-execute
StandardOutput=syslog
StandardError=syslog

View file

@ -1,5 +1,8 @@
#!/bin/sh
{% for target in cryptshot %}
# {{ target.name }}
{% for retain in target.retain|sort(attribute='interval') %}
/usr/local/bin/backitup -l /usr/local/etc/cryptshot/lastrun/{{ target.name }}.{{ retain.level }} -b "/usr/local/bin/cryptshot -c /usr/local/etc/cryptshot/{{ target.name }}.conf -i {{ retain.level }}" -p {{ retain.level|upper }}
{% endfor %}
{% endfor %}

View file

@ -1,8 +1,8 @@
[Unit]
Description=Cryptshot Timer: {{ target.name|capitalize }}
Description=Cryptshot Backup Timer
[Timer]
Unit=cryptshot-{{ target.name }}.service
Unit=cryptshot.service
OnCalendar=hourly
Persistent=True