diff --git a/ansible/roles/system-init-9140/tasks/main.yml b/ansible/roles/system-init-9140/tasks/main.yml index 7c70b45f..ebdcc27b 100644 --- a/ansible/roles/system-init-9140/tasks/main.yml +++ b/ansible/roles/system-init-9140/tasks/main.yml @@ -233,4 +233,27 @@ src: "{{ role_path }}/templates/90-9000-dracut.rules.j2" dest: /usr/lib/dracut/dracut.conf.d/90-9000-dracut.conf mode: 0644 - tags: template \ No newline at end of file + tags: template + +# poweroff guard +- name: "templates poweroff-guard.service.j2" + template: + src: "{{role_path}}/templates/poweroff-guard.service.j2" + dest: /usr/lib/systemd/system/poweroff-guard.service + tags: template + +- name: "templates start-poweroff-guard.service.j2" + template: + src: "{{role_path}}/templates/start-poweroff-guard.service.j2" + dest: /usr/lib/systemd/system/start-poweroff-guard.service + tags: template + +- name: 'poweroff-guard service start' + systemd: + name: poweroff-guard + enabled: yes + +- name: 'start-poweroff-guard service start' + systemd: + name: start-poweroff-guard + enabled: yes \ No newline at end of file diff --git a/ansible/roles/system-init-9140/templates/poweroff-guard.service.j2 b/ansible/roles/system-init-9140/templates/poweroff-guard.service.j2 new file mode 100644 index 00000000..58b04214 --- /dev/null +++ b/ansible/roles/system-init-9140/templates/poweroff-guard.service.j2 @@ -0,0 +1,6 @@ +[Unit] +Description=Poweroff Guard +[Service] +ExecStart=/bin/true +[Install] +RequiredBy=poweroff.target \ No newline at end of file diff --git a/ansible/roles/system-init-9140/templates/start-poweroff-guard.service.j2 b/ansible/roles/system-init-9140/templates/start-poweroff-guard.service.j2 new file mode 100644 index 00000000..994b4385 --- /dev/null +++ b/ansible/roles/system-init-9140/templates/start-poweroff-guard.service.j2 @@ -0,0 +1,6 @@ +[Unit] +Description=Start Poweroff Guard +[Service] +ExecStart=/bin/systemctl enable poweroff-guard +[Install] +WantedBy=multi-user.target \ No newline at end of file