2017-11-27 01:58:45 +00:00
|
|
|
---
|
|
|
|
# This role copies over the user-edited .env.production, runs the database
|
|
|
|
# setup, pre-compiles assets, starts Mastodon daemons, adds media cleanup
|
|
|
|
# cron job
|
|
|
|
|
2017-11-27 02:59:48 +00:00
|
|
|
- name: Generate PAPERCLIP_SECRET and register it
|
2017-11-27 18:18:27 +00:00
|
|
|
shell: cd /home/mastodon/live && bundle exec rake secret
|
2017-11-27 02:59:48 +00:00
|
|
|
register: PAPERCLIP_SECRET
|
|
|
|
environment:
|
|
|
|
RAILS_ENV: production
|
2017-11-27 18:18:27 +00:00
|
|
|
PATH: '/home/mastodon/.rbenv/bin:/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/plugins/ruby-build/bin:{{ ansible_env.PATH }}'
|
2017-11-27 02:59:48 +00:00
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
become: true
|
|
|
|
become_user: mastodon
|
|
|
|
- name: Generate SECRET_KEY_BASE and register it
|
2017-11-27 18:18:27 +00:00
|
|
|
shell: cd /home/mastodon/live && bundle exec rake secret
|
2017-11-27 02:59:48 +00:00
|
|
|
register: SECRET_KEY_BASE
|
|
|
|
environment:
|
|
|
|
RAILS_ENV: production
|
2017-11-27 18:18:27 +00:00
|
|
|
PATH: '/home/mastodon/.rbenv/bin:/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/plugins/ruby-build/bin:{{ ansible_env.PATH }}'
|
2017-11-27 02:59:48 +00:00
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
become: true
|
|
|
|
become_user: mastodon
|
|
|
|
- name: Generate OTP_SECRET and register it
|
2017-11-27 18:18:27 +00:00
|
|
|
shell: cd /home/mastodon/live && bundle exec rake secret
|
2017-11-27 02:59:48 +00:00
|
|
|
register: OTP_SECRET
|
|
|
|
environment:
|
|
|
|
RAILS_ENV: production
|
2017-11-27 18:18:27 +00:00
|
|
|
PATH: '/home/mastodon/.rbenv/bin:/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/plugins/ruby-build/bin:{{ ansible_env.PATH }}'
|
2017-11-27 02:59:48 +00:00
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
become: true
|
|
|
|
become_user: mastodon
|
2017-11-27 03:14:53 +00:00
|
|
|
- name: Generate VAPID keys and register it
|
2017-11-27 18:18:27 +00:00
|
|
|
shell: cd /home/mastodon/live && bundle exec rake mastodon:webpush:generate_vapid_key
|
2017-11-27 03:14:53 +00:00
|
|
|
register: VAPID_KEYS
|
|
|
|
environment:
|
|
|
|
RAILS_ENV: production
|
2017-11-27 18:18:27 +00:00
|
|
|
PATH: '/home/mastodon/.rbenv/bin:/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/plugins/ruby-build/bin:{{ ansible_env.PATH }}'
|
2017-12-11 17:15:40 +00:00
|
|
|
SECRET_KEY_BASE: '0'
|
2017-11-27 03:14:53 +00:00
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
become: true
|
|
|
|
become_user: mastodon
|
2017-12-11 17:19:56 +00:00
|
|
|
- name: Copy Mastodon .env.production
|
2017-11-27 01:58:45 +00:00
|
|
|
template:
|
|
|
|
src: .env.production
|
|
|
|
dest: /home/mastodon/live/.env.production
|
|
|
|
become: true
|
|
|
|
become_user: mastodon
|
2017-11-27 16:54:40 +00:00
|
|
|
- name: Precompile Mastodon static assets
|
2017-11-27 18:18:27 +00:00
|
|
|
shell: cd /home/mastodon/live && bundle exec rails assets:precompile
|
2017-11-27 01:58:45 +00:00
|
|
|
environment:
|
|
|
|
RAILS_ENV: production
|
2017-11-27 18:18:27 +00:00
|
|
|
PATH: '/home/mastodon/.rbenv/bin:/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/plugins/ruby-build/bin:{{ ansible_env.PATH }}'
|
2017-11-27 01:58:45 +00:00
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
become: true
|
|
|
|
become_user: mastodon
|
2017-11-27 16:54:40 +00:00
|
|
|
- name: Run Mastodon database setup
|
2017-11-27 18:18:27 +00:00
|
|
|
shell: cd /home/mastodon/live && bundle exec rails db:setup
|
2017-11-27 01:58:45 +00:00
|
|
|
environment:
|
|
|
|
RAILS_ENV: production
|
2017-11-27 16:54:40 +00:00
|
|
|
SAFETY_ASSURED: 1
|
2017-11-27 18:18:27 +00:00
|
|
|
PATH: '/home/mastodon/.rbenv/bin:/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/plugins/ruby-build/bin:{{ ansible_env.PATH }}'
|
2017-11-27 01:58:45 +00:00
|
|
|
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
|
2017-11-27 16:58:11 +00:00
|
|
|
- name: (Re)Start Mastodon services
|
2017-11-27 16:48:17 +00:00
|
|
|
systemd: name={{ item }} state=restarted
|
2017-11-27 01:58:45 +00:00
|
|
|
with_items:
|
|
|
|
- mastodon-sidekiq
|
|
|
|
- mastodon-streaming
|
|
|
|
- mastodon-web
|