mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Another big round of refactoring and cleaning...
This commit is contained in:
22
roles/sys-timer/tasks/main.yml
Normal file
22
roles/sys-timer/tasks/main.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
- name: "reset (if enabled)"
|
||||
include_tasks: reset.yml
|
||||
when: mode_reset | bool and run_once_gen_timer is not defined
|
||||
|
||||
- name: create {{service_name}}.cymais.timer
|
||||
template:
|
||||
src: dummy.timer.j2
|
||||
dest: "/etc/systemd/system/{{service_name}}.cymais.timer"
|
||||
register: dummy_timer
|
||||
|
||||
- name: "restart timer"
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: "{{service_name}}.cymais.timer"
|
||||
state: restarted
|
||||
enabled: yes
|
||||
when: dummy_timer.changed or activate_all_timers | bool
|
||||
|
||||
- name: run {{ role_name }} once
|
||||
set_fact:
|
||||
run_once_gen_timer: true
|
||||
when: run_once_gen_timer is not defined
|
26
roles/sys-timer/tasks/reset.yml
Normal file
26
roles/sys-timer/tasks/reset.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
- name: Find all cymais.timer units
|
||||
find:
|
||||
paths: /etc/systemd/system
|
||||
patterns: '*.cymais.timer'
|
||||
register: cymais_timers
|
||||
|
||||
- name: Disable and stop each cymais timer
|
||||
systemd:
|
||||
name: "{{ item.path | basename }}"
|
||||
enabled: no
|
||||
state: stopped
|
||||
loop: "{{ cymais_timers.files }}"
|
||||
loop_control:
|
||||
label: "{{ item.path | basename }}"
|
||||
|
||||
- name: Remove all cymais.timer files
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
loop: "{{ cymais_timers.files }}"
|
||||
loop_control:
|
||||
label: "{{ item.path | basename }}"
|
||||
|
||||
- name: Reload systemd daemon
|
||||
command: systemctl daemon-reload
|
||||
become: true
|
Reference in New Issue
Block a user