# HG changeset patch # User Luke Hoersten # Date 1689894464 18000 # Node ID 3069b7d001f73613ae7e874c898df5ece0ededab # Parent 245f2e0933985d81a718ab53cfb90aa7f02dbe49 Added nostr relayer role. diff -r 245f2e093398 -r 3069b7d001f7 relayer/defaults/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relayer/defaults/main.yaml Thu Jul 20 18:07:44 2023 -0500 @@ -0,0 +1,9 @@ +--- + +# https://github.com/fiatjaf/relayer/releases +relayer_user: "relayer" +relayer_pubkey: "" +relayer_port: "7447" +relayer_db: "relayer" +relayer_db_user: "relayer" +relayer_db_pass: "relayer" diff -r 245f2e093398 -r 3069b7d001f7 relayer/files/relayer.service --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relayer/files/relayer.service Thu Jul 20 18:07:44 2023 -0500 @@ -0,0 +1,14 @@ +[Unit] +Description=relayer nostr relay +Requires=network.target postgresql.service +Before=nginx.service + +[Service] +User=relayer +EnvironmentFile=/etc/relayer/relayer.env + +ExecStart=/usr/local/bin/relayer +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff -r 245f2e093398 -r 3069b7d001f7 relayer/handlers/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relayer/handlers/main.yaml Thu Jul 20 18:07:44 2023 -0500 @@ -0,0 +1,5 @@ +--- + +- name: restart relayer service + become: yes + systemd: name="relayer.service" state="restarted" daemon_reload="yes" diff -r 245f2e093398 -r 3069b7d001f7 relayer/tasks/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relayer/tasks/main.yaml Thu Jul 20 18:07:44 2023 -0500 @@ -0,0 +1,60 @@ +--- + +- name: add relayer user + become: yes + user: name="{{relayer_user}}" shell="/bin/false" create_home="false" system="yes" + +- name: install relayer systemd service + become: yes + copy: + src: "relayer.service" + dest: "/lib/systemd/system/relayer.service" + notify: restart relayer service + +- name: install relayer bin + become: yes + copy: + src: "whitelisted" + dest: "/usr/local/bin/relayer" + owner: "root" + group: "root" + mode: "0755" + notify: restart relayer service + +- name: create relayer dirs + become: yes + file: + path: "/etc/relayer" + owner: "root" + group: "root" + mode: "0755" + state: "directory" + +- name: install relayer config + become: yes + template: + src: "relayer.env.j2" + dest: "/etc/relayer/relayer.env" + owner: "root" + group: "root" + mode: "0600" + notify: restart relayer service + +- name: copy db schema file + become: yes + template: + src: "setup_db.psql.j2" + dest: "/tmp/setup_db_relayer.psql" + owner: "postgres" + group: "postgres" + mode: "0600" + +- name: install db schema psql + become: yes + become_user: "postgres" + command: "psql -f /tmp/setup_db_relayer.psql" + changed_when: false + +- name: ensure service is started + become: yes + systemd: name="relayer.service" enabled="yes" state="started" diff -r 245f2e093398 -r 3069b7d001f7 relayer/templates/relayer.env.j2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relayer/templates/relayer.env.j2 Thu Jul 20 18:07:44 2023 -0500 @@ -0,0 +1,4 @@ +POSTGRESQL_DATABASE=postgres://{{relayer_db_user}}:{{relayer_db_pass}}@localhost:5432/{{relayer_db}} +WHITELIST={{relayer_pubkey}} +HOST=127.0.0.1 +PORT={{relayer_port}} diff -r 245f2e093398 -r 3069b7d001f7 relayer/templates/setup_db.psql.j2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relayer/templates/setup_db.psql.j2 Thu Jul 20 18:07:44 2023 -0500 @@ -0,0 +1,2 @@ +CREATE USER {{relayer_db_user}} WITH ENCRYPTED PASSWORD '{{relayer_db_pass}}'; +CREATE DATABASE {{relayer_db}} WITH OWNER {{relayer_db_user}};