diff --git a/roles/snipeit/tasks/main.yml b/roles/snipeit/tasks/main.yml index 37106d5..cdab9f3 100644 --- a/roles/snipeit/tasks/main.yml +++ b/roles/snipeit/tasks/main.yml @@ -289,3 +289,20 @@ name: nginx state: started enabled: yes + +- name: Deploy snipeit upgrade service + template: + src: snipeit-upgrade.service.j2 + dest: /etc/systemd/system/snipeit-upgrade.service + notify: Daemon Reload + +- name: Deploy snipeit upgrade timer + template: + src: snipeit-upgrade.timer.j2 + dest: /etc/systemd/system/snipeit-upgrade.timer + notify: Daemon Reload + +- name: Enable systemd timer for snipeit upgrade + service: + name: snipeit-upgrade.timer + enabled: yes diff --git a/roles/snipeit/templates/snipeit-upgrade.service.j2 b/roles/snipeit/templates/snipeit-upgrade.service.j2 new file mode 100644 index 0000000..02fc854 --- /dev/null +++ b/roles/snipeit/templates/snipeit-upgrade.service.j2 @@ -0,0 +1,8 @@ +[Unit] +Description=SnipeIt Auto Upgrade Service +[Service] +Type=oneshot +WorkingDirectory=/opt/snipeit +User={{ ansible_user }} +Group={{ ansible_user }} +ExecStart=/bin/bash -c 'git pull && php composer.phar update --no-interaction && php upgrade.php --no-interactive' diff --git a/roles/snipeit/templates/snipeit-upgrade.timer.j2 b/roles/snipeit/templates/snipeit-upgrade.timer.j2 new file mode 100644 index 0000000..dbc46d4 --- /dev/null +++ b/roles/snipeit/templates/snipeit-upgrade.timer.j2 @@ -0,0 +1,9 @@ +[Unit] +Description=SnipeIt Renewal Timer +[Timer] +WakeSystem=false +OnCalendar=Sat *-*-* 05:00 +RandomizedDelaySec=600 + +[Install] +WantedBy=timers.target