Setup Bitcoin Node using Ansible in Remote Server

Posted By : Ayush

Oct 20, 2021

Ansible-bitcoin-node Setup

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.

 

The steps for proceeding further are as follows:-

STEP-1 Install ansible in your system

 

For installing ansible follow the below official documentation. Ansible Installation

 

STEP-2 Update the inventory file

 

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

  1. EC2 instance IP
  2. SSH username
  3. EC2 instance private key path(.pem file)

 

STEP-3 Running the Playbook

 

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

 

NOTE:-change the paths in files wherever required.

Now we have the custom dockerfile for bitcoin node, docker-compose, bitcoin configuration, and playbook. A master.yml file that runs two playbooks

  1. docker.yml
  2. bitcoin.yml

 

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.

 

The output of the playbook should look something as shown below

 

output1

 

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.

Leave a

Comment

Name is required

Invalid Name

Comment is required

Recaptcha is required.

blog-detail

November 23, 2024 at 01:23 am

Your comment is awaiting moderation.

By using this site, you allow our use of cookies. For more information on the cookies we use and how to delete or block them, please read our cookie notice.

Chat with Us
Telegram Button
Youtube Button

Contact Us

Oodles | Blockchain Development Company

Name is required

Please enter a valid Name

Please enter a valid Phone Number

Please remove URL from text