laconicd-stack/playbooks/first-validator/setup-first-validator.yml
Prathamesh Musale d91ed4280f Update yq setup and remove --git-ssh usage (#30)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e
- Add step for installing `zstd` in macOS
- Use ansible command module for running docker commands

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Reviewed-on: #30
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2025-06-19 13:18:56 +00:00

76 lines
3.1 KiB
YAML

---
- name: Run mainnet validator node
hosts: localhost
vars_files:
- first-validator-vars.yml
vars:
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}"
spec_file: "{{data_directory}}/laconicd-spec.yml"
spec_template: "./templates/specs/spec-template.yml.j2"
build_args: "{{ '--force-rebuild' if (lookup('env', 'FORCE_REBUILD') | default(omit, true)) not in [ 'false', 'False', '0' ] else '' }}"
BUILD_ONLY: "{{ lookup('env', 'BUILD_ONLY') | default(false) | bool }}"
tasks:
- name: Include setup tasks
ansible.builtin.import_tasks: ../setup.yml
- name: Fail if DATA_DIRECTORY or MAINNET_DEPLOYMENT_DIR env vars are not set
fail:
msg: >-
Required environment variables are not set.
Please export both DATA_DIRECTORY and MAINNET_DEPLOYMENT_DIR before running the playbook.
when: not BUILD_ONLY and (lookup('env', 'DATA_DIRECTORY') == '' or lookup('env', 'MAINNET_DEPLOYMENT_DIR') == '')
- name: Setup required repositories
shell: >
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd
setup-repositories --pull
- name: Build container images
shell: |
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers {{ build_args }}
- name: Create deployment spec file
when: not BUILD_ONLY
shell: |
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd deploy init --output {{ spec_file }}
- name: Replace network section in spec_file
when: not BUILD_ONLY
shell: >
{{ yq_path }} eval '(.network) = load("{{ spec_template }}").network' -i {{ spec_file }}
- name: Create deployment from spec file
when: not BUILD_ONLY
shell: |
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd deploy create --spec-file {{ spec_file }} --deployment-dir {{data_directory}}/{{ mainnet_deployment_dir }}
- name: Create config.env
when: not BUILD_ONLY
copy:
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/config.env"
content: |
CERC_MONIKER: "{{ cerc_moniker }}"
CERC_CHAIN_ID: "{{ cerc_chain_id }}"
MIN_GAS_PRICE: "{{ min_gas_price }}"
CERC_LOGLEVEL: "{{ cerc_loglevel }}"
TMKMS_ENABLED: "{{ tmkms_enabled }}"
mode: '0777'
- name: Initialize laconicd node
when: not BUILD_ONLY
shell: |
docker run -i \
-v {{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data:/root/.laconicd \
-v {{data_directory}}/{{ mainnet_deployment_dir }}/config/mainnet-laconicd:/scripts \
-e "CERC_MONIKER={{ cerc_moniker }}" \
-e "CERC_CHAIN_ID={{ cerc_chain_id }}" \
cerc/laconicd:local bash -c "/scripts/setup-laconicd.sh"
- name: Ensure tmp directory exists inside laconicd-data
when: not BUILD_ONLY
file:
path: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp"
state: directory
mode: '0755'