ansible-roles/webapps/mastodon/tasks/upgrade.yml
Mathieu Gauthier-Pilote 4c59374507
All checks were successful
gitea/ansible-roles/pipeline/head This commit looks good
p10166 Rôle pour mastodon
2022-12-23 10:00:00 -05:00

81 lines
2.3 KiB
YAML

---
# tasks file for mastodon
- name: Dump database to a file with compression
postgresql_db:
name: "{{ service }}_production"
state: dump
target: "{{ service }}_production.sql.gz"
become_user: postgres
- name: Checkout (git)
git:
repo: "{{ git_url }}"
dest: "~/mastodon/"
version: "{{ git_version | default(omit) }}"
#force: yes
update: yes
become_user: "{{ service }}"
- block:
- name: Install bundler
shell: ". ~/.profile && gem install bundler --no-document"
args:
chdir: "~/mastodon"
executable: /bin/bash # fails with /bin/sh
- name: Install gem dependencies
shell: ". ~/.profile && bundle install --deployment --without development test -j$(getconf _NPROCESSORS_ONLN)"
args:
chdir: "~/mastodon"
executable: /bin/bash # fails with /bin/sh
- name: Install javascript dependencies
shell: ". ~/.profile && yarn install --pure-lockfile"
args:
chdir: "~/mastodon"
executable: /bin/bash # fails with /bin/sh
- name: Run database migrations, skipping post-deployment
shell: ". ~/.profile && SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate"
args:
chdir: "~/mastodon"
executable: /bin/bash # fails with /bin/sh
- name: Precompile assets
shell: ". ~/.profile && RAILS_ENV=production bundle exec rails assets:precompile"
args:
chdir: "~/mastodon"
executable: /bin/bash # fails with /bin/sh
become_user: "{{ service }}"
- name: Restart services
service:
name: "{{ service }}.target"
state: restarted
- name: Run database migrations, this time including post-deployment
shell: ". ~/.profile && SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate"
args:
chdir: "~/mastodon"
executable: /bin/bash # fails with /bin/sh
become_user: "{{ service }}"
- name: Define variable to skip next task by default
set_fact:
keep_db_dump: true
- name: Remove database dump
file:
path: "{{ service }}_production.sql.gz"
state: absent
become_user: postgres
when: keep_db_dump is undefined
tags: clean
- name: Template conf file for nginx vhost
template:
src: "vhost.j2"
dest: "/etc/nginx/sites-available/{{ service }}"
- name: Reload nginx conf
service:
name: nginx
state: reloaded