Skip to content

Commit a658154

Browse files
committed
ansible: Add adminapisync service
1 parent 2b47ce1 commit a658154

File tree

10 files changed

+66
-2
lines changed

10 files changed

+66
-2
lines changed

infrastructure/ansible/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
runPlaybook.sh
1+
runPlaybook.sh
2+
secrets.yml

infrastructure/ansible/main.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,14 @@
1717
hosts: job_runner
1818
become: yes
1919
become_method: sudo
20+
vars_files: './secrets.yml'
2021
roles:
21-
- job-runner
22+
- role: fim-queueing-sync
23+
healthCheckEnabled: '{{ fimqueueing.healthCheckEnabled }}'
24+
healthCheckUrl: '{{ fimqueueing.healthCheckUrl }}'
25+
- role: fimadminapi-sync
26+
syncUrl: '{{ fimadminapi.syncUrl }}'
27+
syncToken: '{{ fimadminapi.syncToken }}'
28+
healthCheckEnabled: '{{ fimadminapi.healthCheckEnabled }}'
29+
healthCheckUrl: '{{ fimadminapi.healthCheckUrl }}'
30+

infrastructure/ansible/roles/job-runner/defaults/main.yml renamed to infrastructure/ansible/roles/fim-queueing-sync/defaults/main.yml

File renamed without changes.

infrastructure/ansible/roles/job-runner/tasks/main.yml renamed to infrastructure/ansible/roles/fim-queueing-sync/tasks/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
# Set up a fim-job-runner machine
22

33
- name: Copy .service file to instance
4+
register: service_file
45
template:
56
src: fim-updateCurrentMatch.service.j2
67
dest: /etc/systemd/system/fim-updateCurrentMatch.service
78

89
- name: Copy .timer file to instance
10+
register: timer_file
911
template:
1012
src: fim-updateCurrentMatch.timer.j2
1113
dest: /etc/systemd/system/fim-updateCurrentMatch.timer
1214

15+
- name: daemon-reload
16+
systemd_service:
17+
daemon_reload: yes
18+
when: service_file.changed or timer_file.changed
19+
1320
- name: Ensure timer is started
1421
service:
1522
name: fim-updateCurrentMatch.timer

infrastructure/ansible/roles/job-runner/templates/fim-updateCurrentMatch.service.j2 renamed to infrastructure/ansible/roles/fim-queueing-sync/templates/fim-updateCurrentMatch.service.j2

File renamed without changes.

infrastructure/ansible/roles/job-runner/templates/fim-updateCurrentMatch.timer.j2 renamed to infrastructure/ansible/roles/fim-queueing-sync/templates/fim-updateCurrentMatch.timer.j2

File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
healthCheckEnabled: false
2+
healthCheckUrl: ""
3+
intervalSec: 10
4+
syncUrl: ""
5+
syncToken: ""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Set up a fim-job-runner machine
2+
3+
- name: Copy .service file to instance
4+
register: service_file
5+
template:
6+
src: fim-adminapisync.service.j2
7+
dest: /etc/systemd/system/fim-adminapisync.service
8+
9+
- name: Copy .timer file to instance
10+
register: timer_file
11+
template:
12+
src: fim-adminapisync.timer.j2
13+
dest: /etc/systemd/system/fim-adminapisync.timer
14+
15+
- name: daemon-reload
16+
systemd_service:
17+
daemon_reload: yes
18+
when: service_file.changed or timer_file.changed
19+
20+
- name: Ensure timer is started
21+
service:
22+
name: fim-adminapisync.timer
23+
active: true
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=Run sync current events process in FiMAdminApi
3+
After=network.target
4+
StartLimitIntervalSec=5
5+
StartLimitBurst=2
6+
7+
[Service]
8+
Type=simple
9+
User=root
10+
ExecStart=/usr/bin/env curl -H 'X-fim-sync-secret: {{ syncToken }}' --request PUT {{ syncUrl }}
11+
# Optionally, send a ping to a health check for alerting if the service stops running
12+
{% if not healthCheckEnabled or healthCheckUrl == "" %}# {% endif %}ExecStartPost=/usr/bin/env curl -fsS -m 10 --retry 5 -o /dev/null {{ healthCheckUrl or "<<Health Check URL>>" }}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Timer]
2+
OnUnitInactiveSec={{ intervalSec }}s
3+
OnBootSec={{ intervalSec }}s
4+
Unit=fim-adminapisync.service
5+
6+
[Install]
7+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)