130 lines
4.2 KiB
YAML
130 lines
4.2 KiB
YAML
|
|
---
|
||
|
|
# Install the prebuilt xmrblocks artifact produced by scripts/build-xmrblocks.sh.
|
||
|
|
#
|
||
|
|
# The verification happens on the CONTROL NODE, before a single byte is copied.
|
||
|
|
# Shipping a binary to a host and checking it afterwards is not verification,
|
||
|
|
# it is an apology.
|
||
|
|
|
||
|
|
- name: Assert the artifact checksum is pinned
|
||
|
|
ansible.builtin.assert:
|
||
|
|
that:
|
||
|
|
- xmrblocks_sha256 | length == 64
|
||
|
|
quiet: true
|
||
|
|
fail_msg: >-
|
||
|
|
xmrblocks_sha256 is not set. Build the artifact with
|
||
|
|
scripts/build-xmrblocks.sh and pin the sha it prints, so this role cannot
|
||
|
|
ship a binary nobody has checked.
|
||
|
|
|
||
|
|
- name: Check the artifact on the control node
|
||
|
|
ansible.builtin.stat:
|
||
|
|
path: "{{ xmrblocks_artifact_dir }}/xmrblocks"
|
||
|
|
checksum_algorithm: sha256
|
||
|
|
get_checksum: yes
|
||
|
|
delegate_to: localhost
|
||
|
|
become: no
|
||
|
|
register: xmrblocks_local
|
||
|
|
changed_when: false
|
||
|
|
|
||
|
|
- name: Assert the artifact exists and matches the pinned checksum
|
||
|
|
ansible.builtin.assert:
|
||
|
|
that:
|
||
|
|
- xmrblocks_local.stat.exists
|
||
|
|
- xmrblocks_local.stat.checksum == xmrblocks_sha256
|
||
|
|
quiet: true
|
||
|
|
fail_msg: >-
|
||
|
|
{{ xmrblocks_artifact_dir }}/xmrblocks is
|
||
|
|
{{ 'missing - run scripts/build-xmrblocks.sh'
|
||
|
|
if not xmrblocks_local.stat.exists
|
||
|
|
else 'sha256 ' ~ xmrblocks_local.stat.checksum ~ ', expected ' ~ xmrblocks_sha256 }}
|
||
|
|
|
||
|
|
- name: Check the templates directory on the control node
|
||
|
|
ansible.builtin.stat:
|
||
|
|
path: "{{ xmrblocks_artifact_dir }}/templates/index.html"
|
||
|
|
delegate_to: localhost
|
||
|
|
become: no
|
||
|
|
register: xmrblocks_local_templates
|
||
|
|
changed_when: false
|
||
|
|
|
||
|
|
# The binary resolves TMPL_DIR as "./templates" at request time, so a missing
|
||
|
|
# templates directory is not a startup error - it is a 500 on the first page
|
||
|
|
# view. Catch it here instead.
|
||
|
|
- name: Assert the templates came with the artifact
|
||
|
|
ansible.builtin.assert:
|
||
|
|
that:
|
||
|
|
- xmrblocks_local_templates.stat.exists
|
||
|
|
quiet: true
|
||
|
|
fail_msg: "{{ xmrblocks_artifact_dir }}/templates/index.html is missing - the artifact is incomplete"
|
||
|
|
|
||
|
|
- name: Install the runtime shared libraries xmrblocks needs
|
||
|
|
apt:
|
||
|
|
name:
|
||
|
|
# From `objdump -p xmrblocks | grep NEEDED`. Boost is version-locked to
|
||
|
|
# the build image's Debian release; monerod-box is Debian 13 and the
|
||
|
|
# artifact is built in debian:13, so 1.83 matches on both sides.
|
||
|
|
- libboost-chrono1.83.0
|
||
|
|
- libboost-filesystem1.83.0
|
||
|
|
- libboost-program-options1.83.0
|
||
|
|
- libboost-serialization1.83.0
|
||
|
|
- libboost-thread1.83.0
|
||
|
|
- libhidapi-libusb0
|
||
|
|
- libunbound8
|
||
|
|
- libunwind8
|
||
|
|
state: present
|
||
|
|
update_cache: yes
|
||
|
|
|
||
|
|
- name: Create the xmrblocks directory
|
||
|
|
ansible.builtin.file:
|
||
|
|
path: "{{ xmrblocks_dir }}"
|
||
|
|
state: directory
|
||
|
|
owner: root
|
||
|
|
group: root
|
||
|
|
mode: '0755'
|
||
|
|
|
||
|
|
- name: Install the xmrblocks binary
|
||
|
|
ansible.builtin.copy:
|
||
|
|
src: "{{ xmrblocks_artifact_dir }}/xmrblocks"
|
||
|
|
dest: "{{ xmrblocks_dir }}/xmrblocks"
|
||
|
|
owner: root
|
||
|
|
group: root
|
||
|
|
mode: '0755'
|
||
|
|
notify: Restart xmrblocks
|
||
|
|
|
||
|
|
- name: Install the xmrblocks templates
|
||
|
|
ansible.builtin.copy:
|
||
|
|
src: "{{ xmrblocks_artifact_dir }}/templates/"
|
||
|
|
dest: "{{ xmrblocks_dir }}/templates/"
|
||
|
|
owner: root
|
||
|
|
group: root
|
||
|
|
mode: '0644'
|
||
|
|
directory_mode: '0755'
|
||
|
|
notify: Restart xmrblocks
|
||
|
|
|
||
|
|
- name: Record which build is deployed
|
||
|
|
ansible.builtin.copy:
|
||
|
|
src: "{{ xmrblocks_artifact_dir }}/MANIFEST"
|
||
|
|
dest: "{{ xmrblocks_dir }}/MANIFEST"
|
||
|
|
owner: root
|
||
|
|
group: root
|
||
|
|
mode: '0644'
|
||
|
|
|
||
|
|
- name: Assert the blockchain database is where we think it is
|
||
|
|
ansible.builtin.stat:
|
||
|
|
path: "{{ xmrblocks_bc_path }}/data.mdb"
|
||
|
|
# data.mdb is the whole blockchain - tens of GB and growing. stat computes a
|
||
|
|
# sha1 by DEFAULT, so without these it hashes the entire chain just to answer
|
||
|
|
# "does this file exist", and the play hangs for many minutes.
|
||
|
|
get_checksum: no
|
||
|
|
get_mime: no
|
||
|
|
get_attributes: no
|
||
|
|
register: xmrblocks_lmdb
|
||
|
|
|
||
|
|
- name: Fail if the LMDB is missing
|
||
|
|
ansible.builtin.assert:
|
||
|
|
that:
|
||
|
|
- xmrblocks_lmdb.stat.exists
|
||
|
|
quiet: true
|
||
|
|
fail_msg: >-
|
||
|
|
No LMDB at {{ xmrblocks_bc_path }}/data.mdb. xmrblocks reads monerod's
|
||
|
|
database directly, so it has nothing to serve. Check that monerod is
|
||
|
|
deployed and its data disk is mounted.
|