diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-08-07 11:06:33 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-08-07 19:38:45 +0200 |
commit | 7ccc51aad5ea52b26b27faf6d00413c94bf02f46 (patch) | |
tree | 4dd0bb7670b4c90e5c97350312dede37357a19cd /roles/systemd_edit/tasks/main.yml | |
parent | linux_status: factor out PPA set up to a separate role (diff) | |
download | infra-ansible-7ccc51aad5ea52b26b27faf6d00413c94bf02f46.tar.gz infra-ansible-7ccc51aad5ea52b26b27faf6d00413c94bf02f46.zip |
factor out systemd service editing
Diffstat (limited to 'roles/systemd_edit/tasks/main.yml')
-rw-r--r-- | roles/systemd_edit/tasks/main.yml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/roles/systemd_edit/tasks/main.yml b/roles/systemd_edit/tasks/main.yml new file mode 100644 index 0000000..06a0a8a --- /dev/null +++ b/roles/systemd_edit/tasks/main.yml @@ -0,0 +1,23 @@ +- name: Edit systemd service definition + become: true + 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: '{{ service_section }}' + option: '{{ service_option }}' + values: '{{ service_values }}' + 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 |