From 4eeb9f751e241190680eaf7d172747e32a6a19e6 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Fri, 13 Jun 2025 15:43:48 +0000 Subject: [PATCH] Add yq tool in playbook (#19) Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e Reviewed-on: https://git.vdb.to/cerc-io/laconicd-stack/pulls/19 Co-authored-by: Nabarun Co-committed-by: Nabarun --- docs/run-first-validator.md | 28 +++++++++++++++---- docs/run-validator.md | 12 ++++---- .../cosmos-multisig-app-start.yml | 10 +++---- .../first-validator/setup-first-validator.yml | 5 +++- playbooks/setup.yml | 24 ++++++++++++++++ playbooks/validator/setup-validator.yml | 5 +++- 6 files changed, 65 insertions(+), 19 deletions(-) create mode 100644 playbooks/setup.yml diff --git a/docs/run-first-validator.md b/docs/run-first-validator.md index 42dad20..df83237 100644 --- a/docs/run-first-validator.md +++ b/docs/run-first-validator.md @@ -21,6 +21,7 @@ - Following tools are required in all machines: - [ansible](playbooks/README.md#ansible-installation) + - [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) - laconicd-stack @@ -81,7 +82,7 @@ - Get the public key of your node: ```bash - docker run -it \ + docker run -it \ -v $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data:/root/.laconicd \ cerc/laconicd:local bash -c "laconicd tendermint show-validator" ``` @@ -114,7 +115,7 @@ - Get your private key from testnet deployment: ```bash - laconic-so deployment --dir exec laconicd "laconicd keys export --unarmored-hex --unsafe" + laconic-so deployment --dir exec laconicd "laconicd keys export --unarmored-hex --unsafe --keyring-backend test" ``` NOTE: Store this key securely as it is needed in later steps @@ -169,7 +170,7 @@ ~/cerc/laconicd-stack/scripts/generate-lps-lock.sh -i "" -o $LPS_DISTRIBUTION_PATH ``` - - This will generate the `distribution.json` file at `$LPS_DISTRIBUTION_PATH` + - This will generate the file at `$LPS_DISTRIBUTION_PATH` - Copy the example variables file: @@ -186,6 +187,12 @@ validator_pub_key: '' ``` +- Change to the deployments directory + + ```bash + cd $DATA_DIRECTORY + ``` + - Run playbook to use exported state for generating mainnet genesis file with gentx: ```bash @@ -265,10 +272,11 @@ rm -rf $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json ``` -- Copy the genesis file to the mainnet deployment tmp directory: +- Copy the genesis file generated in [Generate mainnet genesis file section](#generate-mainnet-genesis-file) from machine 3 to the machine 2 mainnet deployment tmp directory: ```bash - cp $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/tmp/genesis.json + # Directory on machine 2 to place genesis.json file + echo $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/tmp/ ``` - Command to run node: @@ -312,12 +320,20 @@ laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query auth module-account lps_lockup' ``` -- Query the `lps_lockup` and early supports accounts balances: +- Query the `lps_lockup` account balance: ```bash lockup_account_address=$(laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query auth module-account lps_lockup -o json | jq -r .account.value.base_account.address') laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd "laconicd query bank balances $lockup_account_address" + ``` +- Query the early supports account balance: + + ```bash + # Set the early supports account address + export EARLY_SUPPORTS_ACC_ADDR= + + # Check balance laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd "laconicd query bank balances $EARLY_SUPPORTS_ACC_ADDR" ``` diff --git a/docs/run-validator.md b/docs/run-validator.md index b3e8c3b..fa08c1b 100644 --- a/docs/run-validator.md +++ b/docs/run-validator.md @@ -2,6 +2,12 @@ ## Prerequisites +- To fetch laconicd-stack: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull + ``` + - Machine 1: Where the SAPO testnet node is already running - Machine 2: Where the mainnet validator node is to be setup @@ -28,12 +34,6 @@ - [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) is required in all machines -- To fetch laconicd-stack: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull - ``` - ## Stop SAPO testnet node - Run the following steps in machine where the testnet node is already running (machine 1) diff --git a/playbooks/cosmos-multisig-app/cosmos-multisig-app-start.yml b/playbooks/cosmos-multisig-app/cosmos-multisig-app-start.yml index 9a81bf6..ef0dd5e 100644 --- a/playbooks/cosmos-multisig-app/cosmos-multisig-app-start.yml +++ b/playbooks/cosmos-multisig-app/cosmos-multisig-app-start.yml @@ -2,10 +2,6 @@ - name: Setup and deploy the cosmos multisig app hosts: multihosts - # To use yq binary installed in user bin path - environment: - PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin" - vars_files: - cosmos-multisig-vars.yml vars: @@ -17,7 +13,11 @@ network_json: "../../config/network.json" remote_network_json: "{{data_directory}}/network.json" build_args: "{{ '--force-rebuild' if (lookup('env', 'FORCE_REBUILD') | default(omit, true)) not in [ 'false', 'False', '0' ] else '' }}" + tasks: + - name: Include setup tasks + ansible.builtin.import_tasks: ../setup.yml + - name: Fail if DATA_DIRECTORY env var is not set fail: msg: "Environment variable DATA_DIRECTORY is not set. Please export it before running the playbook." @@ -43,7 +43,7 @@ - name: Replace network section in spec_output shell: > - yq eval '(.network) = load("{{ remote_spec_template }}").network' -i {{ spec_output }} + {{ yq_path }} eval '(.network) = load("{{ remote_spec_template }}").network' -i {{ spec_output }} - name: Check if deployment directory exists stat: diff --git a/playbooks/first-validator/setup-first-validator.yml b/playbooks/first-validator/setup-first-validator.yml index b58e3a5..da20b0a 100644 --- a/playbooks/first-validator/setup-first-validator.yml +++ b/playbooks/first-validator/setup-first-validator.yml @@ -10,6 +10,9 @@ 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 '' }}" 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: >- @@ -32,7 +35,7 @@ - name: Replace network section in spec_file shell: > - yq eval '(.network) = load("{{ spec_template }}").network' -i {{ spec_file }} + {{ yq_path }} eval '(.network) = load("{{ spec_template }}").network' -i {{ spec_file }} - name: Create deployment from spec file shell: | diff --git a/playbooks/setup.yml b/playbooks/setup.yml new file mode 100644 index 0000000..b3bd354 --- /dev/null +++ b/playbooks/setup.yml @@ -0,0 +1,24 @@ +--- +# Setup tasks for all playbooks +- name: Create tools directory in user's home + file: + path: "{{ ansible_env.HOME }}/.laconic-tools" + state: directory + mode: '0755' + +- name: Check if yq exists + stat: + path: "{{ ansible_env.HOME }}/.laconic-tools/yq" + register: yq_file + +- name: Download yq to user's tools directory + shell: | + curl -L https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o {{ ansible_env.HOME }}/.laconic-tools/yq + chmod +x {{ ansible_env.HOME }}/.laconic-tools/yq + when: not yq_file.stat.exists + args: + creates: "{{ ansible_env.HOME }}/.laconic-tools/yq" + +- name: Set yq path variable + set_fact: + yq_path: "{{ ansible_env.HOME }}/.laconic-tools/yq" diff --git a/playbooks/validator/setup-validator.yml b/playbooks/validator/setup-validator.yml index 4ce0913..bd9a028 100644 --- a/playbooks/validator/setup-validator.yml +++ b/playbooks/validator/setup-validator.yml @@ -10,6 +10,9 @@ 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 '' }}" 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: >- @@ -39,7 +42,7 @@ - name: Replace network section in spec_file shell: > - yq eval '(.network) = load("{{ spec_template }}").network' -i {{ spec_file }} + {{ yq_path }} eval '(.network) = load("{{ spec_template }}").network' -i {{ spec_file }} - name: Create deployment from spec file shell: |