Deleted specific bitcoin role.

Deleted specific build role.

Moved all to general apps role.

Make app_list list so tasks can iterate thru list and install each app
This commit is contained in:
b0xxer 2024-02-11 08:42:22 -06:00
parent ab1b4fabc9
commit 3ff69e504e
21 changed files with 146 additions and 91 deletions

1
hosts
View File

@ -6,6 +6,7 @@
# Each Server should have a "vars" block like below to set individual settings for each
#
[bitb0x:vars]
app_list=['bitcoin.yml','electrs.yml']
ansible_user=b0xxy
ansible_password=b0xxy
#registry_url=git.boxxy.net/b0xxer/

View File

@ -5,8 +5,7 @@
roles:
- install
- build
- bitcoin
- apps
- config
tasks:

View File

@ -1,6 +1,6 @@
#Based on Dockerflie from Kyle Manna - https://github.com/kylemanna/docker-bitcoind
FROM almalinux/9-minimal AS build
FROM docker.io/almalinux/9-minimal:latest AS build
RUN microdnf update -y \
&& microdnf install -y \
@ -38,7 +38,7 @@ RUN wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/downloa
gpgconf --kill all; \
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc;
FROM almalinux/9-minimal
FROM docker.io/almalinux/9-minimal:latest
LABEL maintainer="b0xxer@b0xxy.net"
ENTRYPOINT ["entrypoint.sh"]

View File

@ -0,0 +1,91 @@
#!/bin/bash
set -ex
mkdir -p $HOME/.bitcoin
if [ -f "$HOME/.bitcoin/bitcoin.conf" ];
then
echo "Backing up bitcoin.conf"
TMPEXT=$(date +%Y.%m.%d.%H.%M.%S)
mv $HOME/.bitcoin/bitcoin.conf $HOME/.bitcoin/bitcoin.conf.bak.$TMPEXT
fi
echo "Creating bitcoin.conf"
# Seed a random password for JSON RPC server
cat <<EOF > $HOME/.bitcoin/bitcoin.conf
#
# Do not modify this file as it is autogenerated.
# You can either:
# (a) Modify this template "btc_init" in build or
# (b) You can pass a variable name as env variable during container launch
#
# Environmental Variable Name List
#
# MAINNET
# TESTNET
# REGTEST
# SERVER
# LISTEN
# LISTENONION
# DAEMON
# TXINDEX
# PRUNE
# DISABLEWALLET
# PRINTCONSOLE
# RPCUSER
# RPCPASSWORD
# RPCCONNECT
# RPCPORT
# RPCAUTH
# DBCACHE
# MAXCONNECTIONS
# MAXUPLOADTARGET
# PROXY
# SEEDNODE1
# SEEDNODE2
# SEEDNODE3
# REINDEXCHAINSTATE
# network
mainnet=${MAINNET:-1}
testnet=${TESTNET:-0}
regtest=${REGTEST:-0}
# server
server=${SERVER:-1}
listen=${LISTEN:-1}
listenonion=${LISTENONION:-0}
daemon=${DAEMON:-0}
txindex=${TXINDEX=-1}
prune=${PRUNE=-0}
disablewallet=${DISABLEWALLET:-1}
printtoconsole=${PRINTTOCONSOLE:-1}
# rpc
rpcuser=${RPCUSER:-bitcoinrpc}
rpcpassword=${RPCPASSWORD:-`dd if=/dev/urandom bs=33 count=1 2>/dev/null | base64`}
#rpcconnect=${RPCCONNECT:-127.0.0.1}
#rpcport=${RPCPORT:-8332}
#rpcauth=${RPCAUTH:-xxx}
# performance
dbcache=${DBCACHE:-2000}
maxconnections=${MAXCONNECTIONS:-40}
maxuploadtarget=${MAXUPLOADTARGET:-5000}
# tor
#proxy=${PROXY:-127.0.0.1:9050}
#seednode=${SEEDNODE1:-nkf5e6b7pl4jfd4a.onion}
#seednode=${SEEDNODE2:-xqzfakpeuvrobvpj.onion}
#seednode=${SEEDNODE3:-tsyvzsqwa2kkf6b2.onion}
# validation
reindex-chainstate=${REINDEXCHAINSTATE:-0}
EOF
cat $HOME/.bitcoin/bitcoin.conf
echo "Initialization completed successfully"

View File

@ -0,0 +1,7 @@
---
# handlers file for build
#
- name: rebuild_bitcoin
ansible.builtin.shell:
chdir: ~/Containers/bitcoin
cmd: ./build.sh

View File

@ -1,6 +1,28 @@
---
# tasks file for build
#
- name: Create bitcoin-pod
containers.podman.podman_pod:
name: bitcoin-pod
state: started
ports:
- "50001:50001"
- "4224:4224"
- "127.0.0.1:8332:8332"
- "8333:8333"
- name: Create bitcoin data / conf directory
ansible.builtin.file:
path: ~/.bitcoin
state: directory
mode: '0755'
- name: Copy bitcoin-node.container file
ansible.builtin.template:
src: bitcoin/bitcoin-node.container.j2
dest: /home/b0xxy/.config/containers/systemd/bitcoin-node.container
notify: reload_systemctl
- name: Create Containers/bitcoin Dir
ansible.builtin.file:
path: ~/Containers/bitcoin/bin
@ -31,4 +53,12 @@
src: bitcoin/bin/btc_oneshot
dest: ~/Containers/bitcoin/bin/btc_oneshot
notify: rebuild_bitcoin
- name: Copy build script
ansible.builtin.template:
src: bitcoin/build.sh.j2
dest: ~/Containers/bitcoin/build.sh
mode: '0700'
notify: rebuild_bitcoin

View File

@ -0,0 +1,8 @@
---
- name: Install apps
ansible.builtin.include_tasks:
file: "{{ item }}"
with_items:
- "{{ app_list }}"

View File

@ -3,7 +3,7 @@ Description=Bitcoin Node
[Container]
# Use the centos image
Image={{ registry_url }}:{{ bitcoin_version }}
Image={{ registry_url }}/bitcoin:{{ bitcoin_version }}
PodmanArgs=--pod bitcoin-pod
Environment=RPCPASSWORD={{ bitcoin_rpcpassword }}

View File

@ -0,0 +1,4 @@
#!/bin/sh
#Build command to make container
buildah build -t bitcoin:{{ bitcoin_version }} --build-arg VERSION={{ bitcoin_version }} -f Containerfile

View File

@ -1,68 +0,0 @@
#!/bin/bash
set -ex
mkdir -p $HOME/.bitcoin
if [ -f "$HOME/.bitcoin/bitcoin.conf" ];
then
echo "Backing up bitcoin.conf"
TMPEXT=$(date +%Y.%m.%d.%H.%M.%S)
mv $HOME/.bitcoin/bitcoin.conf $HOME/.bitcoin/bitcoin.conf.bak.$TMPEXT
fi
echo "Creating bitcoin.conf"
# Seed a random password for JSON RPC server
cat <<EOF > $HOME/.bitcoin/bitcoin.conf
#
#Do not modify this file as it is autogenerated.
#You can either (a) Modify this template "btc_init" in build or
# (b) You can pass a variable name as env variable during container launch
# The variable names are printed to right of each item
#
# network
mainnet=${MAINNET:-1} # MAINNET
testnet=${TESTNET:-0} # TESTNET
regtest=${REGTEST:-0} # REGTEST
# server
server=${SERVER:-1} # SERVER
listen=${LISTEN:-1} # LISTEN
listenonion=${LISTENONION:-0} # LISTENONION
daemon=${DAEMON:-0} # DAEMON
txindex=${TXINDEX=-1} # TXINDEX
prune=${PRUNE=-0} # PRUNE
disablewallet=${DISABLEWALLET:-1} # DISABLEWALLET
printtoconsole=${PRINTTOCONSOLE:-1} # PRINTCONSOLE
# rpc
rpcuser=${RPCUSER:-bitcoinrpc} # RPCUSER
rpcpassword=${RPCPASSWORD:-`dd if=/dev/urandom bs=33 count=1 2>/dev/null | base64`} # RPCPASSWORD
#rpcconnect=${RPCCONNECT:-127.0.0.1} # RPCCONNECT
#rpcport=${RPCPORT:-8332} # RPCPORT
#rpcauth=${RPCAUTH:-xxx} # RPCPORT
# performance
dbcache=${DBCACHE=-2000} # DBCACHE
maxconnections=${MAXCONNECTIONS=-40} # MAXCONNECTIONS
maxuploadtarget=${MAXUPLOADTARGET=-5000} # MAXUPLOADTARGET
# tor
#proxy=${PROXY:-127.0.0.1:9050} # PROXY
#seednode=${SEEDNODE1:-nkf5e6b7pl4jfd4a.onion} # SEEDNODE1
#seednode=${SEEDNODE2:-xqzfakpeuvrobvpj.onion} # SEEDNODE2
#seednode=${SEEDNODE3:-tsyvzsqwa2kkf6b2.onion} # SEEDNODE3
# validation
reindex-chainstate=${REINDEXCHAINSTATE=-0} # REINDEXCHAINSTATE
EOF
fi
cat $HOME/.bitcoin/bitcoin.conf
echo "Initialization completed successfully"

View File

@ -1,12 +0,0 @@
---
# handlers file for build
#
- name: rebuild_bitcoin
containers.podman.podman_image:
name: bitcoin:{{ bitcoin_version }}
path: ~/Containers/bitcoin/
build:
force_rm: true
format: oci
extra_args: VERSION={{ bitcoin_version }}
debugger: always

View File

@ -1,6 +0,0 @@
#!/bin/sh
#Build command to make container
VER=26.0
buildah build -t bitcoin:$VER --build-arg VERSION=$VER -f Containerfile

View File

@ -27,6 +27,7 @@
name:
- podman
- podman-compose
- buildah
- gpg
- git
- avahi