2023-01-23 20:23:32 +01:00
- name : "Stop services"
ansible.builtin.service :
name : "{{ item.value['doc'] }}"
state : stopped
2023-03-03 08:34:55 +01:00
when : item.value['manage'] and item.value['activate'] and item.value['doc'].endswith('.service') and not item.value['doc'].endswith('@.service') and item.value['engine'] and item.value['doc'] in services
2023-01-23 20:23:32 +01:00
loop : "{{ vars[inventory_hostname]['services'] | dict2items }}"
loop_control :
label : "{{ item.value['doc'] }}"
- name : "Remove old config files"
file :
path : /usr/local/lib/
state : "{{ item }}"
mode : "0700"
with_items :
- absent
- directory
- name : "Copy config files"
unarchive :
remote_src : true
src : "/tmp/new_configurations/host.tar"
dest : /usr/local/lib/
owner : root
group : root
- name : "Execute systemd-tmpfiles"
command : /usr/bin/systemd-tmpfiles --create --clean --remove -E --exclude-prefix=/tmp
- name : "Remove tmpfiles files directory"
local_action :
module : file
path : /usr/local/lib/tmpfiles.d/
state : absent
- name : "Reload systemd services configuration"
ansible.builtin.systemd :
daemon_reload : yes
- name : "Enable services"
when : item.value['manage'] and item.value['activate'] and '@.service' not in item.value['doc']
ansible.builtin.service :
name : "{{ item.value['doc'] }}"
enabled : yes
loop : "{{ vars[inventory_hostname]['services'] | dict2items }}"
loop_control :
label : "{{ item.value['doc'] }}"
- name : "Disable services"
when : item.value['manage'] and not item.value['activate'] and not item.value['undisable'] and '@.service' not in item.value['doc']
ansible.builtin.service :
name : "{{ item.value['doc'] }}"
enabled : no
loop : "{{ vars[inventory_hostname]['services'] | dict2items }}"
loop_control :
label : "{{ item.value['doc'] }}"
- name : "Start services"
2023-03-03 08:34:55 +01:00
when : item.value['manage'] and item.value['activate'] and item.value['doc'].endswith('.service') and not item.value['doc'].endswith('@.service') and item.value['engine']
2023-07-31 15:27:56 +02:00
ignore_errors : true
2023-01-23 20:23:32 +01:00
ansible.builtin.service :
name : "{{ item.value['doc'] }}"
state : started
loop : "{{ vars[inventory_hostname]['services'] | dict2items }}"
loop_control :
label : "{{ item.value['doc'] }}"
- name : "Restart services"
2023-03-03 08:34:55 +01:00
when : item.value['manage'] and item.value['activate'] and item.value['doc'].endswith('.service') and not item.value['doc'].endswith('@.service') and not item.value['engine']
2023-01-23 20:23:32 +01:00
ansible.builtin.service :
name : "{{ item.value['doc'] }}"
state : restarted
loop : "{{ vars[inventory_hostname]['services'] | dict2items }}"
loop_control :
label : "{{ item.value['doc'] }}"