diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/audit-production.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/audit-production.yml index 1e4aa6f..70cc96e 100644 --- a/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/audit-production.yml +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/audit-production.yml @@ -136,21 +136,29 @@ - name: Read the litecoind network state via the read-only wrapper become: false - ansible.builtin.command: - argv: [/usr/bin/sudo, -n, /usr/local/bin/ltc-readonly, getnetworkinfo] + ansible.builtin.shell: | + /usr/bin/sudo -n /usr/local/bin/ltc-readonly getnetworkinfo | /usr/bin/python3 -c ' + import json, sys + data = json.load(sys.stdin) + reach = {n["name"]: n.get("reachable") for n in data["networks"]} + print("network reachability:", reach) + if reach.get("onion") is not True: + sys.exit("onion network is not reachable") + if reach.get("ipv4") is True or reach.get("ipv6") is True: + sys.exit("clearnet network is reachable; expected onion-only") + ' + args: + executable: /bin/bash check_mode: false changed_when: false register: litecoin_audit_networkinfo - when: not ansible_check_mode + when: + - not ansible_check_mode + - litecoin_service_start_allowed | bool - - name: Require onion-only networking when the node is running - ansible.builtin.assert: - that: - - >- - '"onion"' in litecoin_audit_networkinfo.stdout - - >- - litecoin_audit_networkinfo.stdout is not - search('"name": "(ipv4|ipv6)"') + - name: Report the onion-only network state + ansible.builtin.debug: + msg: "{{ litecoin_audit_networkinfo.stdout | default('check mode or node stopped: skipped') }}" when: - not ansible_check_mode - litecoin_service_start_allowed | bool