From f1eeff4785f87758e1673d170626e45b6b214c23 Mon Sep 17 00:00:00 2001 From: Tyler Hale Date: Fri, 20 Sep 2024 11:37:43 -0600 Subject: [PATCH] Adding auto upgrade service --- roles/snipeit/tasks/main.yml | 17 +++++++++++++++++ .../templates/snipeit-upgrade.service.j2 | 8 ++++++++ .../snipeit/templates/snipeit-upgrade.timer.j2 | 9 +++++++++ 3 files changed, 34 insertions(+) create mode 100644 roles/snipeit/templates/snipeit-upgrade.service.j2 create mode 100644 roles/snipeit/templates/snipeit-upgrade.timer.j2 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