Add mastodon service
This commit is contained in:
106
roles/mastodon/tasks/main.yml
Normal file
106
roles/mastodon/tasks/main.yml
Normal file
@@ -0,0 +1,106 @@
|
||||
---
|
||||
|
||||
- name: Add Yarn apt key
|
||||
apt_key:
|
||||
url: https://dl.yarnpkg.com/debian/pubkey.gpg
|
||||
state: present
|
||||
|
||||
- name: Add Yarn Repository
|
||||
apt_repository:
|
||||
repo: deb https://dl.yarnpkg.com/debian/ stable main
|
||||
state: present
|
||||
|
||||
- name: Install Yarn
|
||||
apt:
|
||||
name: yarn
|
||||
state: present
|
||||
|
||||
- name: Add Nodejs apt key
|
||||
apt_key:
|
||||
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
|
||||
state: present
|
||||
|
||||
- name: Add Nodes 12 repository
|
||||
apt_repository:
|
||||
repo: deb https://deb.nodesource.com/node_12.x buster main
|
||||
state: present
|
||||
|
||||
- name: Install NodeJs
|
||||
apt:
|
||||
name: nodejs
|
||||
state: present
|
||||
|
||||
- name: Install required by mastodon
|
||||
apt:
|
||||
name: "{{ requiredPackages }}"
|
||||
state: present
|
||||
|
||||
- name: Install Mastodon from git
|
||||
become: yes
|
||||
become_user: "{{ username }}"
|
||||
shell: |
|
||||
cd
|
||||
export PATH="$HOME/.rbenv/bin:$PATH"
|
||||
eval "$(rbenv init -)"
|
||||
git clone https://github.com/tootsuite/mastodon.git live
|
||||
cd live
|
||||
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
|
||||
gem install bundler --no-document
|
||||
bundle config set deployment 'true'
|
||||
bundle config set without 'development test'
|
||||
bundle install
|
||||
yarn install --pure-lockfile --non-interactive
|
||||
args:
|
||||
executable: /bin/bash
|
||||
|
||||
- name: ensure postgresql is running
|
||||
service:
|
||||
name: postgresql
|
||||
state: restarted
|
||||
|
||||
- name: Create postgresql Database
|
||||
become: yes
|
||||
become_user: postgres
|
||||
shell: psql -c "CREATE USER mastodon CREATEDB;"
|
||||
|
||||
- name: Copy nginx configuration
|
||||
copy:
|
||||
src: /home/{{ username }}/live/dist/nginx.conf
|
||||
dest: /etc/nginx/sites-available/mastodon.conf
|
||||
owner: root
|
||||
group: root
|
||||
remote_src: yes
|
||||
|
||||
- name: Set server name in nginx configuration
|
||||
replace:
|
||||
path: /etc/nginx/sites-available/mastodon.conf
|
||||
regexp: "^.*server_name example.com;"
|
||||
replace: " server_name {{ domain }};"
|
||||
|
||||
|
||||
- name: Set root directory in nginx configuration
|
||||
replace:
|
||||
dest: /etc/nginx/sites-available/mastodon.conf
|
||||
regexp: "^.*root /home/mastodon/live/public;"
|
||||
replace: "root /home/{{ username}}/live/public;"
|
||||
|
||||
|
||||
- name: Create a symbolic link
|
||||
file:
|
||||
src: /etc/nginx/sites-available/mastodon.conf
|
||||
dest: /etc/nginx/sites-enabled/mastodon.conf
|
||||
owner: root
|
||||
group: root
|
||||
state: link
|
||||
|
||||
- name: Copy systemd services
|
||||
shell: |
|
||||
cp /home/"{{ username }}"/live/dist/mastodon-web.service /etc/systemd/system/
|
||||
cp /home/"{{ username }}"/live/dist/mastodon-sidekiq.service /etc/systemd/system/
|
||||
cp /home/"{{ username }}"/live/dist/mastodon-streaming.service /etc/systemd/system/
|
||||
|
||||
- name: Enable systemd service
|
||||
shell: |
|
||||
systemctl enable mastodon-web
|
||||
systemctl enable mastodon-sidekiq
|
||||
systemctl enable mastodon-streaming
|
||||
Reference in New Issue
Block a user