mastible/roles/mastodon-config/tasks/main.yml

42 lines
1.4 KiB
YAML

---
# This role pre-compiles assets, starts Mastodon daemons,
# adds media cleanup cron job
- name: Run install tasks
include_tasks: install.yml
when: install is defined
- name: Run Mastodon database migration
when: install is not defined
shell: cd /home/mastodon/live && bundle exec rails db:migrate
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: 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: 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