Zammad: small fixes and updates

This commit is contained in:
phil 2023-05-19 11:59:02 +02:00
parent 0e083996e4
commit 2d539c31a0
10 changed files with 65 additions and 43 deletions

View file

@ -26,3 +26,8 @@ zammad_repo: https://github.com/zammad/zammad.git
zammad_user: _zammad
zammad_user_home: /var/lib/zammad
zammad_webserver_configuration: "/etc/nginx/sites-available/{{ zammad_domain }}"
zammad_service: zammad.service
zammad_rails_service: zammad-rails.service
zammad_websocket_service: zammad-websocket.service
zammad_worker_service: zammad-worker.service

View file

@ -21,7 +21,7 @@
state: reloaded
- name: restart zammad
ansible.builtin.command: systemctl restart zammad*
ansible.builtin.command: "systemctl restart {{ zammad_service }}"
- name: restart opensearch
ansible.builtin.service:

View file

@ -1,14 +1,18 @@
---
- name: "systemd | Kopiere Services"
ansible.builtin.template:
src: "systemd/{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
src: "systemd/{{ item.src }}.j2"
dest: "/etc/systemd/system/{{ item.dest }}"
mode: "0644"
loop:
- zammad.service
- zammad-rails.service
- zammad-worker.service
- zammad-websocket.service
- src: zammad.service
dest: "{{ zammad_service }}"
- src: zammad-rails.service
dest: "{{ zammad_rails_service }}"
- src: zammad-worker.service
dest: "{{ zammad_worker_service }}"
- src: zammad-websocket.service
dest: "{{ zammad_websocket_service }}"
- name: "systemd | Erstelle Konfigurationsverzeichnis"
ansible.builtin.file:
@ -24,7 +28,7 @@
- name: "systemd | Aktiviere Service"
ansible.builtin.systemd:
name: zammad
name: "{{ zammad_service }}"
enabled: true
daemon_reload: true
state: started

View file

@ -1,3 +1,8 @@
---
- name: "Zammad | Fix safedir warning"
ansible.builtin.command:
cmd: "git config --global --add safe.directory {{ zammad_home }}"
- name: "zammad | Hole Zammad Repo"
ansible.builtin.git:
repo: "{{ zammad_repo }}"
@ -16,7 +21,7 @@
# https://github.com/zammad/zammad/issues/325
- name: "zammad | Wende plain-Text-Patch an"
ansible.builtin.patch:
ansible.posix.patch:
src: plain-text.patch
dest: "{{ zammad_home }}/app/models/channel/email_build.rb"
@ -29,13 +34,13 @@
ansible.builtin.template:
src: zammad-delete-customers.rb.j2
dest: "{{ local_scripts_dir }}/zammad-delete-customers.rb"
mode: 0644
mode: "0644"
- name: "zammad | Kopiere Updater"
ansible.builtin.template:
src: zammad-updater.j2
dest: "{{ local_scripts_dir }}/zammad-updater"
mode: 0755
mode: "0755"
- name: "zammad | Erstelle Alias"
ansible.builtin.lineinfile:

View file

@ -1,20 +1,22 @@
check process zammad-rails with pidfile {{ zammad_home }}/tmp/pids/server.pid
start program = "/usr/sbin/service zammad-rails start"
stop program = "/usr/sbin/service zammad-rails stop"
check process {{ zammad_rails_service | splitext | first }} with pidfile {{ zammad_home }}/tmp/pids/server.pid
start program = "/usr/sbin/service {{ zammad_rails_service | splitext | first }} start"
stop program = "/usr/sbin/service {{ zammad-rails_service | splitext | first }} stop"
if 2 restarts within 3 cycles then timeout
if cpu usage > 95% for 3 cycles then restart
if failed host 127.0.0.1 port 3000 for 3 cycles then restart
check process zammad-websocket
check process {{ zammad_websocket_service | splitext | first }}
matching "script/websocket-server.rb -b 127.0.0.1 -p 6042 start"
start program = "/usr/sbin/service zammad-websocket start"
stop program = "/usr/sbin/service zammad-websocket stop"
start program = "/usr/sbin/service {{ zammad_websocket_service | splitext | first }} start"
stop program = "/usr/sbin/service {{ zammad_websocket_service | splitext | first }} stop"
if 2 restarts within 3 cycles then timeout
if cpu usage > 95% for 3 cycles then restart
if failed host 127.0.0.1 port 6042 for 3 cycles then restart
check process zammad-scheduler with pidfile {{ zammad_home }}/tmp/pids/scheduler.pid
start program = "/usr/sbin/service zammad-scheduler start"
stop program = "/usr/sbin/service zammad-scheduler stop"
check process {{ zammad_worker_service | splitext | first }}
matching "script/background-worker.rb start"
start program = "/usr/sbin/service {{ zammad-worker_service | splitext | first }} start"
stop program = "/usr/sbin/service {{ zammad_worker_service | splitext | first }} stop"
if 2 restarts within 3 cycles then timeout
if cpu usage > 95% for 3 cycles then restart
if 5 restarts within 5 cycles then timeout

View file

@ -1,14 +1,16 @@
### {{ ansible_managed }}
[Unit]
Description=Zammad rails server
After=syslog.target
After=network.target
After=zammad.service
Requires=zammad.service
After={{ zammad_service }}
Requires={{ zammad_service }}
[Service]
#Type=notify
#WatchdogSec=10
EnvironmentFile=/etc/zammad/zammad.env
EnvironmentFile={{ zammad_env_file }}
User={{ zammad_user }}
Group={{ zammad_user }}
Restart=always
@ -18,4 +20,4 @@ WorkingDirectory={{ zammad_home }}
ExecStart=/bin/bash -l -c "${BUNDLE_BINARY} exec script/rails server -b ${ZAMMAD_BIND_IP} -p ${ZAMMAD_RAILS_PORT}"
[Install]
WantedBy=zammad.service
WantedBy={{ zammad_service }}

View file

@ -1,12 +1,14 @@
### {{ ansible_managed }}
[Unit]
Description=Zammad websocket
After=syslog.target
After=network.target
After=zammad.service
Requires=zammad.service
After={{ zammad_service }}
Requires={{ zammad_service }}
[Service]
EnvironmentFile=/etc/zammad/zammad.env
EnvironmentFile={{ zammad_env_file }}
User={{ zammad_user }}
Group={{ zammad_user }}
Restart=always
@ -16,4 +18,4 @@ WorkingDirectory={{ zammad_home }}
ExecStart=/bin/bash -l -c "${BUNDLE_BINARY} exec script/websocket-server.rb -b ${ZAMMAD_BIND_IP} -p ${ZAMMAD_WEBSOCKET_PORT} start"
[Install]
WantedBy=zammad.service
WantedBy={{ zammad_service }}

View file

@ -1,12 +1,14 @@
### {{ ansible_managed }}
[Unit]
Description=Zammad Background Worker
After=syslog.target
After=network.target
After=zammad.service
Requires=zammad.service
After={{ zammad_service }}
Requires={{ zammad_service }}
[Service]
EnvironmentFile=/etc/zammad/zammad.env
EnvironmentFile={{ zammad_env_file }}
User={{ zammad_user }}
Group={{ zammad_user }}
Restart=always
@ -16,4 +18,4 @@ WorkingDirectory={{ zammad_home }}
ExecStart=/bin/bash -l -c "${BUNDLE_BINARY} exec script/background-worker.rb start"
[Install]
WantedBy=zammad.service
WantedBy={{ zammad_service }}

View file

@ -3,9 +3,9 @@ Description=Zammad
After=syslog.target
After=network.target
StopWhenUnneeded=true
Wants=zammad-rails.service
Wants=zammad-scheduler.service
Wants=zammad-websocket.service
Wants={{ zammad_rails_service }}
Wants={{ zammad_worker_service }}
Wants={{ zammad_websocket_service }}
[Service]
EnvironmentFile={{ zammad_env_file }}

View file

@ -7,9 +7,9 @@ RUBY_VERSION=$(cat {{ zammad_home }}/.ruby-version)
RUBY_INSTALLED_VERSIONS=$(rbenv version | grep $RUBY_VERSION | cut -d ' ' -f2)
echo "Stoppe Monit-Monitoring..."
monit unmonitor zammad-websocket
monit unmonitor zammad-rails
monit unmonitor zammad-scheduler
monit unmonitor {{ zammad_websocket_service | splitext | first }}
monit unmonitor {{ zammad_rails_service | splitext | first }}
monit unmonitor {{ zammad_worker_service | splitext | first }}
echo "Wechsle Verzeichnis..."
cd {{ zammad_home }}
@ -32,7 +32,7 @@ echo "Aktualisiere Ruby-Pakete..."
sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec bundle install --without test development mysql
echo "Stoppe Zammad..."
systemctl stop zammad.service
systemctl stop {{ zammad_service }}
echo "Migriere Datenbank..."
sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec bundle exec rake db:migrate
@ -45,12 +45,12 @@ sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec rails r "Locale.sync"
sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec rails r "Translation.sync"
echo "Starte Zammad..."
systemctl start zammad.service
systemctl start {{ zammad_service }}
sleep 20
echo "Starte Monit-Monitoring..."
monit monitor zammad-websocket
monit monitor zammad-rails
monit monitor zammad-scheduler
monit monitor {{ zammad_websocket_service | splitext | first }}
monit monitor {{ zammad_rails_service | splitext | first }}
monit monitor {{ zammad_worker_service | splitext | first }}
echo "Alles erledigt."