Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e Co-authored-by: Shreerang Kale <shreerangkale@gmail.com> Reviewed-on: #5 Co-authored-by: shreerang <shreerang@noreply.git.vdb.to> Co-committed-by: shreerang <shreerang@noreply.git.vdb.to>
112 lines
4.5 KiB
YAML
112 lines
4.5 KiB
YAML
---
|
|
- name: Create validator on running chain
|
|
hosts: localhost
|
|
vars_files:
|
|
- validator-vars.yml
|
|
vars:
|
|
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
|
|
mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}"
|
|
spec_file: "{{data_directory}}/laconicd-validator-spec.yml"
|
|
tasks:
|
|
- 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: lookup('env', 'DATA_DIRECTORY') == '' or lookup('env', 'MAINNET_DEPLOYMENT_DIR') == ''
|
|
|
|
- name: Fail if required key files are not defined
|
|
fail:
|
|
msg: >-
|
|
Required key files are not defined.
|
|
Please set staking_amount_file in validator-vars.yml.
|
|
when: not staking_amount_file
|
|
|
|
- name: Fetch laconicd stack
|
|
shell: laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
|
|
|
|
- name: Setup required repositories
|
|
shell: >
|
|
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd
|
|
setup-repositories --git-ssh --pull
|
|
|
|
- name: Build container images
|
|
shell: |
|
|
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers
|
|
|
|
- name: Create deployment spec file
|
|
shell: |
|
|
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd deploy init --output {{ spec_file }}
|
|
|
|
- name: Create deployment from spec file
|
|
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
|
|
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 }}"
|
|
mode: '0777'
|
|
|
|
- name: Ensure tmp directory exists inside laconicd-data
|
|
file:
|
|
path: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp"
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: Copy staking amount file to laconicd-data tmp directory
|
|
copy:
|
|
src: "{{ staking_amount_file }}"
|
|
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/staking-amount.json"
|
|
mode: '0644'
|
|
|
|
- name: Prompt for validator private key
|
|
vars:
|
|
private_key_prompt: "Please enter your validator private key: "
|
|
pause:
|
|
prompt: "{{ private_key_prompt }}"
|
|
echo: no
|
|
register: private_key_input
|
|
|
|
- name: Fail if private key is not provided
|
|
fail:
|
|
msg: "Private key is required for creating the gentx."
|
|
when: private_key_input.user_input | default('') | trim == ''
|
|
|
|
- name: Import private key in laconicd
|
|
shell: |
|
|
docker run -i \
|
|
-v {{ data_directory }}/{{ mainnet_deployment_dir }}/data/laconicd-data:/root/.laconicd \
|
|
--network=host \
|
|
cerc/laconicd:local \
|
|
laconicd keys import-hex {{ key_name }} {{ private_key_input.user_input }} --keyring-backend test \
|
|
|
|
- name: Get the key information
|
|
shell: |
|
|
docker run -i \
|
|
-v {{ data_directory }}/{{ mainnet_deployment_dir }}/data/laconicd-data:/root/.laconicd \
|
|
--network=host \
|
|
cerc/laconicd:local \
|
|
laconicd keys show {{ key_name }} --keyring-backend test
|
|
register: key_info
|
|
|
|
- name: Run create-validator script
|
|
shell: |
|
|
docker run -i \
|
|
-v {{ data_directory }}/{{ mainnet_deployment_dir }}/data/laconicd-data:/root/.laconicd \
|
|
-v {{ data_directory }}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/staking-amount.json:/scripts/staking-amount.json \
|
|
-v ~/cerc/laconicd-stack/stack-orchestrator/config/mainnet-laconicd/create-validator.sh:/scripts/create-validator.sh \
|
|
-e "KEY_NAME={{ key_name }}" \
|
|
-e "NODE_URL={{ node_url }}" \
|
|
-e "CERC_MONIKER={{ cerc_moniker }}" \
|
|
-e "CERC_CHAIN_ID={{ cerc_chain_id }}" \
|
|
-e "MIN_GAS_PRICE={{ min_gas_price }}" \
|
|
-e "VALIDATOR_PUB_KEY={{ validator_pub_key | to_json }}" \
|
|
--network=host \
|
|
cerc/laconicd:local \
|
|
sh -c "/scripts/create-validator.sh"
|