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
+38
View File
@@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
+2
View File
@@ -0,0 +1,2 @@
---
# defaults file for build
+68
View File
@@ -0,0 +1,68 @@
#Based on Dockerflie from Kyle Manna - https://github.com/kylemanna/docker-bitcoind
FROM docker.io/almalinux/9-minimal:latest AS build
RUN microdnf update -y \
&& microdnf install -y \
ca-certificates \
gnupg2 \
libatomic \
wget \
tar \
gzip \
&& microdnf clean all && rm -fr /tmp/* /var/tmp/*
ARG VERSION=26.0
ARG BITCOIN_CORE_SIGNATURE=71A3B16735405025D447E8F274810B012346C9A6
ENV GOSU_VERSION 1.17
RUN cd /tmp \
&& gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys ${BITCOIN_CORE_SIGNATURE} \
&& wget https://bitcoincore.org/bin/bitcoin-core-${VERSION}/SHA256SUMS.asc \
https://bitcoincore.org/bin/bitcoin-core-${VERSION}/SHA256SUMS \
https://bitcoincore.org/bin/bitcoin-core-${VERSION}/bitcoin-${VERSION}-x86_64-linux-gnu.tar.gz \
&& gpg --verify --status-fd 1 --verify SHA256SUMS.asc SHA256SUMS 2>/dev/null | grep "^\[GNUPG:\] VALIDSIG.*${BITCOIN_CORE_SIGNATURE}\$" \
&& sha256sum --ignore-missing --check SHA256SUMS \
&& tar -xzvf bitcoin-${VERSION}-x86_64-linux-gnu.tar.gz -C /opt \
&& ln -sv bitcoin-${VERSION} /opt/bitcoin \
&& /opt/bitcoin/bin/test_bitcoin --show_progress \
&& rm -v /opt/bitcoin/bin/test_bitcoin /opt/bitcoin/bin/bitcoin-qt
RUN wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64"; \
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64.asc"; \
\
# verify the signature
export GNUPGHOME="$(mktemp -d)"; \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
gpgconf --kill all; \
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc;
FROM docker.io/almalinux/9-minimal:latest
LABEL maintainer="b0xxer@b0xxy.net"
ENTRYPOINT ["entrypoint.sh"]
ENV HOME /bitcoin
EXPOSE 8332 8333
VOLUME ["/bitcoin/.bitcoin"]
WORKDIR /bitcoin
COPY --from=build /opt/ /opt/
COPY --from=build /usr/local/bin/gosu /usr/local/bin/
RUN microdnf update -y \
&& microdnf install -y libatomic shadow-utils \
&& microdnf clean all && rm -rf /tmp/* /var/tmp/* \
&& ln -sv /opt/bitcoin/bin/* /usr/local/bin
ARG GROUP_ID=1000
ARG USER_ID=1000
RUN groupadd -g ${GROUP_ID} bitcoin \
&& useradd -u ${USER_ID} -g bitcoin -d /bitcoin bitcoin
COPY ./bin ./entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh && chmod +x /usr/local/bin/gosu \
&& chmod +x /usr/local/bin/btc_oneshot && chmod +x /usr/local/bin/btc_init
CMD ["btc_oneshot"]
+91
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"
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
set -ex
# Generate bitcoin.conf
btc_init
# Default / no argument invocation listens for RPC commands and has to accept non-localhost because of
# Docker port proxying or Docker private networking.
if [ $# -eq 0 ]; then
# If IPv6 is in the container do both:
#set -- '-rpcbind=[::]:8332' '-rpcallowip=::/0' '-rpcallowip=0.0.0.0/0'
set -- '-rpcbind=:8332' '-rpcallowip=0.0.0.0/0'
fi
exec bitcoind "$@"
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
set -e
# first arg is `-f` or `--some-option`
# or first arg is `something.conf`
if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then
set -- btc_oneshot "$@"
fi
# Allow the container to be started with `--user`, if running as root drop privileges
if [ "$1" = 'btc_oneshot' -a "$(id -u)" = '0' ]; then
chown -R bitcoin .
exec gosu bitcoin "$0" "$@"
fi
# If not root (i.e. docker run --user $USER ...), then run as invoked
exec "$@"
+7
View File
@@ -0,0 +1,7 @@
---
# handlers file for build
#
- name: rebuild_bitcoin
ansible.builtin.shell:
chdir: ~/Containers/bitcoin
cmd: ./build.sh
+52
View File
@@ -0,0 +1,52 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
+64
View File
@@ -0,0 +1,64 @@
---
# 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
recurse: true
state: directory
notify: rebuild_bitcoin
- name: Copy Containerfile Template
ansible.builtin.copy:
src: bitcoin/Containerfile
dest: ~/Containers/bitcoin/Containerfile
notify: rebuild_bitcoin
- name: Copy entrypoint.sh
ansible.builtin.copy:
src: bitcoin/entrypoint.sh
dest: ~/Containers/bitcoin/entrypoint.sh
notify: rebuild_bitcoin
- name: Copy btc_init
ansible.builtin.copy:
src: bitcoin/bin/btc_init
dest: ~/Containers/bitcoin/bin/btc_init
notify: rebuild_bitcoin
- name: Copy btc_oneshot
ansible.builtin.copy:
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
+8
View File
@@ -0,0 +1,8 @@
---
- name: Install apps
ansible.builtin.include_tasks:
file: "{{ item }}"
with_items:
- "{{ app_list }}"
@@ -0,0 +1,23 @@
[Unit]
Description=Bitcoin Node
[Container]
# Use the centos image
Image={{ registry_url }}/bitcoin:{{ bitcoin_version }}
PodmanArgs=--pod bitcoin-pod
Environment=RPCPASSWORD={{ bitcoin_rpcpassword }}
# 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
+4
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
+2
View File
@@ -0,0 +1,2 @@
localhost
+5
View File
@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- build
+2
View File
@@ -0,0 +1,2 @@
---
# vars file for build