2020-07-28 10:41:07 -05:00
|
|
|
#!/usr/bin/ansible-playbook
|
|
|
|
# vim:ft=ansible:
|
|
|
|
---
|
|
|
|
- name: Install Pleroma
|
|
|
|
block:
|
|
|
|
- name: Set up system
|
|
|
|
block:
|
|
|
|
- name: Install packages
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- curl
|
2020-08-01 22:17:14 -05:00
|
|
|
- python3-psycopg2
|
2020-07-28 10:41:07 -05:00
|
|
|
- unzip
|
|
|
|
#- ncurses # Comes installed by default on buntu
|
|
|
|
- name: Create pleroma user
|
|
|
|
user:
|
|
|
|
name: pleroma
|
|
|
|
password: "!"
|
|
|
|
home: /opt/pleroma
|
|
|
|
shell: /usr/sbin/nologin
|
2020-07-30 08:28:46 -05:00
|
|
|
- name: Template out service
|
|
|
|
template:
|
|
|
|
src: "pleroma.service"
|
|
|
|
dest: "/etc/systemd/system/pleroma.service"
|
|
|
|
notify: restart pleroma
|
2020-07-28 10:41:07 -05:00
|
|
|
- name: Set up PostgreSQL
|
|
|
|
block:
|
|
|
|
- name: Create DB user
|
|
|
|
postgresql_user:
|
|
|
|
name: pleroma
|
|
|
|
password: "{{ pleroma_db_password }}"
|
2020-08-01 18:35:38 -05:00
|
|
|
login_host: "{{ pleroma_db_hostname }}"
|
|
|
|
login_user: "{{ psql_ansible_user }}"
|
|
|
|
login_password: "{{ psql_ansible_password }}"
|
2020-07-28 10:41:07 -05:00
|
|
|
- name: Create DB
|
|
|
|
postgresql_db:
|
|
|
|
name: pleroma
|
|
|
|
owner: pleroma
|
2020-08-01 18:35:38 -05:00
|
|
|
login_host: "{{ pleroma_db_hostname }}"
|
|
|
|
login_user: "{{ psql_ansible_user }}"
|
|
|
|
login_password: "{{ psql_ansible_password }}"
|
2020-07-28 10:41:07 -05:00
|
|
|
- name: Create extensions
|
|
|
|
postgresql_ext:
|
|
|
|
db: pleroma
|
|
|
|
name: "{{ item }}"
|
2020-08-01 18:35:38 -05:00
|
|
|
login_host: "{{ pleroma_db_hostname }}"
|
|
|
|
login_user: "{{ psql_ansible_user }}"
|
|
|
|
login_password: "{{ psql_ansible_password }}"
|
2020-07-28 10:41:07 -05:00
|
|
|
loop:
|
|
|
|
- citext
|
|
|
|
- pg_trgm
|
|
|
|
- uuid-ossp
|
|
|
|
- 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
|
2020-07-30 08:28:46 -05:00
|
|
|
- name: Template out scripts
|
|
|
|
template:
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "/opt/pleroma/{{ item.dest }}"
|
|
|
|
owner: pleroma
|
|
|
|
group: pleroma
|
|
|
|
mode: "{{ item.mode }}"
|
|
|
|
loop:
|
|
|
|
- { src: "recover.sh", dest: "recover.sh", mode: "0755" }
|
2020-07-28 10:41:07 -05:00
|
|
|
- name: Install Pleroma
|
|
|
|
block:
|
2020-07-30 09:01:32 -05:00
|
|
|
- name: Disable service
|
|
|
|
systemd:
|
|
|
|
name: pleroma
|
|
|
|
state: stopped
|
2020-07-28 10:41:07 -05:00
|
|
|
- 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
|
2020-07-28 10:57:34 -05:00
|
|
|
mode: "0640"
|
2020-07-28 10:41:07 -05:00
|
|
|
notify: restart pleroma
|
2020-07-28 10:57:34 -05:00
|
|
|
- name: Clone static directory
|
|
|
|
git:
|
|
|
|
repo: "{{ pleroma_static_repo }}"
|
|
|
|
dest: "/var/lib/pleroma/static"
|
|
|
|
force: yes
|
|
|
|
when: pleroma_static_repo is defined
|
2020-07-28 11:38:49 -05:00
|
|
|
become: yes
|
|
|
|
become_user: pleroma
|
2020-07-28 10:41:07 -05:00
|
|
|
- name: Migrate DB
|
|
|
|
command: /opt/pleroma/bin/pleroma_ctl migrate
|
|
|
|
args:
|
|
|
|
chdir: /opt/pleroma
|
2020-07-30 08:40:39 -05:00
|
|
|
become: yes
|
|
|
|
become_user: pleroma
|
2020-07-28 10:41:07 -05:00
|
|
|
changed_when: false
|
|
|
|
- name: Start and enable service
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
name: pleroma.service
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
2020-07-28 15:49:05 -05:00
|
|
|
- name: Template out backup module
|
|
|
|
template:
|
|
|
|
src: "backup.sh"
|
|
|
|
dest: "/opt/backups/modules/{{ pleroma_url }}.sh"
|
|
|
|
mode: "0600"
|
2020-07-28 10:41:07 -05:00
|
|
|
become: yes
|