Skip to content

Commit 320bdad

Browse files
authored
fix: handle private IP detection and make dashmon optional (#744)
1 parent 43af15b commit 320bdad

4 files changed

Lines changed: 32 additions & 4 deletions

File tree

ansible/roles/dashd/defaults/main.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ dashd_externalip: '{{ public_ip }}'
1111
dashd_private_net_prefix: 16
1212
dashd_private_cidr: '{{ private_ip | ansible.utils.ipsubnet(dashd_private_net_prefix) }}'
1313

14-
# When running devnet/regtest in local networks, we have to allow RFC1918/private addresses
15-
dashd_allowprivatenet: '{% if dashd_externalip | ansible.utils.ipaddr("private") == dashd_externalip %}1{% else %}0{% endif %}'
14+
# When running devnet/regtest in local networks, we have to allow RFC1918/private addresses.
15+
# Avoid ansible.utils.ipaddr("private") here because some runner/library combinations
16+
# return netaddr objects that do not expose the expected is_private attribute.
17+
dashd_allowprivatenet: >-
18+
{% if dashd_externalip is match('^(10\\.|127\\.|169\\.254\\.|192\\.168\\.|172\\.(1[6-9]|2[0-9]|3[0-1])\\.)') %}
19+
1
20+
{% else %}
21+
0
22+
{% endif %}
1623
1724
dashd_compose_project_name: dashcore
1825
dashd_compose_path: '{{ dashd_home }}/{{ dashd_compose_project_name }}'

ansible/roles/dashmate/tasks/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@
257257

258258
- name: Set dashmate config version from already extracted version
259259
ansible.builtin.set_fact:
260-
dashmate_config_version: "{{ installed_dashmate_version }}"
260+
dashmate_config_version: >-
261+
{{ dashmate_version if installed_dashmate_version == 'none' else installed_dashmate_version }}
261262
262263
# This check will return an error code if config is missing, config schema is invalid or default config is not yet set
263264
- name: Check state of dashmate config

ansible/roles/status_dashboard/defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
status_dashboard_image: dashpay/status:latest
44
status_dashboard_port: 3010
55
status_dashboard_path: "{{ dashd_home }}/status_dashboard"
6-
status_dashboard_ssh_private_key_path: "{{ lookup('env', 'STATUS_DASHBOARD_SSH_KEY_PATH') | default('~/.ssh/dashmon-testnet', true) }}"
6+
status_dashboard_ssh_private_key_path: "{{ lookup('env', 'STATUS_DASHBOARD_SSH_KEY_PATH') | default(lookup('env', 'HOME') + '/.ssh/dashmon-testnet', true) }}"
77
status_dashboard_ssh_user: dashmon
88
status_dashboard_poll_interval: 10000
99
status_dashboard_poll_concurrency: 20

ansible/roles/status_dashboard/tasks/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
---
22

3+
- name: Check status dashboard SSH key on controller
4+
ansible.builtin.stat:
5+
path: "{{ status_dashboard_ssh_private_key_path }}"
6+
register: status_dashboard_ssh_key_stat
7+
delegate_to: localhost
8+
become: false
9+
10+
- name: Skip status dashboard when controller SSH key is missing
11+
ansible.builtin.debug:
12+
msg: >-
13+
Skipping status dashboard because SSH monitoring key was not found at
14+
{{ status_dashboard_ssh_private_key_path }}.
15+
Set STATUS_DASHBOARD_SSH_KEY_PATH on the controller to enable it.
16+
when: not status_dashboard_ssh_key_stat.stat.exists
17+
318
- name: Create status dashboard directory
419
ansible.builtin.file:
520
path: "{{ status_dashboard_path }}"
621
state: directory
722
recurse: true
23+
when: status_dashboard_ssh_key_stat.stat.exists
824

925
- name: Copy inventory file for status dashboard
1026
ansible.builtin.copy:
1127
src: "{{ inventory_file }}"
1228
dest: "{{ status_dashboard_path }}/inventory"
1329
mode: "0644"
30+
when: status_dashboard_ssh_key_stat.stat.exists
1431

1532
- name: Copy SSH monitoring key for status dashboard
1633
ansible.builtin.copy:
@@ -20,16 +37,19 @@
2037
owner: root
2138
group: root
2239
no_log: true
40+
when: status_dashboard_ssh_key_stat.stat.exists
2341

2442
- name: Deploy status dashboard docker-compose
2543
ansible.builtin.template:
2644
src: docker-compose.yml.j2
2745
dest: "{{ status_dashboard_path }}/docker-compose.yml"
2846
mode: "0644"
47+
when: status_dashboard_ssh_key_stat.stat.exists
2948

3049
- name: Start status dashboard
3150
community.docker.docker_compose_v2:
3251
project_src: "{{ status_dashboard_path }}"
3352
state: present
3453
pull: "{{ 'always' if (force_dashmate_reinstall | default(false) or not (skip_dashmate_image_update | default(false))) else 'policy' }}"
3554
recreate: "{{ 'always' if (force_dashmate_rebuild | default(false)) else 'auto' }}"
55+
when: status_dashboard_ssh_key_stat.stat.exists

0 commit comments

Comments
 (0)