add consul service definition, fix volume paths

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-03-23 09:57:42 +01:00
parent 8154ed43b3
commit 793e9a66f7
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
3 changed files with 45 additions and 35 deletions

View File

@ -1,12 +1,14 @@
--- ---
beacon_node_verbose: false beacon_node_verbose: false
# https://github.com/status-im/nimbus/docker
beacon_node_build_flavour: 'rlpx' beacon_node_build_flavour: 'rlpx'
beacon_node_network: 'testnet0' beacon_node_network: 'testnet0'
beacon_node_cont_image: 'statusteam/nimbus_beacon_node:{{beacon_node_network}}-{{beacon_node_build_flavour}}'
beacon_node_total_nodes: 1 beacon_node_total_nodes: 1
# Image source: https://github.com/status-im/nimbus/tree/master/docker/beacon_node
beacon_node_cont_tag: '{{ beacon_node_network }}-{{ beacon_node_build_flavour }}'
beacon_node_cont_image: 'statusteam/nimbus_beacon_node:{{ beacon_node_cont_tag }}'
beacon_node_cont_vol: '/docker/beacon_node' beacon_node_cont_vol: '/docker/beacon_node'
beacon_node_disovery_port: 9000 beacon_node_disovery_port: 9000

View File

@ -1,49 +1,58 @@
--- ---
- name: 'Create {{container_name}} container' - name: 'Create container dir: {{ container_name }}'
file:
path: '/docker/{{ container_name }}/data'
state: directory
owner: dockremap
group: docker
- name: 'Create container: {{ container_name }} {{ public_tcp_port }}'
docker_container: docker_container:
name: '{{container_name}}' name: '{{ container_name }}'
image: '{{beacon_node_cont_image}}' image: '{{ beacon_node_cont_image }}'
pull: true pull: true
restart_policy: always restart_policy: always
state: 'started' state: 'started'
recreate: false recreate: false
restart: false restart: false
ports: ports:
- '127.0.0.1:{{public_tcp_port}}:{{beacon_node_listening_port}}' - '{{ public_tcp_port }}:{{ beacon_node_listening_port }}'
- '127.0.0.1:{{public_udp_port}}:{{beacon_node_disovery_port}}/udp' - '{{ public_udp_port }}:{{ beacon_node_disovery_port }}/udp'
- '{{public_tcp_port}}:{{beacon_node_listening_port}}'
- '{{public_udp_port}}:{{beacon_node_disovery_port}}/udp'
command: | command: |
{% if beacon_node_verbose %} {% if beacon_node_verbose %}
--logLevel=DEBUG --logLevel=DEBUG
{% endif %} {% endif %}
--network={{beacon_node_network}} --network={{ beacon_node_network }}
--tcpPort={{beacon_node_listening_port}} --tcpPort={{ beacon_node_listening_port }}
--udpPort={{beacon_node_disovery_port}} --udpPort={{ beacon_node_disovery_port }}
volumes: volumes:
- '{{beacon_node_cont_vol}}/node-{{index}}:/root/.cache/nimbus' - '/docker/{{ container_name }}/data:/root/.cache/nimbus'
- name: 'Enable TCP port for beacon node {{index}}' - name: 'Enable ports for: {{ container_name }}'
iptables: iptables:
comment: 'TCP port for beacon node {{index}}' comment: '{{ container_name }} {{ item.protocol }}'
action: insert action: insert
chain: DOCKER-USER chain: DOCKER-USER
jump: ACCEPT jump: ACCEPT
source: '0.0.0.0/0' source: '0.0.0.0/0'
protocol: 'tcp' protocol: '{{ item.protocol }}'
destination_port: '{{public_tcp_port}}' destination_port: '{{ item.por }}'
notify: with_items:
- Save iptables rules - { protocol: 'tcp', port: '{{ public_tcp_port }}' }
- { protocol: 'udp', port: '{{ public_udp_port }}' }
- name: 'Enable UDP port for beacon node {{index}}'
iptables:
comment: 'UDP port for beacon node {{index}}'
action: insert
chain: DOCKER-USER
jump: ACCEPT
source: '0.0.0.0/0'
protocol: 'udp'
destination_port: '{{public_udp_port}}'
notify: notify:
- Save iptables rules - Save iptables rules
- name: 'Consul service definition - {{ container_name }}'
include_role: name=consul-service
vars:
consul_config_name: '{{ container_name | replace("-", "_") }}'
consul_services:
- id: '{{ container_name }}-{{ index }}'
name: '{{ container_name }}'
port: '{{ public_tcp_port }}'
tags: ['{{ env }}.{{ stage }}', 'beacon', 'nimbus']
checks:
- id: beacon-node-health
type: tcp
tcp: 'localhost:{{ public_tcp_port }}'

View File

@ -1,11 +1,10 @@
--- ---
- include_tasks: beacon_node.yml - include_tasks: beacon_node.yml
vars: vars:
public_tcp_port: '{{beacon_node_listening_port + loop_index}}' public_tcp_port: '{{ beacon_node_listening_port + loop_index }}'
public_udp_port: '{{beacon_node_listening_port + loop_index}}' public_udp_port: '{{ beacon_node_disovery_port + loop_index }}'
container_name: 'beacon-node-{{beacon_node_build_flavour}}-{{beacon_node_network}}-{{loop_index}}' container_name: 'beacon-node-{{ beacon_node_build_flavour }}-{{ beacon_node_network}}-{{loop_index }}'
index: '{{loop_index}}' index: '{{ loop_index }}'
loop: '{{range(0, beacon_node_total_nodes)|list}}' loop: '{{ range(0, beacon_node_total_nodes) | list }}'
loop_control: loop_control:
index_var: loop_index index_var: loop_index