Skip to content

Commit

Permalink
Merge pull request #19 from blinklabs-io/feat/cardano-node-api
Browse files Browse the repository at this point in the history
feat: cardano-node-api
  • Loading branch information
wolf31o2 authored Nov 14, 2023
2 parents e6edae3 + 44c0894 commit 5868931
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 0 deletions.
51 changes: 51 additions & 0 deletions roles/cardano_node_api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
cardano_node_api
=========

This role deploys a Cardano Node API instance.

Requirements
------------

Any pre-requisites that may not be covered by Ansible itself or the role should
be mentioned here. For instance, if the role uses the EC2 module, it may be a
good idea to mention in this section that the boto package is required.

Role Variables
--------------

A description of the settable variables for this role should go here, including
any variables that are in defaults/main.yml, vars/main.yml, and any variables
that can/should be set via parameters to the role. Any variables that are read
from other roles and/or the global scope (ie. hostvars, group vars, etc.)
should be mentioned here as well.

Dependencies
------------

A list of other roles hosted on Galaxy should go here, plus any details in
regards to parameters that may need to be set for other roles, or variables
that are used from other roles.

Example Playbook
----------------

Including an example of how to use your role (for instance, with variables
passed in as parameters) is always nice for users too:

```yaml
- hosts: servers
tasks:
- include_role:
name: blinklabs.cardano.cardano_node_api
```
License
-------
Apache 2.0
Author Information
------------------
An optional section for the role authors to include contact information, or a
website (HTML is not allowed).
34 changes: 34 additions & 0 deletions roles/cardano_node_api/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
# Install method
cardano_node_api_install_method: 'docker'

# Cardano Submit API version
cardano_node_api_version: 'main'

# Base host directory for node data
cardano_node_dir: /opt/cardano

# IPC directory for host/container
cardano_node_ipc_dir: '{{ cardano_node_dir }}/ipc'
cardano_node_api_ipc_container_dir: '/node-ipc'

# User/group for file/directory ownership
cardano_node_user: root
cardano_node_group: root

# Docker image
cardano_node_api_docker_image: 'ghcr.io/blinklabs-io/cardano-node-api:{{ cardano_node_api_version }}'

# Docker container name
cardano_node_api_docker_container_name: cardano-node-api

# Port for host/container
cardano_node_api_container_port: 8080
cardano_node_api_port: '{{ cardano_node_api_container_port }}'

# Metrics port for host/container
cardano_node_api_metrics_container_port: 8081
cardano_node_api_metrics_port: '{{ cardano_node_api_metrics_container_port }}'

# Cardano network
cardano_node_api_network: mainnet
3 changes: 3 additions & 0 deletions roles/cardano_node_api/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
galaxy_info: {}

dependencies: []
13 changes: 13 additions & 0 deletions roles/cardano_node_api/tasks/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Create container
docker_container:
name: '{{ cardano_node_api_docker_container_name }}'
image: '{{ cardano_node_api_docker_image }}'
restart_policy: unless-stopped
ports:
- '{{ cardano_node_api_port }}:{{ cardano_node_api_container_port }}'
- '{{ cardano_node_api_metrics_port }}:{{ cardano_node_api_metrics_container_port }}'
env:
CARDANO_NETWORK: '{{ cardano_node_api_network }}'
volumes:
- '{{ cardano_node_ipc_dir }}:{{ cardano_node_api_ipc_container_dir }}'
23 changes: 23 additions & 0 deletions roles/cardano_node_api/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- name: Check install method
vars:
_allowed_install_methods: ['docker']
ansible.builtin.assert:
that:
- cardano_node_api_install_method in _allowed_install_methods
fail_msg: 'The specified install method ({{ cardano_node_api_install_method }}) is not one of the allowed values ({{ _allowed_install_methods | join(", ") }})'

# We use the node owner and group
- name: Create directories
ansible.builtin.file:
state: directory
path: '{{ item }}'
owner: '{{ cardano_node_user }}'
group: '{{ cardano_node_group }}'
mode: '0755'
loop:
- '{{ cardano_node_ipc_dir }}'

- name: Include docker-related tasks
ansible.builtin.include_tasks: docker.yml
when: cardano_node_api_install_method == 'docker'

0 comments on commit 5868931

Please sign in to comment.