feat: add mastodon support directly

This commit is contained in:
VC
2024-07-05 11:53:29 +02:00
parent a8868f7f07
commit e77ff577c1
17 changed files with 427 additions and 12 deletions

View File

@@ -0,0 +1,71 @@
---
- name: install nodejs
include_tasks: nodejs.yml
- name: install yarn
include_tasks: yarn.yml
- name: install redis
include_tasks: redis.yml
- name: mastodon user
user:
name: mastodon
comment: "John Mastodon"
password: '!'
shell: /bin/bash
home: "{{ mastodon_home }}"
- name: mastodon .ssh dir
file:
state: directory
path: "{{ mastodon_home }}/.ssh"
owner: mastodon
group: mastodon
- name: ssh for mastodon user
copy:
remote_src: true
src: /root/.ssh/authorized_keys
dest: "{{ mastodon_home }}/.ssh/authorized_keys"
owner: mastodon
group: mastodon
- name: install prereq
apt:
name: "{{ item }}"
state: present
loop:
- imagemagick
- ffmpeg
- libpq-dev
- libxml2-dev
- libxslt1-dev
- file
- git-core
- g++
- libprotobuf-dev
- protobuf-compiler
- pkg-config
- nodejs
- gcc
- autoconf
- bison
- build-essential
- libssl-dev
- libyaml-dev
- libreadline6-dev
- zlib1g-dev
- libncurses5-dev
- libffi-dev
- libgdbm-dev
- libidn11-dev
- libicu-dev
- libjemalloc-dev
- name: install rbenv
include_tasks: rbenv.yml
- name: install mastodon
include_tasks: mastodon.yml

View File

@@ -0,0 +1,47 @@
---
- name: git mastodon
remote_user: mastodon
git:
repo: "https://github.com/mastodon/mastodon.git"
dest: "{{ mastodon_home }}/live"
version: "v{{ mastodon_version }}"
- name: bundle config command
remote_user: mastodon
shell: |
bash -lic "bundle config deployment 'true' && bundle config without 'development test'"
args:
creates: "{{ mastodon_home }}/.bundle/config"
chdir: "{{ mastodon_home }}/live"
- name: bundle install
remote_user: mastodon
shell: |
bash -lic "bundle install -j$(getconf _NPROCESSORS_ONLN)"
args:
chdir: "{{ mastodon_home }}/live"
- name: yarn install
remote_user: mastodon
shell: |
bash -lic "yarn install --pure-lockfile"
args:
chdir: "{{ mastodon_home }}/live"
- name: install services
template:
src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
loop: &mastodon_services
- "mastodon-sidekiq.service"
- "mastodon-streaming.service"
- "mastodon-web.service"
- name: run services
systemd:
name: "{{ item }}"
daemon_reload: true
state: started
enabled: true
loop: *mastodon_services

View File

@@ -0,0 +1,22 @@
---
- name: get node source gpg url
get_url:
url: "{{ mastodon_nodejs_key_url }}"
dest: /tmp/nodesource.gpg.key
- name: gpg dearmor key
shell: "gpg --dearmor -o {{ mastodon_nodejs_key_path }} /tmp/nodesource.gpg.key"
args:
creates: "{{ mastodon_nodejs_key_path }}"
- name: node source repo
copy:
content: "deb [signed-by={{ mastodon_nodejs_key_path }}] https://deb.nodesource.com/node_16.x {{ ansible_facts['distribution_release'] }} main"
dest: /etc/apt/sources.list.d/nodesource.list
- name: install nodejs
apt:
name: nodejs
state: present
update_cache: true

View File

@@ -0,0 +1,38 @@
---
- name: git rbenv
remote_user: mastodon
git:
repo: "https://github.com/rbenv/rbenv.git"
dest: "{{ mastodon_home }}/.rbenv"
single_branch: true
version: master
- name: git ruby-build
remote_user: mastodon
git:
repo: https://github.com/rbenv/ruby-build.git
dest: "{{ mastodon_home }}/.rbenv/plugins/ruby-build"
single_branch: true
version: master
- name: append env to mastodon bashrc
remote_user: mastodon
lineinfile:
path: "{{ mastodon_home }}/.bashrc"
line: "eval \"$(~/.rbenv/bin/rbenv init - bash)\""
- name: install ruby version
remote_user: mastodon
shell: "bash -lic 'rbenv install {{ mastodon_ruby_version }}'"
args:
executable: /bin/bash
creates: "~/.rbenv/versions/{{ mastodon_ruby_version }}/bin/ruby"
environment:
RUBY_CONFIGURE_OPTS: "--with-jemalloc"
- name: install bundler for ruby
remote_user: mastodon
shell: "bash -lic 'rbenv global {{ mastodon_ruby_version }} && ruby --version && gem install bundler --no-document'"
args:
executable: /bin/bash

View File

@@ -0,0 +1,12 @@
---
- name: install redis
apt:
name: redis
state: present
update_cache: true
- name: start redis service
service:
name: redis
state: started

View File

@@ -0,0 +1,22 @@
---
- name: get yarn gpg url
get_url:
url: "{{ mastodon_yarn_key_url }}"
dest: /tmp/yarn.gpg.key
- name: gpg dearmor key
shell: "gpg --dearmor -o {{ mastodon_yarn_key_path }} /tmp/yarn.gpg.key"
args:
creates: "{{ mastodon_yarn_key_path }}"
- name: yarn source repo
copy:
content: "deb [signed-by={{ mastodon_yarn_key_path }}] https://dl.yarnpkg.com/debian stable main"
dest: /etc/apt/sources.list.d/yarn.list
- name: install yarn
apt:
name: yarn
state: present
update_cache: true