aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-08-06 15:27:30 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-08-06 15:27:30 +0200
commit3034c3c8e399b7efda2e379fe9b9a1ee2f0a5923 (patch)
treecd411200a5b3d44469df4d725de1baa5180189a1
parentv0.0.2 (diff)
downloadinfra-ansible-3034c3c8e399b7efda2e379fe9b9a1ee2f0a5923.tar.gz
infra-ansible-3034c3c8e399b7efda2e379fe9b9a1ee2f0a5923.zip
linux_status: support disabling power mgmt
-rw-r--r--roles/linux_status/defaults/main.yml2
-rw-r--r--roles/linux_status/tasks/main.yml27
2 files changed, 29 insertions, 0 deletions
diff --git a/roles/linux_status/defaults/main.yml b/roles/linux_status/defaults/main.yml
index da596ae..0c526dc 100644
--- a/roles/linux_status/defaults/main.yml
+++ b/roles/linux_status/defaults/main.yml
@@ -1,2 +1,4 @@
+linux_status_disable_power_management: false
+
keys_dir: /etc/apt/keyrings
gpg_key_id: ecb69cbafc6d7cd8bd67ec35b1089b3051c9384d
diff --git a/roles/linux_status/tasks/main.yml b/roles/linux_status/tasks/main.yml
index 766f009..1fa381f 100644
--- a/roles/linux_status/tasks/main.yml
+++ b/roles/linux_status/tasks/main.yml
@@ -23,3 +23,30 @@
ansible.builtin.apt:
install_recommends: false
name: linux-status
+
+- name: Disable power management
+ when: linux_status_disable_power_management
+ become: true
+ vars:
+ service_name: linux-status
+ block:
+ - name: 'Create override directory: {{ service_name }}'
+ ansible.builtin.file:
+ path: '/etc/systemd/system/{{ service_name }}.service.d'
+ state: directory
+
+ - name: 'Set up override: {{ service_name }}'
+ community.general.ini_file:
+ dest: '/etc/systemd/system/{{ service_name }}.service.d/override.conf'
+ section: Unit
+ option: ExecStart
+ values: ['', '/usr/bin/python3 -B server.py --disable-power']
+ no_extra_spaces: true
+ register: overridden
+
+ - name: 'Restart service: {{ service_name }}'
+ ansible.builtin.systemd_service:
+ daemon_reload: true
+ name: '{{ service_name }}'
+ state: restarted
+ when: overridden.changed