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: _zammad
zammad_user_home: /var/lib/zammad zammad_user_home: /var/lib/zammad
zammad_webserver_configuration: "/etc/nginx/sites-available/{{ zammad_domain }}" 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 state: reloaded
- name: restart zammad - name: restart zammad
ansible.builtin.command: systemctl restart zammad* ansible.builtin.command: "systemctl restart {{ zammad_service }}"
- name: restart opensearch - name: restart opensearch
ansible.builtin.service: ansible.builtin.service:

View file

@ -1,14 +1,18 @@
--- ---
- name: "systemd | Kopiere Services" - name: "systemd | Kopiere Services"
ansible.builtin.template: ansible.builtin.template:
src: "systemd/{{ item }}.j2" src: "systemd/{{ item.src }}.j2"
dest: "/etc/systemd/system/{{ item }}" dest: "/etc/systemd/system/{{ item.dest }}"
mode: "0644" mode: "0644"
loop: loop:
- zammad.service - src: zammad.service
- zammad-rails.service dest: "{{ zammad_service }}"
- zammad-worker.service - src: zammad-rails.service
- zammad-websocket.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" - name: "systemd | Erstelle Konfigurationsverzeichnis"
ansible.builtin.file: ansible.builtin.file:
@ -24,7 +28,7 @@
- name: "systemd | Aktiviere Service" - name: "systemd | Aktiviere Service"
ansible.builtin.systemd: ansible.builtin.systemd:
name: zammad name: "{{ zammad_service }}"
enabled: true enabled: true
daemon_reload: true daemon_reload: true
state: started 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" - name: "zammad | Hole Zammad Repo"
ansible.builtin.git: ansible.builtin.git:
repo: "{{ zammad_repo }}" repo: "{{ zammad_repo }}"
@ -16,7 +21,7 @@
# https://github.com/zammad/zammad/issues/325 # https://github.com/zammad/zammad/issues/325
- name: "zammad | Wende plain-Text-Patch an" - name: "zammad | Wende plain-Text-Patch an"
ansible.builtin.patch: ansible.posix.patch:
src: plain-text.patch src: plain-text.patch
dest: "{{ zammad_home }}/app/models/channel/email_build.rb" dest: "{{ zammad_home }}/app/models/channel/email_build.rb"
@ -29,13 +34,13 @@
ansible.builtin.template: ansible.builtin.template:
src: zammad-delete-customers.rb.j2 src: zammad-delete-customers.rb.j2
dest: "{{ local_scripts_dir }}/zammad-delete-customers.rb" dest: "{{ local_scripts_dir }}/zammad-delete-customers.rb"
mode: 0644 mode: "0644"
- name: "zammad | Kopiere Updater" - name: "zammad | Kopiere Updater"
ansible.builtin.template: ansible.builtin.template:
src: zammad-updater.j2 src: zammad-updater.j2
dest: "{{ local_scripts_dir }}/zammad-updater" dest: "{{ local_scripts_dir }}/zammad-updater"
mode: 0755 mode: "0755"
- name: "zammad | Erstelle Alias" - name: "zammad | Erstelle Alias"
ansible.builtin.lineinfile: ansible.builtin.lineinfile:

View file

@ -1,20 +1,22 @@
check process zammad-rails with pidfile {{ zammad_home }}/tmp/pids/server.pid check process {{ zammad_rails_service | splitext | first }} with pidfile {{ zammad_home }}/tmp/pids/server.pid
start program = "/usr/sbin/service zammad-rails start" start program = "/usr/sbin/service {{ zammad_rails_service | splitext | first }} start"
stop program = "/usr/sbin/service zammad-rails stop" stop program = "/usr/sbin/service {{ zammad-rails_service | splitext | first }} stop"
if 2 restarts within 3 cycles then timeout if 2 restarts within 3 cycles then timeout
if cpu usage > 95% for 3 cycles then restart if cpu usage > 95% for 3 cycles then restart
if failed host 127.0.0.1 port 3000 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" matching "script/websocket-server.rb -b 127.0.0.1 -p 6042 start"
start program = "/usr/sbin/service zammad-websocket start" start program = "/usr/sbin/service {{ zammad_websocket_service | splitext | first }} start"
stop program = "/usr/sbin/service zammad-websocket stop" stop program = "/usr/sbin/service {{ zammad_websocket_service | splitext | first }} stop"
if 2 restarts within 3 cycles then timeout if 2 restarts within 3 cycles then timeout
if cpu usage > 95% for 3 cycles then restart if cpu usage > 95% for 3 cycles then restart
if failed host 127.0.0.1 port 6042 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 check process {{ zammad_worker_service | splitext | first }}
start program = "/usr/sbin/service zammad-scheduler start" matching "script/background-worker.rb start"
stop program = "/usr/sbin/service zammad-scheduler stop" 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 2 restarts within 3 cycles then timeout
if cpu usage > 95% for 3 cycles then restart 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] [Unit]
Description=Zammad rails server Description=Zammad rails server
After=syslog.target After=syslog.target
After=network.target After=network.target
After=zammad.service After={{ zammad_service }}
Requires=zammad.service Requires={{ zammad_service }}
[Service] [Service]
#Type=notify #Type=notify
#WatchdogSec=10 #WatchdogSec=10
EnvironmentFile=/etc/zammad/zammad.env EnvironmentFile={{ zammad_env_file }}
User={{ zammad_user }} User={{ zammad_user }}
Group={{ zammad_user }} Group={{ zammad_user }}
Restart=always 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}" ExecStart=/bin/bash -l -c "${BUNDLE_BINARY} exec script/rails server -b ${ZAMMAD_BIND_IP} -p ${ZAMMAD_RAILS_PORT}"
[Install] [Install]
WantedBy=zammad.service WantedBy={{ zammad_service }}

View file

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

View file

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

View file

@ -3,9 +3,9 @@ Description=Zammad
After=syslog.target After=syslog.target
After=network.target After=network.target
StopWhenUnneeded=true StopWhenUnneeded=true
Wants=zammad-rails.service Wants={{ zammad_rails_service }}
Wants=zammad-scheduler.service Wants={{ zammad_worker_service }}
Wants=zammad-websocket.service Wants={{ zammad_websocket_service }}
[Service] [Service]
EnvironmentFile={{ zammad_env_file }} 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) RUBY_INSTALLED_VERSIONS=$(rbenv version | grep $RUBY_VERSION | cut -d ' ' -f2)
echo "Stoppe Monit-Monitoring..." echo "Stoppe Monit-Monitoring..."
monit unmonitor zammad-websocket monit unmonitor {{ zammad_websocket_service | splitext | first }}
monit unmonitor zammad-rails monit unmonitor {{ zammad_rails_service | splitext | first }}
monit unmonitor zammad-scheduler monit unmonitor {{ zammad_worker_service | splitext | first }}
echo "Wechsle Verzeichnis..." echo "Wechsle Verzeichnis..."
cd {{ zammad_home }} 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 sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec bundle install --without test development mysql
echo "Stoppe Zammad..." echo "Stoppe Zammad..."
systemctl stop zammad.service systemctl stop {{ zammad_service }}
echo "Migriere Datenbank..." echo "Migriere Datenbank..."
sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec bundle exec rake db:migrate 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" sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec rails r "Translation.sync"
echo "Starte Zammad..." echo "Starte Zammad..."
systemctl start zammad.service systemctl start {{ zammad_service }}
sleep 20 sleep 20
echo "Starte Monit-Monitoring..." echo "Starte Monit-Monitoring..."
monit monitor zammad-websocket monit monitor {{ zammad_websocket_service | splitext | first }}
monit monitor zammad-rails monit monitor {{ zammad_rails_service | splitext | first }}
monit monitor zammad-scheduler monit monitor {{ zammad_worker_service | splitext | first }}
echo "Alles erledigt." echo "Alles erledigt."