Skip to content

Commit e0d0c85

Browse files
authored
feat: dolos role (#141)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent f4f1b86 commit e0d0c85

File tree

6 files changed

+226
-0
lines changed

6 files changed

+226
-0
lines changed

roles/dolos/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
dolos
2+
=========
3+
4+
This role deploys an Dolos instance.
5+
6+
Requirements
7+
------------
8+
9+
Any pre-requisites that may not be covered by Ansible itself or the role should
10+
be mentioned here. For instance, if the role uses the EC2 module, it may be a
11+
good idea to mention in this section that the boto package is required.
12+
13+
Role Variables
14+
--------------
15+
16+
A description of the settable variables for this role should go here, including
17+
any variables that are in defaults/main.yml, vars/main.yml, and any variables
18+
that can/should be set via parameters to the role. Any variables that are read
19+
from other roles and/or the global scope (ie. hostvars, group vars, etc.)
20+
should be mentioned here as well.
21+
22+
Dependencies
23+
------------
24+
25+
A list of other roles hosted on Galaxy should go here, plus any details in
26+
regards to parameters that may need to be set for other roles, or variables
27+
that are used from other roles.
28+
29+
Example Playbook
30+
----------------
31+
32+
Including an example of how to use your role (for instance, with variables
33+
passed in as parameters) is always nice for users too:
34+
35+
```yaml
36+
- hosts: servers
37+
tasks:
38+
- include_role:
39+
name: blinklabs.cardano.dolos
40+
```
41+
42+
License
43+
-------
44+
45+
Apache 2.0
46+
47+
Author Information
48+
------------------
49+
50+
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

roles/dolos/defaults/main.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# Install method
3+
dolos_install_method: 'docker'
4+
5+
# Dolos version
6+
dolos_version: '0.15.1'
7+
8+
# Cardano network
9+
dolos_network: mainnet
10+
11+
# Base host directory for node data
12+
cardano_node_dir: /opt/cardano
13+
14+
# DB directory for host/container
15+
dolos_db_dir: '{{ cardano_node_dir }}/dolos'
16+
dolos_db_container_dir: '/data'
17+
18+
# Config directory for host/container (cardano-node)
19+
cardano_node_config_dir: '{{ cardano_node_dir }}/config'
20+
dolos_cardano_node_config_container_dir: '/config'
21+
# Config directory for host/container (dolos)
22+
dolos_etc_container_dir: '/etc/dolos'
23+
24+
# IPC directory for host/container
25+
cardano_node_ipc_dir: '{{ cardano_node_dir }}/ipc'
26+
dolos_ipc_container_dir: '/ipc'
27+
28+
# User/group for file/directory ownership
29+
cardano_node_user: root
30+
cardano_node_group: root
31+
32+
# Docker image
33+
dolos_docker_image: 'ghcr.io/txpipe/dolos:v{{ dolos_version }}'
34+
35+
# Docker container name
36+
dolos_docker_container_name: dolos
37+
38+
# Port for host/container (relay)
39+
dolos_relay_container_port: 30013
40+
dolos_relay_port: '{{ dolos_relay_container_port }}'
41+
42+
# Port for host/container (grpc)
43+
dolos_grpc_container_port: 50051
44+
dolos_grpc_port: '{{ dolos_grpc_container_port }}'

roles/dolos/meta/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
galaxy_info: {}
2+
3+
dependencies: []

roles/dolos/tasks/docker.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
- name: Initialize dolos_docker_volumes fact
3+
set_fact:
4+
dolos_docker_volumes: '{{ dolos_docker_volumes | default([]) + [item] }}'
5+
loop:
6+
- '{{ cardano_node_ipc_dir }}:{{ dolos_ipc_container_dir }}'
7+
- '{{ dolos_db_dir }}:{{ dolos_db_container_dir }}'
8+
9+
- name: Add config to dolos_docker_volumes fact
10+
set_fact:
11+
dolos_docker_volumes: '{{ dolos_docker_volumes | default([]) + [item] }}'
12+
loop:
13+
- '{{ cardano_node_config_dir }}/{{ dolos_network}}:{{ dolos_cardano_node_config_container_dir }}'
14+
- '{{ cardano_node_config_dir }}/dolos:{{ dolos_etc_container_dir }}'
15+
16+
- name: Create container
17+
docker_container:
18+
name: '{{ dolos_docker_container_name }}'
19+
image: '{{ dolos_docker_image }}'
20+
restart_policy: unless-stopped
21+
command:
22+
- dolos
23+
- daemon
24+
ports:
25+
- '{{ dolos_grpc_port }}:{{ dolos_grpc_container_port }}'
26+
- '{{ dolos_relay_port }}:{{ dolos_relay_container_port }}'
27+
volumes: '{{ dolos_docker_volumes | list }}'

roles/dolos/tasks/main.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
- name: Check install method
3+
vars:
4+
_allowed_install_methods: ['docker']
5+
ansible.builtin.assert:
6+
that:
7+
- dolos_install_method in _allowed_install_methods
8+
fail_msg: 'The specified install method ({{ dolos_install_method }}) is not one of the allowed values ({{ _allowed_install_methods | join(", ") }})'
9+
10+
# We use the node owner and group
11+
- name: Create directories
12+
ansible.builtin.file:
13+
state: directory
14+
path: '{{ item }}'
15+
owner: '{{ cardano_node_user | string }}'
16+
group: '{{ cardano_node_group | string }}'
17+
mode: '0755'
18+
loop:
19+
- '{{ cardano_node_ipc_dir }}'
20+
- '{{ dolos_db_dir }}'
21+
- '{{ cardano_node_config_dir }}/dolos'
22+
23+
- name: Generate Dolos config
24+
template:
25+
dest: '{{ dolos_etc_container_dir }}/daemon.toml'
26+
src: daemon.toml.j2
27+
owner: '{{ cardano_node_user | string }}'
28+
group: '{{ cardano_node_group | string }}'
29+
mode: 0644
30+
31+
- name: Include docker-related tasks
32+
ansible.builtin.include_tasks: docker.yml
33+
when: dolos_install_method == 'docker'
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# https://dolos.txpipe.io/configuration
2+
[upstream]
3+
{% if dolos_network == "preprod" %}
4+
{% set network_magic = 1 %}
5+
network_magic = {{ network_magic }}
6+
peer_address = "preprod-node.world.dev.cardano.org:3001"
7+
is_testnet = true
8+
{% elif dolos_network == "preview" %}
9+
{% set network_magic = 2 %}
10+
network_magic = {{ network_magic }}
11+
peer_address = "preview-node.play.dev.cardano.org:3001"
12+
is_testnet = true
13+
{% elif dolos_network == "sanchonet" %}
14+
{% set network_magic = 4 %}
15+
network_magic = {{ network_magic }}
16+
peer_address = "sanchonet-node.play.dev.cardano.org:3001"
17+
is_testnet = true
18+
{% else %}
19+
{% set network_magic = 764824073 %}
20+
network_magic = {{ network_magic }}
21+
peer_address = "backbone.mainnet.cardanofoundation.org:3001"
22+
is_testnet = false
23+
{% endif %}
24+
25+
[storage]
26+
path = "/data/db"
27+
wal_size = 1000
28+
29+
[relay]
30+
listen_address = "[::]:30013"
31+
magic = {{ network_magic }}
32+
33+
[sync]
34+
pull_batch_size = 100
35+
36+
[submit]
37+
prune_height = 200
38+
39+
[genesis]
40+
byron_path = "/config/byron-genesis.json"
41+
shelley_path = "/config/shelley-genesis.json"
42+
alonzo_path = "/config/alonzo-genesis.json"
43+
44+
[mithril]
45+
{% if dolos_network == "preprod" %}
46+
aggregator = "https://aggregator.release-preprod.api.mithril.network/aggregator"
47+
genesis_key = "5b3132372c37332c3132342c3136312c362c3133372c3133312c3231332c3230372c3131372c3139382c38352c3137362c3139392c3136322c3234312c36382c3132332c3131392c3134352c31332c3233322c3234332c34392c3232392c322c3234392c3230352c3230352c33392c3233352c34345d"
48+
{% elif dolos_network = "preview" %}
49+
aggregator = "https://aggregator.prerelease-preview.api.mithril.network/aggregator"
50+
genesis_key = "5b3132372c37332c3132342c3136312c362c3133372c3133312c3231332c3230372c3131372c3139382c38352c3137362c3139392c3136322c3234312c36382c3132332c3131392c3134352c31332c3233322c3234332c34392c3232392c322c3234392c3230352c3230352c33392c3233352c34345d"
51+
{% elif dolos_network = "sanchonet" %}
52+
aggregator = "https://aggregator.prerelease-sanchonet.api.mithril.network/aggregator"
53+
genesis_key = "5b3132372c37332c3132342c3136312c362c3133372c3133312c3231332c3230372c3131372c3139382c38352c3137362c3139392c3136322c3234312c36382c3132332c3131392c3134352c31332c3233322c3234332c34392c3232392c322c3234392c3230352c3230352c33392c3233352c34345d"
54+
{% else %}
55+
aggregator = "https://aggregator.release-mainnet.api.mithril.network/aggregator"
56+
genesis_key = "5b3139312c36362c3134302c3138352c3133382c31312c3233372c3230372c3235302c3134342c32372c322c3138382c33302c31322c38312c3135352c3230342c31302c3137392c37352c32332c3133382c3139362c3231372c352c31342c32302c35372c37392c33392c3137365d"
57+
{% endif %}
58+
59+
[serve.grpc]
60+
listen_address = "[::]:50051"
61+
62+
[serve.ouroboros]
63+
listen_path = "/ipc/dolos.socket"
64+
magic = {{ network_magic }}
65+
66+
[logging]
67+
max_level = "info"
68+
include_pallas = false
69+
include_grpc = false

0 commit comments

Comments
 (0)