nostr/relayer/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sun, 21 Jul 2024 12:42:43 -0500
changeset 235 f88bb54f63bd
parent 217 e69a030975c4
child 237 c6c11084c802
permissions -rw-r--r--
Added scrypted role.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
214
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     1
---
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     2
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     3
- name: add relayer user
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     4
  become: yes
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     5
  user: name="{{relayer_user}}" shell="/bin/false" create_home="false" system="yes"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     6
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     7
- name: install relayer systemd service
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     8
  become: yes
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     9
  copy:
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    10
    src: "relayer.service"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    11
    dest: "/lib/systemd/system/relayer.service"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    12
  notify: restart relayer service
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    13
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    14
- name: install relayer bin
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    15
  become: yes
217
e69a030975c4 Split out nostr install and build roles.
Luke Hoersten <luke@hoersten.org>
parents: 214
diff changeset
    16
  get_url:
e69a030975c4 Split out nostr install and build roles.
Luke Hoersten <luke@hoersten.org>
parents: 214
diff changeset
    17
    url: "{{relayer_bin_url}}"
214
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    18
    dest: "/usr/local/bin/relayer"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    19
    owner: "root"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    20
    group: "root"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    21
    mode: "0755"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    22
  notify: restart relayer service
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    23
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    24
- name: create relayer dirs
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    25
  become: yes
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    26
  file:
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    27
    path: "/etc/relayer"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    28
    owner: "root"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    29
    group: "root"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    30
    mode: "0755"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    31
    state: "directory"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    32
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    33
- name: install relayer config
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    34
  become: yes
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    35
  template:
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    36
    src: "relayer.env.j2"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    37
    dest: "/etc/relayer/relayer.env"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    38
    owner: "root"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    39
    group: "root"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    40
    mode: "0600"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    41
  notify: restart relayer service
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    42
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    43
- name: copy db schema file
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    44
  become: yes
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    45
  template:
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    46
    src: "setup_db.psql.j2"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    47
    dest: "/tmp/setup_db_relayer.psql"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    48
    owner: "postgres"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    49
    group: "postgres"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    50
    mode: "0600"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    51
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    52
- name: install db schema psql
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    53
  become: yes
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    54
  become_user: "postgres"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    55
  command: "psql -f /tmp/setup_db_relayer.psql"
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    56
  changed_when: false
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    57
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    58
- name: ensure service is started
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    59
  become: yes
3069b7d001f7 Added nostr relayer role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    60
  systemd: name="relayer.service" enabled="yes" state="started"