-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from blinklabs-io/feat-add-role-for-deploying-…
…snek
- Loading branch information
Showing
5 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Snek | ||
========= | ||
|
||
This role deploys an Snek 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.snek | ||
``` | ||
License | ||
------- | ||
Apache 2.0 | ||
Author Information | ||
------------------ | ||
An optional section for the role authors to include contact information, or a website (HTML is not allowed). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
# Install method | ||
snek_install_method: 'docker' | ||
|
||
# Snek version | ||
snek_version: '0.15.0' | ||
|
||
# Base host directory for node data | ||
cardano_node_dir: /opt/cardano | ||
|
||
# DB directory for host/container | ||
snek_db_dir: '{{ cardano_node_dir }}/snek' | ||
|
||
# Config directory for host/container | ||
cardano_node_config_dir: '{{ cardano_node_dir }}/config' | ||
snek_config_container_dir: '{{ cardano_node_config_dir }}' | ||
|
||
# IPC directory for host/container | ||
cardano_node_ipc_dir: '{{ cardano_node_dir }}/ipc' | ||
snek_ipc_container_dir: '/node-ipc' | ||
|
||
# User/group for file/directory ownership | ||
cardano_node_user: root | ||
cardano_node_group: root | ||
|
||
# Docker image | ||
snek_docker_image: 'ghcr.io/blinklabs-io/snek:{{ snek_version }}' | ||
|
||
# Docker container name | ||
snek_docker_container_name: snek | ||
|
||
# Port for host/container | ||
snek_container_port: 8080 | ||
snek_port: '{{ snek_container_port }}' | ||
|
||
# Cardano network | ||
snek_network: mainnet | ||
|
||
cardano_node_socket_name: node.socket | ||
|
||
# snek arguments (defaults to everything) | ||
snek_arguments: | ||
# Local node | ||
# - '-v' | ||
# - '{{ cardano_node_ipc_dir }}:{{ snek_ipc_container_dir }}' | ||
- '-input-chainsync-network' | ||
- '{{ snek_network }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
galaxy_info: {} | ||
|
||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Initialize snek_docker_volumes fact | ||
set_fact: | ||
snek_docker_volumes: '{{ snek_docker_volumes | default([]) + [item] }}' | ||
loop: | ||
- '{{ cardano_node_ipc_dir }}:{{ snek_ipc_container_dir }}' | ||
|
||
- name: Create container | ||
docker_container: | ||
name: '{{ snek_docker_container_name }}' | ||
image: '{{ snek_docker_image }}' | ||
restart_policy: unless-stopped | ||
command: | ||
- "{{ snek_arguments | default([]) }}" | ||
ports: | ||
- '{{ snek_port }}:{{ snek_container_port }}' | ||
env: | ||
CARDANO_NETWORK: '{{ snek_network }}' | ||
volumes: '{{ snek_docker_volumes | list }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
- name: Echo Snek | ||
command: echo "hello snek" | ||
|
||
- name: Check install method | ||
vars: | ||
_allowed_install_methods: ['docker'] | ||
ansible.builtin.assert: | ||
that: | ||
- snek_install_method in _allowed_install_methods | ||
fail_msg: 'The specified install method ({{ snek_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: snek_install_method == 'docker' |