diff --git a/playbooks/first-validator/run-first-validator.yml b/playbooks/first-validator/run-first-validator.yml index 8022454..732a7c9 100644 --- a/playbooks/first-validator/run-first-validator.yml +++ b/playbooks/first-validator/run-first-validator.yml @@ -54,7 +54,6 @@ CERC_CHAIN_ID: "{{ cerc_chain_id }}" MIN_GAS_PRICE: "{{ min_gas_price }}" CERC_LOGLEVEL: "{{ cerc_loglevel }}" - KEY_NAME: "{{ key_name }}" mode: '0777' - name: Ensure tmp directory exists inside laconicd-data diff --git a/playbooks/validator/run-validator.yml b/playbooks/validator/run-validator.yml new file mode 100644 index 0000000..036591f --- /dev/null +++ b/playbooks/validator/run-validator.yml @@ -0,0 +1,74 @@ +--- +- name: Run mainnet validator node + 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-spec.yml" + spec_template: "./templates/specs/spec-template.yml.j2" + 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 genesis_file in validator-vars.yml. + when: not genesis_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: Replace network section in spec_file + shell: > + yq eval '(.network) = load("{{ spec_template }}").network' -i {{ 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 }}" + CERC_PEERS: "{{ cerc_peers }}" + 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 genesis file to laconicd-data tmp directory + copy: + src: "{{ genesis_file }}" + dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/genesis.json" + mode: '0644' + + - name: Run validator node + shell: | + laconic-so deployment --dir {{data_directory}}/{{ mainnet_deployment_dir }} start diff --git a/playbooks/validator/templates/specs/spec-template.yml.j2 b/playbooks/validator/templates/specs/spec-template.yml.j2 new file mode 100644 index 0000000..9ae553e --- /dev/null +++ b/playbooks/validator/templates/specs/spec-template.yml.j2 @@ -0,0 +1,9 @@ +network: + ports: + laconicd: + - '6060:6060' + - '26657:26657' + - '26656:26656' + - '9473:9473' + - '9090:9090' + - '1317:1317' diff --git a/playbooks/validator/validator-vars.yml b/playbooks/validator/validator-vars.yml new file mode 100644 index 0000000..f3a1142 --- /dev/null +++ b/playbooks/validator/validator-vars.yml @@ -0,0 +1,6 @@ +cerc_moniker: "MainnetNode" +cerc_chain_id: "laconic-mainnet" +min_gas_price: 0.001 +cerc_loglevel: "info" +genesis_file: "" +cerc_peers: "" diff --git a/run-first-validator.md b/run-first-validator.md index ffb5d0a..dbc4a21 100644 --- a/run-first-validator.md +++ b/run-first-validator.md @@ -7,13 +7,13 @@ ## Generate mainnet genesis file -- Fetch the stack in machine where the testnet chain node is running +- Fetch the stack in machine where the testnet chain node is running: ```bash laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull ``` -- Run script to export state from testnet chain +- Run script to export state from testnet chain: ```bash ~/cerc/laconicd-stack/scripts/export-testnet-state.sh @@ -21,7 +21,7 @@ - The file will be generated in `/export/testnet-state.json` -- If mainnet node will be setup in new machine, fetch the stack again +- If mainnet node will be setup in new machine, fetch the stack again: ```bash laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull @@ -29,14 +29,14 @@ - Copy over the exported `testnet-state.json` file to target machine -- Set envs +- Set envs: ```bash export EXPORTED_STATE_PATH= export EARLY_SUPPORTS_ACC_ADDR= ``` -- Run playbook to use exported state for generating mainnet genesis +- Run playbook to use exported state for generating mainnet genesis: ```bash ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/generate-genesis.yml -e "exported_state_path=$EXPORTED_STATE_PATH" -e "early_supports_acc_address=$EARLY_SUPPORTS_ACC_ADDR" @@ -54,6 +54,7 @@ - Copy the example variables file: + ```bash cp ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml ```