You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
3.6 KiB

---
- hosts: server
tasks:
- name: create misskey User
ansible.builtin.user:
name: misskey
createhome: yes
home: /home/misskey
shell: /bin/nologin
become: yes
- name: add nodejs repo key
ansible.builtin.shell:
cmd: curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg >/dev/null
creates: /usr/share/keyrings/nodesource.gpg
become: yes
when: "{{ use_snap }} == false"
- name: add nodejs repo
ansible.builtin.apt_repository:
repo: deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x jammy main
become: yes
when: "{{ use_snap }} == false"
- name: install packages needed by misskey
ansible.builtin.package:
name: nodejs
state: latest
become: yes
when: "{{ use_snap }} == false"
- name: install yarn
ansible.builtin.shell:
cmd: npm install --global yarn
become: yes
- name: install nodejs via snap
snap:
name: node
channel: 16/stable
classic: yes
when: "{{ use_snap }} == true"
become: yes
- name: update apt cache
ansible.builtin.package:
update_cache: yes
become: yes
- name: install needed packages via apt
ansible.builtin.package:
name: "{{ item }}"
state: present
loop:
- postgresql
- redis
- python3-psycopg2
become: yes
- name: clone mk repo
ansible.builtin.git:
repo: "{{ source_repo }}"
dest: /home/misskey/misskey
version: "{{ version }}"
become: yes
become_user: misskey
- name: build dependencies
ansible.builtin.shell:
cmd: yarn install
chdir: /home/misskey/misskey
become: yes
become_user: misskey
- name: build mk
ansible.builtin.shell:
cmd: NODE_ENV=production yarn build
chdir: /home/misskey/misskey
become: yes
become_user: misskey
- name: setup mk config
ansible.builtin.template:
src: templates/mk_default.yml
dest: /home/misskey/misskey/.config/default.yml
owner: misskey
mode: '0600'
become: yes
- name: setup systemd config
ansible.builtin.template:
src: templates/misskey.service
dest: /etc/systemd/system/misskey.service
owner: root
become: yes
- name: start and enable postgresql
ansible.builtin.systemd:
state: started
enabled: true
name: postgresql
- name: Createe mk db
community.postgresql.postgresql_db:
name: misskey
encoding: UTF-8
become: yes
become_user: postgres
- name: create mk user and set privileges
community.postgresql.postgresql_user:
db: misskey
name: "{{ db_user }}"
password: "{{ db_password }}"
become: yes
become_user: postgres
- name: Grant DB privileges to mk user
community.postgresql.postgresql_privs:
database: misskey
type: database
state: present
privs: ALL
roles: "{{ db_user }}"
grant_option: yes
become: yes
become_user: postgres
- name: init db
ansible.builtin.shell:
cmd: yarn run init
chdir: /home/misskey/misskey
become: yes
become_user: misskey
- name: start and enable mk
ansible.builtin.systemd:
state: restarted
daemon_reload: true
enabled: true
name: misskey
become: yes