Commit d45d9367 authored by nimrod's avatar nimrod
Browse files

Check if a restart is needed.

Service and timer to run needrestart and notify if a restart is needed.
parent 897a4b2f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
# vim: filetype=systemd
[Unit]
Description=Check if a restart is needed
ConditionACPower=true
After=network-online.target

[Service]
Type=oneshot
ExecStart=/bin/sh -c 'needrestart -p || curl "https://notify.shore.co.il/send?message=$(hostname --short)%%20needs%%20to%%20be%%20restarted."'
+9 −0
Original line number Diff line number Diff line
# vim: filetype=systemd
[Unit]
Description=Check if a restart is needed

[Timer]
OnCalendar=daily

[Install]
WantedBy=multi-user.target
+20 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
      - intel-microcode
      - libpam-mount-bin
      - make
      - needrestart
      - python3-cryptography
      - rsync
      - tmux
@@ -111,6 +112,8 @@
    dest: /etc/systemd/system
    mode: 0o0644
    src: '{{ item }}'
  notify:
    - Systemd daemon reload

- name: Enable the update timer
  ansible.builtin.systemd:
@@ -118,6 +121,23 @@
    name: update.timer
    state: started

- name: Copy the need restart service and timer
  loop:
    - needrestart.service
    - needrestart.timer
  ansible.builtin.copy:
    dest: /etc/systemd/system
    mode: 0o0644
    src: '{{ item }}'
  notify:
    - Systemd daemon reload

- name: Enable the need restart timer
  ansible.builtin.systemd:
    enabled: true
    name: needrestart.timer
    state: started

- name: Include Docker tasks
  ansible.builtin.include_tasks:
    file: docker.yml