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
|
2020-08-28 16:21:33 -05:00
|
|
|
#- ncurses-bin # Comes installed by default on buntu
|
2020-07-28 10:41:07 -05:00
|
|
|
- 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
|
2020-08-02 19:46:12 -05:00
|
|
|
password: "{{ pleroma.db.pass }}"
|
2020-08-01 18:35:38 -05:00
|
|
|
login_host: "{{ pleroma_db_hostname }}"
|
2020-08-02 19:36:46 -05:00
|
|
|
login_user: "{{ psql.ansible.user }}"
|
|
|
|
login_password: "{{ psql.ansible.pass }}"
|
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 }}"
|
2020-08-02 19:36:46 -05:00
|
|
|
login_user: "{{ psql.ansible.user }}"
|
|
|
|
login_password: "{{ psql.ansible.pass }}"
|
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 }}"
|
2020-08-02 19:36:46 -05:00
|
|
|
login_user: "{{ psql.ansible.user }}"
|
|
|
|
login_password: "{{ psql.ansible.pass }}"
|
2020-07-28 10:41:07 -05:00
|
|
|
loop:
|
|
|
|
- citext
|
|
|
|
- pg_trgm
|
|
|
|
- uuid-ossp
|
2020-08-02 08:06:38 -05:00
|
|
|
when: pleroma_db_hostname is defined
|
2020-07-28 10:41:07 -05:00
|
|
|
- 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"
|
2020-09-09 02:02:30 -05:00
|
|
|
become: yes
|
|
|
|
become_user: pleroma
|
2020-07-28 10:41:07 -05:00
|
|
|
- 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
|
2020-08-07 05:42:06 -05:00
|
|
|
mode: "0755"
|
2020-07-28 10:41:07 -05:00
|
|
|
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:
|
2020-08-02 19:46:12 -05:00
|
|
|
repo: "{{ pleroma.static_repo }}"
|
2020-07-28 10:57:34 -05:00
|
|
|
dest: "/var/lib/pleroma/static"
|
|
|
|
force: yes
|
2020-08-02 19:46:12 -05:00
|
|
|
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
|