-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from notoraptor/cw-556-update-cluster-status
Set up a service to update clusters status
- Loading branch information
Showing
5 changed files
with
64 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea/ |
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,33 @@ | ||
--- | ||
# We can immediately install requirements from the file {{ clockwork_install_path }}/scripts/requirements.txt | ||
# because it is expected that this task is called after setup_scrape, which copy the source code | ||
- name: Install scripts requirements with pip | ||
ansible.builtin.pip: | ||
requirements: "{{ clockwork_install_path }}/scripts/requirements.txt" | ||
virtualenv: "{{ clockwork_venv_path }}" | ||
|
||
- name: Setup scripts for clusters status update | ||
ansible.builtin.template: | ||
src: templates/clockwork-clusters-status.service.j2 | ||
dest: /etc/systemd/system/clockwork-clusters-status.service | ||
mode: 0600 | ||
|
||
- name: Setup system timer trigger | ||
ansible.builtin.template: | ||
src: templates/clockwork-clusters-status.timer.j2 | ||
dest: /etc/systemd/system/clockwork-clusters-status.timer | ||
mode: 0600 | ||
|
||
- name: Ensure config dir is present | ||
ansible.builtin.file: | ||
path: /etc/clockwork | ||
mode: 0700 | ||
state: directory | ||
owner: "{{ clockwork_user }}" | ||
|
||
- name: Enable timers for clusters status update | ||
ansible.builtin.systemd: | ||
daemon-reload: yes | ||
enabled: true | ||
state: started | ||
name: clockwork-clusters-status.timer |
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,13 @@ | ||
[Unit] | ||
Description=Clockwork clusters status updater | ||
After=network.target | ||
|
||
[Service] | ||
Type=oneshot | ||
User={{ clockwork_user }} | ||
Group={{ clockwork_group }} | ||
Environment=CLOCKWORK_CONFIG=/etc/clockwork/clockwork.toml | ||
Environment=PYTHONPATH={{ clockwork_install_path }} | ||
|
||
WorkingDirectory={{ clockwork_install_path }} | ||
ExecStart={{ clockwork_venv_path }}/bin/python3 {{ clockwork_install_path }}/scripts/update_clusters_status.py |
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,11 @@ | ||
[Unit] | ||
Description=Update clusters status in clockwork. | ||
Requires=clockwork-clusters-status.service | ||
|
||
[Timer] | ||
Unit=clockwork-clusters-status.service | ||
OnCalendar=*-*-* 00:00:00 | ||
AccuracySec=2min | ||
|
||
[Install] | ||
WantedBy=timers.target |