87 lines
3.0 KiB
YAML
87 lines
3.0 KiB
YAML
---
|
|
# This role copies over the user-edited .env.production, runs the database
|
|
# setup, pre-compiles assets, starts Mastodon daemons, adds media cleanup
|
|
# cron job
|
|
|
|
- name: Generate PAPERCLIP_SECRET and register it
|
|
shell: cd /home/mastodon/live && bundle exec rake secret
|
|
register: PAPERCLIP_SECRET
|
|
environment:
|
|
RAILS_ENV: production
|
|
PATH: '/home/mastodon/.rbenv/bin:/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/plugins/ruby-build/bin:{{ ansible_env.PATH }}'
|
|
args:
|
|
executable: /bin/bash
|
|
become: true
|
|
become_user: mastodon
|
|
- name: Generate SECRET_KEY_BASE and register it
|
|
shell: cd /home/mastodon/live && bundle exec rake secret
|
|
register: SECRET_KEY_BASE
|
|
environment:
|
|
RAILS_ENV: production
|
|
PATH: '/home/mastodon/.rbenv/bin:/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/plugins/ruby-build/bin:{{ ansible_env.PATH }}'
|
|
args:
|
|
executable: /bin/bash
|
|
become: true
|
|
become_user: mastodon
|
|
- name: Generate OTP_SECRET and register it
|
|
shell: cd /home/mastodon/live && bundle exec rake secret
|
|
register: OTP_SECRET
|
|
environment:
|
|
RAILS_ENV: production
|
|
PATH: '/home/mastodon/.rbenv/bin:/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/plugins/ruby-build/bin:{{ ansible_env.PATH }}'
|
|
args:
|
|
executable: /bin/bash
|
|
become: true
|
|
become_user: mastodon
|
|
- name: Generate VAPID keys and register it
|
|
shell: cd /home/mastodon/live && bundle exec rake mastodon:webpush:generate_vapid_key
|
|
register: VAPID_KEYS
|
|
environment:
|
|
RAILS_ENV: production
|
|
PATH: '/home/mastodon/.rbenv/bin:/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/plugins/ruby-build/bin:{{ ansible_env.PATH }}'
|
|
SECRET_KEY_BASE: '0'
|
|
args:
|
|
executable: /bin/bash
|
|
become: true
|
|
become_user: mastodon
|
|
- name: Copy Mastodon .env.production
|
|
template:
|
|
src: .env.production
|
|
dest: /home/mastodon/live/.env.production
|
|
become: true
|
|
become_user: mastodon
|
|
- name: Precompile Mastodon static assets
|
|
shell: cd /home/mastodon/live && bundle exec rails assets:precompile
|
|
environment:
|
|
RAILS_ENV: production
|
|
PATH: '/home/mastodon/.rbenv/bin:/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/plugins/ruby-build/bin:{{ ansible_env.PATH }}'
|
|
args:
|
|
executable: /bin/bash
|
|
become: true
|
|
become_user: mastodon
|
|
- name: Run Mastodon database setup
|
|
shell: cd /home/mastodon/live && bundle exec rails db:setup
|
|
environment:
|
|
RAILS_ENV: production
|
|
SAFETY_ASSURED: 1
|
|
PATH: '/home/mastodon/.rbenv/bin:/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/plugins/ruby-build/bin:{{ ansible_env.PATH }}'
|
|
args:
|
|
executable: /bin/bash
|
|
become: true
|
|
become_user: mastodon
|
|
- name: Add Mastodon media cache cleanup cronjob
|
|
cron:
|
|
name: "Mastodon media cache cleanup"
|
|
special_time: daily
|
|
job: "cd /home/mastodon/live && RAILS_ENV=production /home/mastodon/.rbenv/shims/bundle exec rake mastodon:media:remove_remote"
|
|
backup: yes
|
|
state: present
|
|
become: true
|
|
become_user: mastodon
|
|
- name: (Re)Start Mastodon services
|
|
systemd: name={{ item }} state=restarted
|
|
with_items:
|
|
- mastodon-sidekiq
|
|
- mastodon-streaming
|
|
- mastodon-web
|