Add mastodon service

This commit is contained in:
2021-01-01 23:39:04 +01:00
parent 43afec97ae
commit f246a2a47d
19 changed files with 418 additions and 16 deletions

3
roles/mastodon/README.md Normal file
View File

@@ -0,0 +1,3 @@
# Mastodon pour social.bim.land.
Rbenv est installé dans le home de l'utilisateur mastodon

View File

@@ -0,0 +1,30 @@
---
requiredPackages:
- imagemagick
- ffmpeg
- libpq-dev
- libxml2-dev
- libxslt1-dev
- file
- git-core
- g++
- libprotobuf-dev
- protobuf-compiler
- pkg-config
- gcc
- autoconf
- bison
- build-essential
- libssl-dev
- libyaml-dev
- libreadline-dev
- zlib1g-dev
- libncurses5-dev
- libffi-dev
- libgdbm-dev
- libidn11-dev
- libicu-dev
- libjemalloc-dev
- redis-tools
- redis-server

View 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