Konfiguriere Minion Job Queue

This commit is contained in:
phil 2022-12-14 17:17:59 +01:00
parent 400b61b934
commit 2c02f0d5cb
5 changed files with 59 additions and 6 deletions

View file

@ -13,3 +13,8 @@ lstu:
path: /var/www/lstu path: /var/www/lstu
contact: 'admin[at]systemausfall.org' contact: 'admin[at]systemausfall.org'
minion_service: lstu-minion
minion_workers: 1
minion_db: lstu-minion
minion_db_user: lstu-minion
minion_db_password: "{{ lookup('password', '/tmp/lstu_minion_db_pw length=42 chars=ascii_letters,digits') }}"

View file

@ -1,18 +1,28 @@
--- ---
- name: "database | Erstelle Datenbank" - name: "database | Erstelle Datenbank"
ansible.builtin.mysql_db: ansible.builtin.mysql_db:
name: "{{ lstu_db }}" name: "{{ item }}"
state: present state: present
login_unix_socket: "{{ mysql_socket }}" login_unix_socket: "{{ mysql_socket }}"
login_user: root login_user: root
loop:
- "{{ lstu_db }}"
- "{{ minion_db }}"
- name: "database | Erstelle Benuzter" - name: "database | Erstelle Benuzter"
ansible.builtin.mysql_user: ansible.builtin.mysql_user:
name: "{{ lstu_db_user }}" name: "{{ item.user }}"
password: "{{ lstu_db_password }}" password: "{{ item.password }}"
host: "{{ inventory_hostname }}" host: "{{ inventory_hostname }}"
priv: "{{ lstu_db }}.*:ALL" priv: "{{ item.database }}.*:ALL"
update_password: on_create update_password: on_create
state: present state: present
login_unix_socket: "{{ mysql_socket }}" login_unix_socket: "{{ mysql_socket }}"
login_user: root login_user: root
loop:
- user: "{{ lstu_db_user }}"
password: "{{ lstu_db_password }}"
database: "{{ lstu_db }}"
- user: "{{ minion_db_user }}"
password: "{{ minion_db_password }}"
database: "{{ minion_db }}"

View file

@ -44,7 +44,6 @@
group: "{{ lstu_user }}" group: "{{ lstu_user }}"
recurse: true recurse: true
- name: "lstu | edit config" - name: "lstu | edit config"
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path="{{ lstu.path }}/lstu.conf" path="{{ lstu.path }}/lstu.conf"
@ -87,6 +86,20 @@
mode: 0644 mode: 0644
notify: restart lstu notify: restart lstu
- name: "lstu | Kopiere systemd-Unit für minion-Worker"
ansible.builtin.template:
src: lstu-minion.service
dest: "/etc/systemd/system/{{ minion_service }}@.service"
mode: 0644
- name: lstu | Starte minion-Worker
ansible.builtin.systemd:
name: "{{ minion_service }}@{{ item }}"
enabled: true
state: restarted
daemon_reload: true
loop: "{{ range(0, minion_workers ) | list }}"
- name: "lstu | Prüfe Theme-Verzeichnis" - name: "lstu | Prüfe Theme-Verzeichnis"
ansible.builtin.stat: ansible.builtin.stat:
path: "{{ lstu.path }}/themes/{{ lstu_theme }}" path: "{{ lstu.path }}/themes/{{ lstu_theme }}"

View file

@ -0,0 +1,21 @@
[Unit]
Description=Shortened URLs service job queue
Documentation=https://framagit.org/fiat-tux/hat-softwares/lstu
[Service]
Type=simple
User={{ lstu_user }}
WorkingDirectory={{ lstu.path }}
ExecStart=/usr/bin/carton exec script/application minion worker
# Hardening
CapabilityBoundingSet=
PrivateMounts=true
PrivateTmp=true
ProtectControlGroups=true
ProtectHome=true
ProtectSystem=strict
ReadWritePaths=-{{ lstu.path }}
[Install]
WantedBy=multi-user.target

View file

@ -2,3 +2,7 @@ check process lstu with pidfile {{ lstu.path }}/script/hypnotoad.pid
start program = "/bin/systemctl start {{ lstu_service }}" start program = "/bin/systemctl start {{ lstu_service }}"
stop program = "/bin/systemctl stop {{ lstu_service }}" stop program = "/bin/systemctl stop {{ lstu_service }}"
if failed host {{ ansible_default_ipv4.address }} port 8080 with timeout 15 seconds for 3 times within 4 cycles then restart if failed host {{ ansible_default_ipv4.address }} port 8080 with timeout 15 seconds for 3 times within 4 cycles then restart
check process lstu-minion matching "perl script/application minion worker"
start program = "/bin/systemctl start {{ minion_service }}"
stop program = "/bin/systemctl stop {{ minion_service }}"