summaryrefslogtreecommitdiff
path: root/roles/radicle_node/tasks/main.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/radicle_node/tasks/main.yml')
-rw-r--r--roles/radicle_node/tasks/main.yml68
1 files changed, 6 insertions, 62 deletions
diff --git a/roles/radicle_node/tasks/main.yml b/roles/radicle_node/tasks/main.yml
index a86a67a..13c49eb 100644
--- a/roles/radicle_node/tasks/main.yml
+++ b/roles/radicle_node/tasks/main.yml
@@ -95,62 +95,15 @@
mode: 0644
- name: "install systemd unit for Radicle node"
- copy:
- content: |
- [Unit]
- Description=Radicle Node
- After=network.target network-online.target
- Requires=network-online.target
-
- [Service]
- User=_rad
- Group=_rad
- ExecStart=/usr/bin/radicle-node --listen 0.0.0.0:8776 --force
- Environment=RAD_HOME=/home/_rad/.radicle RUST_BACKTRACE=1 RUST_LOG=info
- KillMode=process
- Restart=always
- RestartSec=3
-
- [Install]
- WantedBy=multi-user.target
+ template:
+ src: radicle-node.service.j2
dest: /lib/systemd/system/radicle-node.service
- name: "install script to add update Radicle config file"
when: radicle_node_connections is defined
copy:
- content: |
- #!/usr/bin/python3
-
- import json, os, subprocess, sys
-
- alias = sys.argv[1]
- ext = sys.argv[2]
- peer = sys.argv[3]
-
- p = subprocess.run(["rad", "config", "show"], check=True, capture_output=True)
- if p.returncode != 0:
- sys.exit("rad config show failed")
- config = json.loads(p.stdout.decode())
-
- config["node"]["alias"] = alias
- config["node"]["externalAddresses"] = [ext]
- config["node"]["policy"] = "allow"
-
- nodes = config["node"]["connect"]
- if peer not in nodes:
- nodes.append(peer)
-
- p = subprocess.run(["rad", "self", "--home"], check=True, capture_output=True)
- if p.returncode != 0:
- sys.exit("rad self --home failed")
-
- home = p.stdout.decode().strip()
- filename = os.path.join(home, "config.json")
- if os.path.exists(filename):
- os.rename(filename, filename + ".bak")
- with open(filename, "w") as f:
- f.write(json.dumps(config, indent=4))
- dest: /home/_rad/radicle-perma-connect
+ src: rad-config-update
+ dest: /home/_rad/rad-config-update
owner: _rad
group: _rad
mode: 0755
@@ -159,22 +112,13 @@
when: radicle_node_connections is defined
with_items: "{{ radicle_node_connections }}"
shell: |
- cat <<'EOF' > /home/_rad/connect.sh
- export PATH="$HOME/.radicle/bin:$PATH"
- ./radicle-perma-connect "{{ radicle_node_domain_name }}" "{{ radicle_node_domain_name }}:8776" "{{ item.nid }}@{{ item.host }}:{{ item.port }}"
- EOF
- sudo -u _rad -i bash -ex ./connect.sh
+ sudo -u _rad -i ./rad-config-update "{{ radicle_node_domain_name }}" "{{ radicle_node_domain_name }}:8776" "{{ item.nid }}@{{ item.host }}:{{ item.port }}"
- name: "seed Radicle repositories"
when: radicle_node_repositories is defined
with_items: "{{ radicle_node_repositories }}"
shell: |
- cat <<'EOF' > /home/_rad/seed.sh
- export PATH="$HOME/.radicle/bin:$PATH"
- rad node status
- rad seed "{{ item.rid }}"
- EOF
- sudo -u _rad bash -ex /home/_rad/seed.sh
+ sudo -u _rad rad seed "{{ item.rid }}"
- name: "(re)start systemd unit for Radicle node"
systemd: