Added proper reinstall logic for pleroma.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pleroma/aws-s3-backup/handlers/main.yaml Sat Sep 19 13:17:07 2020 -0500
@@ -0,0 +1,5 @@
+---
+
+- name: restart pleroma instance s3 backup
+ become: yes
+ systemd: name="pleroma-s3-backup@{{pleroma_instance}}.service" enabled="yes" daemon_reload="yes"
--- a/pleroma/otp/handlers/main.yaml Mon Sep 14 12:37:21 2020 -0500
+++ b/pleroma/otp/handlers/main.yaml Sat Sep 19 13:17:07 2020 -0500
@@ -1,9 +1,9 @@
---
+- name: restart all pleroma instances
+ become: yes
+ command: "systemctl restart pleroma@*.service"
+
- name: restart pleroma instance
become: yes
systemd: name="pleroma@{{pleroma_instance}}.service" state="restarted" daemon_reload="yes"
-
-- name: restart pleroma instance s3 backup
- become: yes
- systemd: name="pleroma-s3-backup@{{pleroma_instance}}.service" enabled="yes" daemon_reload="yes"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pleroma/otp/tasks/install.yaml Sat Sep 19 13:17:07 2020 -0500
@@ -0,0 +1,24 @@
+---
+
+- name: download and unarchive pleroma release
+ become: yes
+ unarchive:
+ src: "{{pleroma_download_url}}"
+ dest: "/tmp/"
+ remote_src: yes
+
+- name: delete old pleroma release
+ become: yes
+ file:
+ path: "/opt/pleroma/"
+ state: "absent"
+
+- name: install pleroma release
+ become: yes
+ copy:
+ remote_src: true
+ src: "/tmp/release/"
+ dest: "/opt/pleroma/"
+ owner: "pleroma"
+ group: "pleroma"
+ notify: restart all pleroma instances
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pleroma/otp/tasks/instance.yaml Sat Sep 19 13:17:07 2020 -0500
@@ -0,0 +1,57 @@
+---
+
+- name: install pleroma instance config
+ template:
+ src: "config.exs.j2"
+ dest: "/etc/pleroma/{{pleroma_instance}}.config.exs"
+ owner: "pleroma"
+ group: "pleroma"
+ mode: "0600"
+ become: yes
+ notify: restart pleroma instance
+
+- name: create instance data directory
+ become: yes
+ file:
+ path: "{{item}}"
+ state: "directory"
+ owner: "pleroma"
+ group: "pleroma"
+ mode: "0755"
+ with_items:
+ - "{{pleroma_data_dir}}/{{pleroma_instance}}"
+ - "{{pleroma_data_dir}}/{{pleroma_instance}}/uploads"
+ - "{{pleroma_data_dir}}/{{pleroma_instance}}/static"
+ - "{{pleroma_data_dir}}/{{pleroma_instance}}/static/emoji"
+
+- name: install pleroma db schema file
+ become: yes
+ template:
+ src: "setup_db.psql.j2"
+ dest: "/tmp/setup_db_{{pleroma_instance}}.psql"
+ owner: "{{pleroma_db_superuser}}"
+ group: "{{pleroma_db_superuser}}"
+ mode: "0600"
+
+- name: install pleroma psql
+ become: yes
+ become_user: "{{pleroma_db_superuser}}"
+ command: "psql -f /tmp/setup_db_{{pleroma_instance}}.psql"
+ changed_when: false
+
+- include_tasks: soapbox.yaml
+ when: pleroma_soapbox
+
+- name: ensure pleroma instance is enabled and started
+ become: yes
+ systemd: name="pleroma@{{pleroma_instance}}.service" enabled="yes" state="started"
+
+- name: migrate db
+ become: yes
+ become_user: "pleroma"
+ command: "/opt/pleroma/bin/pleroma_ctl migrate"
+ args:
+ chdir: "/opt/pleroma/"
+ environment:
+ PLEROMA_CONFIG_PATH: "/etc/pleroma/{{pleroma_instance}}.config.exs"
+ changed_when: false
--- a/pleroma/otp/tasks/main.yaml Mon Sep 14 12:37:21 2020 -0500
+++ b/pleroma/otp/tasks/main.yaml Sat Sep 19 13:17:07 2020 -0500
@@ -1,6 +1,6 @@
---
-- name: add users
+- name: add pleroma user
become: yes
user: name="pleroma" shell="/bin/false" home="/opt/pleroma" system="yes"
@@ -8,7 +8,7 @@
become: yes
apt: name="libtinfo5"
-- name: create config and data directory
+- name: create pleroma config and data directories
become: yes
file:
path: "{{item}}"
@@ -19,67 +19,6 @@
- "/etc/pleroma"
- "/opt/pleroma"
-- name: install pleroma config
- template:
- src: "config.exs.j2"
- dest: "/etc/pleroma/{{pleroma_instance}}.config.exs"
- owner: "pleroma"
- group: "pleroma"
- mode: "0600"
- become: yes
- notify: restart pleroma instance
-
-- name: create instance data directory
- become: yes
- file:
- path: "{{item}}"
- state: "directory"
- owner: "pleroma"
- group: "pleroma"
- mode: "0755"
- with_items:
- - "{{pleroma_data_dir}}/{{pleroma_instance}}"
- - "{{pleroma_data_dir}}/{{pleroma_instance}}/uploads"
- - "{{pleroma_data_dir}}/{{pleroma_instance}}/static"
- - "{{pleroma_data_dir}}/{{pleroma_instance}}/static/emoji"
-
-- name: install pleroma db schema file
- become: yes
- template:
- src: "setup_db.psql.j2"
- dest: "/tmp/setup_db_{{pleroma_instance}}.psql"
- owner: "{{pleroma_db_superuser}}"
- group: "{{pleroma_db_superuser}}"
- mode: "0600"
-
-- name: install pleroma psql
- become: yes
- become_user: "{{pleroma_db_superuser}}"
- command: "psql -f /tmp/setup_db_{{pleroma_instance}}.psql"
- changed_when: false
-
-- name: download and unarchive pleroma release
- become: yes
- unarchive:
- src: "{{pleroma_download_url}}"
- dest: "/tmp/"
- creates: "/tmp/release"
- remote_src: yes
- notify: restart pleroma instance
-
-- name: install pleroma release
- become: yes
- copy:
- remote_src: true
- src: "/tmp/release/"
- dest: "/opt/pleroma/"
- owner: "pleroma"
- group: "pleroma"
- changed_when: false
-
-- include_tasks: soapbox.yaml
- when: pleroma_soapbox
-
- name: configure pleroma systemd service
become: yes
copy:
@@ -87,16 +26,11 @@
dest: "/lib/systemd/system/[email protected]"
notify: restart pleroma instance
-- name: ensure pleroma instance is enabled and started
- become: yes
- systemd: name="pleroma@{{pleroma_instance}}.service" enabled="yes" state="started"
+- name: check if pleroma release exists
+ stat: path="/tmp/release/"
+ register: release
-- name: migrate db
- become: yes
- become_user: "pleroma"
- command: "/opt/pleroma/bin/pleroma_ctl migrate"
- args:
- chdir: "/opt/pleroma/"
- environment:
- PLEROMA_CONFIG_PATH: "/etc/pleroma/{{pleroma_instance}}.config.exs"
- changed_when: false
+- include_tasks: install.yaml
+ when: not release.stat.exists
+
+- include_tasks: instance.yaml