Posted By : Ayush
What is Ansible
Ansible is a tool that can be used for provisioning software or packages, configuration management, and application deployment via infrastructure as a code.
Ansible is an open-source tool and has a large community for support and has a large number of playbooks in its the store for almost all configurations whether it is linux system or windows.
Ansible is an agentless tool that needs no agent to be run on the target machine. Which makes it easy to use and configure a remote systems without needing direct access of the system.
This is the ansible-playbook to automatically set up a bitcoin node over docker in a remote server.
For installing ansible follow the below official documentation. Ansible Installation
If the server is an EC2 instance we have to write the inventory file as follows-
[ec21]
<EC2 instance IP> ansible_ssh_user=<SSH username> ansible_connection=ssh ansible_ssh_private_key_file=<EC2 instance private key path(.pem file)> ansible_python_interpreter=/usr/bin/python3
Replace the values of the following according to your instance details
Clone the repository in your local system. The directory structure after cloning will be as shown below
.
|__ bitcoin.retry
|__ bitcoin.yml
|__ btc
|__ bitcoin.conf
|__ btc-docker-compose.yml
|__ Dockerfile
|__ wallet.sh
1 directory, 6 files
Now we have the custom dockerfile for bitcoin node, docker-compose, bitcoin configuration, and playbook. A master.yml file that runs two playbooks
The docker.yml
playbook setup docker and docker-compose into the remote server if not present.
The bitcoin.yml
setup bitcoin node over docker in a remote server.
To run the playbooks
#ansible-playbook master.yml
To run the playbook with verbose
#ansible-playbook master.yml -vv
#Increase or decrease the number of v for depth of verbosity you want.
Also, ssh to the server and check for the node to be deployed over docker.
ubuntu@ip-172-31-84-130:~/opt/btc$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3bba6ab3acda btc_bitcoin "/usr/bin/bitcoind -…" 9 seconds ago Up 8 seconds 0.0.0.0:8332-8333->8332-8333/tcp, :::8332-8333->8332-8333/tcp, 0.0.0.0:18332-18333->18332-18333/tcp, :::18332-18333->18332-18333/tcp btc_bitcoin_1
To check the syncing of the node get inside the docker container
#docker-compose exec bitcoin bash
#bitcoin-cli getblockchaininfo
THE BITCOIN NODE HAS TO BE SUCCESSFULLY SET UP AND CONFIGURED ON THE REMOTE SERVER.
November 23, 2024 at 01:23 am
Your comment is awaiting moderation.