144 lines
4.3 KiB
YAML
144 lines
4.3 KiB
YAML
|
#!/usr/bin/ansible-playbook
|
||
|
# vim:ft=ansible:
|
||
|
---
|
||
|
- name: Install Pleroma
|
||
|
block:
|
||
|
- name: Set up system
|
||
|
block:
|
||
|
- name: Install packages
|
||
|
apt:
|
||
|
name:
|
||
|
- curl
|
||
|
- unzip
|
||
|
#- ncurses # Comes installed by default on buntu
|
||
|
- name: Create pleroma user
|
||
|
user:
|
||
|
name: pleroma
|
||
|
password: "!"
|
||
|
home: /opt/pleroma
|
||
|
shell: /usr/sbin/nologin
|
||
|
- name: Set up PostgreSQL
|
||
|
block:
|
||
|
- name: Create DB user
|
||
|
postgresql_user:
|
||
|
name: pleroma
|
||
|
password: "{{ pleroma_db_password }}"
|
||
|
- name: Create DB
|
||
|
postgresql_db:
|
||
|
name: pleroma
|
||
|
owner: pleroma
|
||
|
- name: Create extensions
|
||
|
postgresql_ext:
|
||
|
db: pleroma
|
||
|
name: "{{ item }}"
|
||
|
loop:
|
||
|
- citext
|
||
|
- pg_trgm
|
||
|
- uuid-ossp
|
||
|
become: yes
|
||
|
become_user: postgres
|
||
|
- name: Set up Apache
|
||
|
block:
|
||
|
- name: Enable modules
|
||
|
command:
|
||
|
cmd: a2enmod "{{ item }}"
|
||
|
creates: "/etc/apache2/mods-enabled/{{ item }}.load"
|
||
|
loop:
|
||
|
- proxy
|
||
|
- proxy_http
|
||
|
notify: restart apache
|
||
|
- name: Template out vhost
|
||
|
template:
|
||
|
src: "apache2-vhost-ssl.conf"
|
||
|
dest: "/etc/apache2/sites-available/{{ pleroma_url }}.conf"
|
||
|
notify: restart apache
|
||
|
- name: Create webroot
|
||
|
file:
|
||
|
state: directory
|
||
|
path: "{{ pleroma_webroot }}"
|
||
|
- name: Enable site
|
||
|
command:
|
||
|
cmd: "a2ensite {{ pleroma_url }}.conf"
|
||
|
creates: "/etc/apache2/sites-enabled/{{ pleroma_url }}.conf"
|
||
|
notify: restart apache
|
||
|
- name: Generate certificate
|
||
|
include_role:
|
||
|
name: https
|
||
|
vars:
|
||
|
website_url: "{{ pleroma_url }}"
|
||
|
- name: Install Pleroma
|
||
|
block:
|
||
|
- name: Get latest release zip
|
||
|
get_url:
|
||
|
url: "https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/stable/download?job={{ pleroma_arch }}"
|
||
|
dest: "/opt/pleroma/release.zip"
|
||
|
register: r
|
||
|
- name: Install Pleroma
|
||
|
block:
|
||
|
- name: Unzip release
|
||
|
unarchive:
|
||
|
src: "/opt/pleroma/release.zip"
|
||
|
remote_src: yes
|
||
|
dest: "/opt/pleroma"
|
||
|
- name: Remove old release
|
||
|
file:
|
||
|
path: "/opt/pleroma/{{ item }}"
|
||
|
state: absent
|
||
|
loop:
|
||
|
- bin
|
||
|
- lib
|
||
|
- releases
|
||
|
- installation
|
||
|
- erts-10.3.5.2 # Don't give me shit for hardcoding this version string in
|
||
|
- name: Move release out of folder
|
||
|
shell: mv -f /opt/pleroma/release/* /opt/pleroma/
|
||
|
- name: Clean up
|
||
|
file:
|
||
|
path: /opt/pleroma/release
|
||
|
state: absent
|
||
|
- name: Assign ownership
|
||
|
file:
|
||
|
path: /opt/pleroma
|
||
|
owner: pleroma
|
||
|
group: pleroma
|
||
|
recurse: yes
|
||
|
when: r is changed
|
||
|
- name: Create directory structure
|
||
|
file:
|
||
|
path: "{{ item }}"
|
||
|
state: directory
|
||
|
owner: pleroma
|
||
|
group: pleroma
|
||
|
mode: "0750"
|
||
|
loop:
|
||
|
- /etc/pleroma
|
||
|
- /opt/pleroma
|
||
|
- /var/lib/pleroma
|
||
|
- /var/lib/pleroma/uploads
|
||
|
- /var/lib/pleroma/static
|
||
|
- name: Template out configs
|
||
|
template:
|
||
|
src: config.exs
|
||
|
dest: /etc/pleroma/config.exs
|
||
|
owner: pleroma
|
||
|
group: pleroma
|
||
|
notify: restart pleroma
|
||
|
- name: Migrate DB
|
||
|
command: /opt/pleroma/bin/pleroma_ctl migrate
|
||
|
args:
|
||
|
chdir: /opt/pleroma
|
||
|
changed_when: false
|
||
|
- name: Template out service
|
||
|
template:
|
||
|
src: "pleroma.service"
|
||
|
dest: "/etc/systemd/system/pleroma.service"
|
||
|
notify: restart pleroma
|
||
|
- name: Start and enable service
|
||
|
systemd:
|
||
|
daemon_reload: yes
|
||
|
name: pleroma.service
|
||
|
state: started
|
||
|
enabled: yes
|
||
|
# TODO: BACKUPS BACKUPS BACKUPS
|
||
|
become: yes
|