Add base for lnd

This commit is contained in:
Amarpreet Minhas 2021-01-07 20:02:04 -05:00
parent a06971afc4
commit 50b2fc08c7
8 changed files with 127 additions and 0 deletions

View file

@ -0,0 +1,7 @@
---
- hosts: lnd
roles:
- role: tor
- role: bitcoind
- role: lnd
...

View file

@ -5,4 +5,5 @@
- import_playbook: consul-client.yml
- import_playbook: nomad.yml
- import_playbook: nexus.yml
- import_playbook: lnd.yml
...

View file

@ -0,0 +1,17 @@
[Unit]
Description=Bitcoin daemon
[Service]
ExecStartPre=/bin/sh -c 'sleep 30'
ExecStart=/usr/bin/bitcoind -daemon -conf=/home/bitcoind/.bitcoin/bitcoin.conf -pid=/home/bitcoind/.bitcoin/bitcoind.pid
PIDFile=/home/bitcoind/.bitcoin/bitcoind.pid
User=bitcoind
Group=bitcoind
Type=forking
KillMode=process
Restart=always
TimeoutSec=120
RestartSec=30
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,5 @@
---
- name: reload systemd
systemd:
daemon_reload: True
...

View file

@ -0,0 +1,53 @@
---
- name: create bitcoind group
group:
name: bitcoind
state: present
- name: create bitcoind user
user:
name: bitcoind
group: bitcoind
state: present
shell: /bin/bash
home: /home/bitcoind
- name: ensure bitcoind config directory exists
file:
path: /home/bitcoind/.bitcoin
state: directory
owner: bitcoind
group: bitcoind
mode: '0750'
- name: ensure bitcoind mount exists
mount:
path: /home/bitcoind/.bitcoin
src: /dev/sda1
fstype: ext4
opts: defaults
state: present
- name: install bitcoind
apt:
name: bitcoind
state: present
- name: ensure bitcoind service file exists
copy:
src: files/bitcoind.service
dest: /etc/systemd/system/bitcoind.service
mode: 0755
owner: root
group: root
notify: reload systemd
- name: flush handlers for systemd reloading
meta: flush_handlers
- name: ensure bitcoind is enabled and started
systemd:
name: bitcoind
state: started
enabled: True
...

View file

@ -0,0 +1,3 @@
---
lnd_arch: amd64
...

View file

@ -0,0 +1,30 @@
---
- name: ensure go/bin dir exists for bitcoind user
file:
path: /home/bitcoind/go/bin
state: directory
owner: bitcoind
group: bitcoind
mode: 0750
- name: check if lnd is installed
stat:
path: /home/bitcoind/go/bin/lnd
register: lnd_binary
- name: check lnd version
shell: /home/bitcoind/go/bin/lnd --version | cut -d ' ' -f3
when: lnd_binary.stat.exists
changed_when: False
register: lnd_installed_version
- name: update lnd
unarchive:
src: 'https://github.com/lightningnetwork/lnd/releases/download/{{ lnd_version }}/lnd-linux-{{ lnd_arch }}-{{ lnd_version }}.tar.gz'
dest: /home/bitcoind/go/bin/
owner: bitcoind
group: bitcoind
remote_src: True
extra_opts: [--strip-components=1]
when: (lnd_binary.stat.exists == False) or (lnd_version != lnd_installed_version)
...

View file

@ -0,0 +1,11 @@
---
- name: ensure tor exists
apt:
name: tor
state: present
- name: ensure tor is started and enabled
systemd:
name: tor
state: started
enabled: True