Skip to content

Commit

Permalink
refactor: update Penumbra service configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Catopish committed Dec 25, 2024
1 parent 92c8136 commit 491f98b
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 33 deletions.
1 change: 0 additions & 1 deletion bkk07
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ polkadot
hydration
cumulus
penumbra
misc-container

[prometheus]
ibp-bkk07
Expand Down
2 changes: 1 addition & 1 deletion group_vars/penumbra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ penumbra_download_pcli_url: "https://github.com/penumbra-zone/penumbra/releases/
penumbra_download_pd_url: "https://github.com/penumbra-zone/penumbra/releases/download/v{{ penumbra_version }}/pd-installer.sh"
penumbra_download_pclientd_url: "https://github.com/penumbra-zone/penumbra/releases/download/v{{ penumbra_version }}/pclientd-installer.sh"
cometbft_download_url: "https://github.com/cometbft/cometbft/releases/download/v{{ cometbft_version }}/cometbft_{{ cometbft_version }}_linux_amd64.tar.gz"
polkachu_download_url: "wget -O penumbra_{{ polkachu_version }}.tar.lz4 https://snapshots.polkachu.com/snapshots/penumbra/penumbra_{{ polkachu_version }}.tar.lz4 --inet4-only"
#polkachu_download_cmd: "wget -O penumbra_{{ polkachu_version }}.tar.lz4 https://snapshots.polkachu.com/snapshots/penumbra/penumbra_{{ polkachu_version }}.tar.lz4 --inet4-only"

# service/user
default_service: "penumbra"
Expand Down
54 changes: 39 additions & 15 deletions roles/setup_install_penumbra/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
---
- name: Stop Penumbra
ansible.builtin.systemd:
name: pd
state: stopped
enabled: True

- name: Stop Cometbft
ansible.builtin.systemd:
name: cometbft
state: stopped
enabled: True

- name: Symlink cometbft & pd service to systemd
- name: Symlink cometbft & validator service to systemd
ansible.builtin.file:
src: "{{ default_home_path }}/{{ item }}.service"
dest: "/etc/systemd/system/{{ item }}.service"
Expand All @@ -21,9 +9,21 @@
group: "root"
mode: "0644"
loop:
- pd
- validator
- cometbft

- name: Stop Penumbra
ansible.builtin.systemd:
name: validator
state: stopped
enabled: True

- name: Stop Cometbft
ansible.builtin.systemd:
name: cometbft
state: stopped
enabled: True

- name: Systemd daemon-reload
ansible.builtin.systemd:
daemon_reload: True
Expand All @@ -36,9 +36,33 @@

- name: Start Penumbra
ansible.builtin.systemd:
name: pd
name: validator
state: started
enabled: True

- name: Add type of service fact
ansible.builtin.lineinfile:
path: /etc/ansible/facts.d/noderole.fact
regexp: "^type="
line: "type={{ default_node_type }}"
create: True
mode: "0644"

- name: Add Penumbra service version
ansible.builtin.lineinfile:
path: /etc/ansible/facts.d/noderole.fact
regexp: "^version="
line: "version={{ penumbra_version }}"
create: True
mode: "0644"

- name: Add Service Pinned Status
ansible.builtin.lineinfile:
path: /etc/ansible/facts.d/noderole.fact
regexp: "^pinned="
line: "pinned=False"
create: True
mode: "0644"

- name: Flush Handlers
ansible.builtin.meta: flush_handlers
77 changes: 61 additions & 16 deletions roles/setup_install_penumbra/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@
- name: Unpack cometbft
ansible.builtin.unarchive:
src: "{{ default_home_path }}/tmp/cometbft_{{ cometbft_version }}_linux_amd64.tar.gz"
dest: "{{ default_home_path }}"
dest: "{{ default_home_path }}/tmp"
remote_src: True
owner: "{{ default_user }}"
group: "{{ default_user }}"
mode: "u+r+x"
when: ansible_local['noderole']['node']['version'] != cometbft_version

- name: Create soft links for penumbra binaries
- name: Create soft links for penumbra & cometbft binaries
ansible.builtin.file:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
Expand All @@ -101,6 +101,8 @@
dest: "{{ default_home_path }}/pcli"
- src: "{{ default_home_path }}/.cargo/bin/pclientd"
dest: "{{ default_home_path }}/pclientd"
- src: "{{ default_home_path }}/tmp/cometbft"
dest: "{{ default_home_path }}/cometbft"

- name: Install lz4 package
ansible.builtin.package:
Expand All @@ -124,13 +126,14 @@
when: not cometbft_dir.stat.exists

- name: Download Polkachu Cometbft snapshot
ansible.builtin.get_url:
url: "{{ polkachu_download_url }}"
dest: "{{ default_database_path }}/node0/"
mode: "u+r+x"
owner: "{{ default_user }}"
group: "{{ default_user }}"
ansible.builtin.shell:
cmd: "wget -O {{ default_database_path }}/node0/penumbra_{{ polkachu_version }}.tar.lz4 https://snapshots.polkachu.com/snapshots/penumbra/penumbra_{{ polkachu_version }}.tar.lz4 --inet4-only"
become: True
become_user: "{{ default_user }}"
when: not cometbft_dir.stat.exists
# when: ansible_local['noderole']['node']['version'] != penumbra_version
args:
executable: /bin/bash

- name: Extract and decompress Polkachu snapshot
ansible.builtin.shell:
Expand All @@ -142,11 +145,19 @@
become_user: "{{ default_user }}"
when: not cometbft_dir.stat.exists

- name: Remove lz4 archive after decompression
# NOTE: i still commented this out cause its58GB file and still for experimenting in case something wrong
# - name: Remove lz4 archive after decompression
# ansible.builtin.file:
# path: "{{ default_database_path }}/node0/penumbra_{{ polkachu_version }}.tar.lz4"
# state: absent
# when: not cometbft_dir.stat.exists
- name: Ensure cometbft config directory exists
ansible.builtin.file:
path: "{{ default_database_path }}/node0/penumbra_{{ polkachu_version }}.tar.lz4"
state: absent
when: not cometbft_dir.stat.exists
path: "{{ default_database_path }}/node0/cometbft/config"
state: directory
mode: "0750"
owner: "{{ default_user }}"
group: "{{ default_user }}"

- name: Download Polkachu's Penumbra address book
ansible.builtin.get_url:
Expand All @@ -168,15 +179,49 @@
force: True
when: not cometbft_dir.stat.exists

- name: Copy Cometbft & pd service templates
- name: Ensure proper ownership of cometbft and pd directories
ansible.builtin.file:
path: "{{ default_database_path }}/node0/{{ item }}"
state: directory
owner: "{{ default_user }}"
group: "{{ default_user }}"
mode: "0750"
recurse: true
loop:
- cometbft
- pd

- name: Flush handlers after service copy
ansible.builtin.meta: flush_handlers

- name: Copy Cometbft & validator service templates
ansible.builtin.template:
src: "{{ item }}.service.j2"
dest: "{{ default_home_path }}/{{ item }}.service"
owner: "{{ default_user }}"
group: "{{ default_user }}"
mode: "0640"
when: default_node_type in ["validator", "bootnode", "endpoint"]
loop:
- pd
- validator
- cometbft
notify:
- Symlink cometbft & validator service to systemd
- Systemd daemon-reload
- Start Cometbft
- Start Penumbra

- name: Symlink cometbft & validator service to systemd
ansible.builtin.file:
src: "{{ default_home_path }}/{{ item }}.service"
dest: "/etc/systemd/system/{{ item }}.service"
state: link
force: True
owner: "root"
group: "root"
mode: "0644"
loop:
- validator
- cometbft

- name: Flush handlers after service copy
Expand All @@ -188,8 +233,8 @@
state: started
enabled: True

- name: Ensure pd service is running
- name: Ensure validator service is running
ansible.builtin.systemd:
name: pd
name: validator
state: started
enabled: True

0 comments on commit 491f98b

Please sign in to comment.