ansible-role-zammad/tasks/database.yml
2023-03-19 01:12:43 +01:00

81 lines
2.2 KiB
YAML

---
- name: "database | Datenbank anlegen"
community.postgresql.postgresql_db:
name: "{{ zammad_database_name }}"
encoding: UTF8
template: template0
become: true
become_user: postgres
delegate_to: "{{ database_host }}"
register: database_created
- name: "database | Benutzer einrichten"
community.postgresql.postgresql_user:
name: "{{ zammad_database_user }}"
password: "{{ zammad_database_password }}"
db: "{{ zammad_database_name }}"
become: true
become_user: postgres
delegate_to: "{{ database_host }}"
- name: "database | Konfiguration kopieren"
ansible.builtin.template:
src: database.yml.j2
dest: "{{ zammad_database_configuration }}"
owner: "{{ zammad_user }}"
group: "{{ zammad_user }}"
mode: "0600"
- name: "database | Stoppe Service"
ansible.builtin.service:
name: zammad
state: stopped
register: unused_disable
changed_when: false
failed_when: "unused_disable is failed and ('find' not in unused_disable.msg and 'found' not in unused_disable.msg)"
- name: "database | Führe Migrationen aus"
ansible.builtin.shell: "rbenv exec bundle exec rake db:migrate"
args:
chdir: "{{ zammad_home }}"
become: true
become_user: "{{ zammad_user }}"
environment:
RAILS_ENV: production
- name: "database | Führe Seeds aus"
ansible.builtin.shell: "rbenv exec bundle exec rake db:seed"
args:
chdir: "{{ zammad_home }}"
become: true
become_user: "{{ zammad_user }}"
environment:
RAILS_ENV: production
when: database_created.changed
- name: "database | Precompile Assets"
ansible.builtin.shell: "rbenv exec bundle exec rake assets:precompile"
args:
chdir: "{{ zammad_home }}"
become: true
become_user: "{{ zammad_user }}"
environment:
RAILS_ENV: production
- name: "database | Synchronisiere Locales"
ansible.builtin.shell: rbenv exec bundle exec rails r "Locale.sync"
args:
chdir: "{{ zammad_home }}"
become: true
become_user: "{{ zammad_user }}"
environment:
RAILS_ENV: production
- name: "database | Synchronisiere Translations"
ansible.builtin.shell: rbenv exec bundle exec rails r "Translation.sync"
args:
chdir: "{{ zammad_home }}"
become: true
become_user: "{{ zammad_user }}"
environment:
RAILS_ENV: production