# HG changeset patch # User Luke Hoersten # Date 1579469588 21600 # Node ID dcfd23308c32be15702ca9dcc917fa472a60f5b0 # Parent d0c40727e6ff1011486720fbf4dba9beea92ee82 Completed pleroma-otp role. diff -r d0c40727e6ff -r dcfd23308c32 roles/pleroma-otp/defaults/main.yaml --- a/roles/pleroma-otp/defaults/main.yaml Sun Jan 19 13:41:08 2020 -0600 +++ b/roles/pleroma-otp/defaults/main.yaml Sun Jan 19 15:33:08 2020 -0600 @@ -23,8 +23,8 @@ - "unzip" pleroma_branch: "stable" -pleroma_flavor: "arm" +pleroma_download_url: "https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/{{pleroma_branch}}/download?job={{pleroma_flavor}}" -pleroma_db: "{{pleroma_instance}}" -pleroma_db_user: "{{pleroma_instance}}" +pleroma_db: "pleroma_{{pleroma_instance}}" +pleroma_db_user: "pleroma_{{pleroma_instance}}" pleroma_data_dir: "/var/lib/pleroma/instance_data" diff -r d0c40727e6ff -r dcfd23308c32 roles/pleroma-otp/files/pleroma@.service --- a/roles/pleroma-otp/files/pleroma@.service Sun Jan 19 13:41:08 2020 -0600 +++ b/roles/pleroma-otp/files/pleroma@.service Sun Jan 19 15:33:08 2020 -0600 @@ -1,6 +1,6 @@ [Unit] -Description=Pleroma social network instance %I -After=network.target postgresql.service +Description=Pleroma social network instance "%I" +After=network.target postgresql.service nginx.service [Service] User=pleroma @@ -12,6 +12,7 @@ ExecStart=/opt/pleroma/bin/pleroma daemon ExecReload=/opt/pleroma/bin/pleroma stop + KillMode=process Restart=on-failure @@ -19,7 +20,7 @@ ; Use private /tmp and /var/tmp folders inside a new file system namespace, which are discarded after the process stops. PrivateTmp=true ; The /home, /root, and /run/user folders can not be accessed by this service anymore. If your Pleroma user has its home folder in one of the restricted places, or use one of these folders as its working directory, you have to set this to false. -ProtectHome=false +ProtectHome=true ; Mount /usr, /boot, and /etc as read-only for processes invoked by this service. ProtectSystem=full ; Sets up a new /dev mount for the process and only adds API pseudo devices like /dev/null, /dev/zero or /dev/random but not physical devices. Disabled by default because it may not work on devices like the Raspberry Pi. diff -r d0c40727e6ff -r dcfd23308c32 roles/pleroma-otp/handlers/main.yaml --- a/roles/pleroma-otp/handlers/main.yaml Sun Jan 19 13:41:08 2020 -0600 +++ b/roles/pleroma-otp/handlers/main.yaml Sun Jan 19 15:33:08 2020 -0600 @@ -1,5 +1,5 @@ --- -- name: "restart pleroma {{pleroma_instance}} instance" +- name: restart pleroma instance become: yes - systemd: name="pleroma@{{pleroma_instance}}" state="restarted" daemon_reload="yes" + systemd: name="pleroma@{{pleroma_instance}}.service" state="restarted" daemon_reload="yes" diff -r d0c40727e6ff -r dcfd23308c32 roles/pleroma-otp/tasks/main.yaml --- a/roles/pleroma-otp/tasks/main.yaml Sun Jan 19 13:41:08 2020 -0600 +++ b/roles/pleroma-otp/tasks/main.yaml Sun Jan 19 15:33:08 2020 -0600 @@ -17,14 +17,17 @@ with_items: - "{{pleroma_data_dir}}" - "/etc/pleroma" + - "/opt/pleroma" - name: install pleroma config template: src: "config.exs.j2" dest: "/etc/pleroma/{{pleroma_instance}}.config.exs" - mode: "0700" + owner: "pleroma" + group: "pleroma" + mode: "0600" become: yes - notify: "restart pleroma {{pleroma_instance}} instance" + notify: restart pleroma instance - name: create instance data directory become: yes @@ -40,74 +43,59 @@ - "{{pleroma_data_dir}}/{{pleroma_instance}}/static" - "{{pleroma_data_dir}}/{{pleroma_instance}}/static/emoji" -# Set config path in systemd: PLEROMA_CONFIG_PATH - -# - name: install pleroma db schema file -# template: -# src: "setup_db.psql.j2" -# dest: "/tmp/setup_db.psql" -# owner: "{{pleroma_db_superuser}}" -# group: "{{pleroma_db_superuser}}" -# mode: "0700" -# become: yes +- name: install pleroma db schema file + template: + src: "setup_db.psql.j2" + dest: "/tmp/setup_db.psql" + owner: "{{pleroma_db_superuser}}" + group: "{{pleroma_db_superuser}}" + mode: "0600" + become: yes -# - name: install pleroma psql -# become: yes -# become_user: "{{pleroma_db_superuser}}" -# command: "psql -f /tmp/setup_db.psql" -# notify: restart pleroma - - - - - -# MIGERATION -# mv ~pleroma/uploads/* /var/lib/pleroma/uploads -# mv ~pleroma/instance/static /var/lib/pleroma/static -# mv ~pleroma/priv/static/emoji /var/lib/pleroma/static/emoji -# mv ~pleroma/config/prod.secret.exs /etc/pleroma/config.exs -# Change `use Mix.Config` at the top to `import Config` -# rm -r ~pleroma/* - +- name: install pleroma psql + become: yes + become_user: "{{pleroma_db_superuser}}" + command: "psql -f /tmp/setup_db.psql" + notify: restart pleroma instance - name: download and unarchive pleroma release become: yes unarchive: - src: "https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/{{pleroma_branch}}/download?job={{pleroma_flavor}}" + src: "{{pleroma_download_url}}" dest: "/tmp/" remote_src: yes creates: "/tmp/release" - notify: "restart pleroma {{pleroma_instance}} instance" + notify: restart pleroma instance - name: install pleroma release become: yes - copy: remote_src="True" src="/tmp/release/" dest="/opt/pleroma/" - -# - name: Remove old files foo -# file: path="/path/to/foo" state="absent" + copy: remote_src="True" src="/tmp/release/" dest="/opt/pleroma/" owner="pleroma" group="pleroma" + notify: restart pleroma instance -# *** -# mv /tmp/release/* ~pleroma/ - - -# Copy the service into a proper directory -# cp ~pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service - -# - name: "configure pleroma systemd service" +# - name: remove tmp release folder # become: yes -# copy: -# src: "pleroma@.service" -# dest: "/lib/systemd/system/pleroma@.service" -# notify: "restart pleroma {{pleroma_instance}} instance" +# file: path="{{item}}" state="absent" +# with_items: +# - "/tmp/setup_db.psql" +# - "/tmp/release/" + +- name: "configure pleroma systemd service" + become: yes + copy: + src: "pleroma@.service" + dest: "/lib/systemd/system/pleroma@.service" + notify: restart pleroma instance -# - name: "ensure pleroma {{pleroma_instance}} instance is enabled and started" -# become: yes -# systemd: name="pleroma@{{pleroma_instance}}" enabled="yes" state="started" +- name: "ensure pleroma {{pleroma_instance}} 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/" -# notify: restart pleroma +- 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" + notify: restart pleroma instance diff -r d0c40727e6ff -r dcfd23308c32 roles/pleroma-otp/templates/config.exs.j2 --- a/roles/pleroma-otp/templates/config.exs.j2 Sun Jan 19 13:41:08 2020 -0600 +++ b/roles/pleroma-otp/templates/config.exs.j2 Sun Jan 19 15:33:08 2020 -0600 @@ -1,4 +1,4 @@ -use Mix.Config +import Config config :pleroma, Pleroma.Web.Endpoint, url: [host: "{{pleroma_link_host}}", scheme: "{{pleroma_link_scheme}}", port: {{pleroma_link_port}}], @@ -17,14 +17,15 @@ email: "{{pleroma_admin_email}}", limit: {{pleroma_char_limit}}, registrations_open: {{pleroma_signup_open}}, - invites_enabled: {{pleroma_invites_enabled}} + invites_enabled: {{pleroma_invites_enabled}}, + static_dir: "{{pleroma_data_dir}}/{{pleroma_instance}}/static/" config :pleroma, Pleroma.Upload, uploader: Pleroma.Uploaders.Local, filters: [Pleroma.Upload.Filter.Dedupe] config :pleroma, Pleroma.Uploaders.Local, - uploads: "{{pleroma_data_dir}}/{{pleroma_instance}}/" + uploads: "{{pleroma_data_dir}}/{{pleroma_instance}}/uploads/" config :pleroma, :media_proxy, enabled: false,