aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--roles/linux_status/handlers/main.yml7
-rw-r--r--roles/linux_status/tasks/main.yml34
-rw-r--r--roles/linux_status/templates/disable_power_management.conf.j25
3 files changed, 37 insertions, 9 deletions
diff --git a/roles/linux_status/handlers/main.yml b/roles/linux_status/handlers/main.yml
new file mode 100644
index 0000000..0ea529f
--- /dev/null
+++ b/roles/linux_status/handlers/main.yml
@@ -0,0 +1,7 @@
+- name: Restart linux-status
+ become: true
+ ansible.builtin.systemd_service:
+ daemon_reload: true
+ name: linux-status
+ state: restarted
+ listen: linux_status_restart
diff --git a/roles/linux_status/tasks/main.yml b/roles/linux_status/tasks/main.yml
index 70fd41b..17a00d3 100644
--- a/roles/linux_status/tasks/main.yml
+++ b/roles/linux_status/tasks/main.yml
@@ -6,18 +6,34 @@
ppa_name: linux-status
ppa_key: ecb69cbafc6d7cd8bd67ec35b1089b3051c9384d
+- name: Disable power management
+ when: linux_status_disable_power_management
+ become: true
+ block:
+ - name: Create override directory
+ ansible.builtin.file:
+ path: /etc/systemd/system/linux-status.service.d
+ state: directory
+ owner: root
+ group: root
+ mode: '755'
+
+ - name: Create override file
+ ansible.builtin.template:
+ src: disable_power_management.conf.j2
+ dest: /etc/systemd/system/linux-status.service.d/99-disable_power_management.conf
+ owner: root
+ group: root
+ mode: '644'
+ notify: linux_status_restart
+
- name: Install linux-status
become: true
ansible.builtin.apt:
install_recommends: false
name: linux-status
+ policy_rc_d: 101
+ notify: linux_status_restart
-- name: Disable power management
- when: linux_status_disable_power_management
- ansible.builtin.include_role:
- name: systemd_edit
- vars:
- service_name: linux-status
- service_section: Service
- service_option: ExecStart
- service_values: ['', '/usr/bin/python3 -B server.py --disable-power']
+- name: Restart systemd service if necessary
+ ansible.builtin.meta: flush_handlers
diff --git a/roles/linux_status/templates/disable_power_management.conf.j2 b/roles/linux_status/templates/disable_power_management.conf.j2
new file mode 100644
index 0000000..a16c83d
--- /dev/null
+++ b/roles/linux_status/templates/disable_power_management.conf.j2
@@ -0,0 +1,5 @@
+{{ ansible_managed | comment }}
+
+[Service]
+ExecStart=
+ExecStart=/usr/bin/python3 -B server.py --disable-power