Setup Bitcoin Node using Ansible in Remote Server

Posted By : Ayush Gupta | 20-Oct-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-


<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

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




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>8332-8333/tcp, :::8332-8333->8332-8333/tcp,>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



About Author

Ayush Gupta

He is an engineering graduate in computer science. He's interested in learning new technologies and taking up new challenges. His skills include DevOps, Ansible, RedHat v8, AWS Cloud, and OpenStack.

Leave a Comment

Name is required

Comment is required

Recaptcha is required.

No Comments Yet.

    Request For Proposal

    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.

    We would love to hear from you!

    Oodles | Blockchain Development Company

    Please enter a valid Phone Number

    Please remove URL from text

    Recaptcha is required.