From a15c2dfcc48b00118afad323c8e1463d75bd4ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Trellu?= Date: Mon, 4 Dec 2023 10:03:30 -0500 Subject: [PATCH] [ansible/config] Restart systemd service when configuration changed --- ansible/roles/ovos_installer/tasks/ovos.yml | 1 + ansible/roles/ovos_installer/tasks/virtualenv/systemd.yml | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ansible/roles/ovos_installer/tasks/ovos.yml b/ansible/roles/ovos_installer/tasks/ovos.yml index 7df16e1..a342004 100644 --- a/ansible/roles/ovos_installer/tasks/ovos.yml +++ b/ansible/roles/ovos_installer/tasks/ovos.yml @@ -45,3 +45,4 @@ group: "{{ ovos_installer_user }}" mode: '0600' backup: true + register: _configuration diff --git a/ansible/roles/ovos_installer/tasks/virtualenv/systemd.yml b/ansible/roles/ovos_installer/tasks/virtualenv/systemd.yml index be52a70..0008dac 100644 --- a/ansible/roles/ovos_installer/tasks/virtualenv/systemd.yml +++ b/ansible/roles/ovos_installer/tasks/virtualenv/systemd.yml @@ -28,13 +28,15 @@ ansible.builtin.meta: flush_handlers - name: Enable and start OVOS and/or HiveMind systemd units + vars: + _state: "{{ 'restarted' if _configuration.changed | bool else 'started' }}" become: true become_user: "{{ item.user }}" ansible.builtin.systemd_service: name: "{{ item.unit }}" enabled: true force: true - state: started + state: "{{ _state }}" scope: "{{ item.scope }}" loop: - {"unit": "ovos-messagebus.service", "scope": "user", "user": "{{ ovos_installer_user }}", "state": "{{ true if ovos_installer_profile != 'satellite' else false }}"}