-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Timers are easier to debug and give more control about the scheduling.
- Loading branch information
Showing
11 changed files
with
108 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
timer_name: | ||
timer_descr: | ||
timer_exec: /bin/false | ||
timer_user: root | ||
timer_interval: | ||
timer_calendar: | ||
timer_randomized_delay: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
- name: Fail when timer_name is empty | ||
fail: msg="timer_name is empty" | ||
when: not timer_name | ||
|
||
- name: Upload service and timer | ||
template: | ||
src: "job.{{ item }}" | ||
dest: /lib/systemd/system/{{ timer_name }}.{{ item }} | ||
with_items: | ||
- service | ||
- timer | ||
register: template_result | ||
|
||
- name: Reload systemd | ||
command: systemctl daemon-reload | ||
when: template_result.changed | ||
|
||
- name: Enable and start timer | ||
service: {{ timer_name }}.timer enabled=yes state=started |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# {{ ansible_managed }} | ||
|
||
[Unit] | ||
Description={{ timer_descr | default(timer_name + " Timer") }} | ||
|
||
[Service] | ||
Type=oneshot | ||
User={{ timer_user }} | ||
|
||
ExecStart={{ timer_exec }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# {{ ansible_managed }} | ||
|
||
[Unit] | ||
Description={{ timer_name }} Service | ||
|
||
[Timer] | ||
Unit={{ timer_name }}.service | ||
{% if timer_calendar is defined %} | ||
OnCalendar={{ timer_calendar }} | ||
{% else %} | ||
OnBootSec={{ timer_startup_delay | default("60") }} | ||
OnUnitInactiveSec={{ timer_interval }} | ||
{% endif %} | ||
|
||
{% if timer_randomized_delay is defined %} | ||
RandomizedDelaySec={{ timer_randomized_delay }} | ||
{% endif %} | ||
|
||
[Install] | ||
WantedBy=basic.target |