diff --git a/hosts b/hosts index b49fa59..0282638 100644 --- a/hosts +++ b/hosts @@ -22,7 +22,7 @@ zerotier_network= [n0xb0x:vars] hostname=n0xb0x -app_list=['bitcoin.yml','docs.yml'] +app_list=['bitcoin.yml','electrs.yml','docs.yml'] ansible_user=n0xb0x ansible_password=n0xb0x #registry_url=git.boxxy.net/b0xxer/ @@ -31,6 +31,7 @@ registry_user= registry_pass= bitcoin_version=26.0 bitcoin_rpcpassword=rVhfmriXjB8uFekmn7sLvnUiY610JaOx +electrs_version=0.10.2 zerotier_network= diff --git a/roles/apps/handlers/main.yml b/roles/apps/handlers/main.yml index 6a7bfb8..1c1dcff 100644 --- a/roles/apps/handlers/main.yml +++ b/roles/apps/handlers/main.yml @@ -6,6 +6,11 @@ chdir: ~/Containers/bitcoin cmd: ./build.sh +- name: rebuild_electrs + ansible.builtin.shell: + chdir: ~/Containers/electrs + cmd: ./build.sh + - name: rebuild_docs ansible.builtin.shell: chdir: ~/Containers/docs diff --git a/roles/apps/tasks/electrs.yml b/roles/apps/tasks/electrs.yml new file mode 100644 index 0000000..9b19036 --- /dev/null +++ b/roles/apps/tasks/electrs.yml @@ -0,0 +1,30 @@ +--- +# tasks file for build +# +- name: electrs - Copy electrs-node.container file + ansible.builtin.template: + src: electrs/electrs-node.container.j2 + dest: /home/{{ ansible_user }}/.config/containers/systemd/electrs-node.container + notify: reload_systemctl + +- name: electrs - Create Containers/bitcoin Dir + ansible.builtin.file: + path: ~/Containers/electrs + recurse: true + state: directory + notify: rebuild_electrs + +- name: electrs - Copy Containerfile Template + ansible.builtin.template: + src: electrs/Containerfile.j2 + dest: ~/Containers/electrs/Containerfile + notify: rebuild_electrs + +- name: electrs - Copy build script + ansible.builtin.template: + src: electrs/build.sh.j2 + dest: ~/Containers/electrs/build.sh + mode: '0700' + notify: rebuild_electrs + + diff --git a/podman/electrs/Containerfile b/roles/apps/templates/electrs/Containerfile.j2 similarity index 86% rename from podman/electrs/Containerfile rename to roles/apps/templates/electrs/Containerfile.j2 index 6c6a02f..4b5513a 100644 --- a/podman/electrs/Containerfile +++ b/roles/apps/templates/electrs/Containerfile.j2 @@ -2,9 +2,9 @@ #FROM rust:1.44.1-slim-buster AS builder -FROM almalinux/9-base as builder +FROM docker.io/almalinux/9-base:latest as builder -ARG VERSION=v0.10.2 +ARG VERSION=v{{ electrs_version }} ENV REPO=https://github.com/romanz/electrs.git WORKDIR /build @@ -19,7 +19,7 @@ RUN cargo build --release --bin electrs #FROM debian:buster-slim -FROM almalinux/9-minimal +FROM docker.io/almalinux/9-minimal:latest RUN microdnf update -y && microdnf clean all diff --git a/podman/electrs/build.sh b/roles/apps/templates/electrs/build.sh.j2 similarity index 83% rename from podman/electrs/build.sh rename to roles/apps/templates/electrs/build.sh.j2 index 11f15d8..91c65cc 100755 --- a/podman/electrs/build.sh +++ b/roles/apps/templates/electrs/build.sh.j2 @@ -1,6 +1,6 @@ #!/bin/sh #Build command to make container -VER=0.10.2 +VER={{electrs_version}} buildah build -t electrs:$VER --build-arg VERSION=v$VER -f Containerfile diff --git a/roles/apps/templates/electrs/electrs-node.container.j2 b/roles/apps/templates/electrs/electrs-node.container.j2 new file mode 100644 index 0000000..86e2a94 --- /dev/null +++ b/roles/apps/templates/electrs/electrs-node.container.j2 @@ -0,0 +1,21 @@ +[Unit] +Description=Electrs Server + +[Container] +Image={{ registry_url }}/electrs:{{ electrs_version }} +PodmanArgs=--pod bitcoin-pod + +# Use volume +Volume=/home/{{ansible_user}}/.bitcoin:/bitcoin/.bitcoin:Z + +[Service] +# Restart service when sleep finishes +Restart=always +# Extend Timeout to allow time to pull the image +TimeoutStartSec=900 +# ExecStartPre flag and other systemd commands can go here, see systemd.unit(5) man page. +# ExecStartPre=/usr/share/mincontainer/setup.sh + +[Install] +# Start by default on boot +WantedBy=multi-user.target default.target