Divide generate genesis and create validator playbooks into build and start playbooks (#13)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e Co-authored-by: Shreerang Kale <shreerangkale@gmail.com> Reviewed-on: #13 Co-authored-by: shreerang <shreerang@noreply.git.vdb.to> Co-committed-by: shreerang <shreerang@noreply.git.vdb.to>
This commit was merged in pull request #13.
This commit is contained in:
@@ -5,36 +5,21 @@
|
||||
- first-validator-vars.yml
|
||||
vars:
|
||||
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
|
||||
mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}"
|
||||
gentx_genesis_dir: "{{data_directory}}/generate-gentx-genesis"
|
||||
spec_file: "{{data_directory}}/laconicd-spec.yml"
|
||||
connection: local
|
||||
tasks:
|
||||
- name: Fail if DATA_DIRECTORY or MAINNET_DEPLOYMENT_DIR env vars are not set
|
||||
- name: Fail if DATA_DIRECTORY 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: Fetch repositories
|
||||
ansible.builtin.shell:
|
||||
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd setup-repositories --git-ssh --pull"
|
||||
|
||||
# TODO: Add a flag to control force rebuild
|
||||
- name: Build containers
|
||||
ansible.builtin.shell:
|
||||
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers --force-rebuild"
|
||||
|
||||
- name: Copy exported testnet state file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ exported_state_path }}"
|
||||
dest: "~/cerc/laconicd-stack/testnet-state.json"
|
||||
remote_src: true # Set to true if exported_state_path is on the target host
|
||||
Please export both DATA_DIRECTORY before running the playbook.
|
||||
when: lookup('env', 'DATA_DIRECTORY') == ''
|
||||
|
||||
- block:
|
||||
- name: Run script to generate genesis file
|
||||
ansible.builtin.shell:
|
||||
cmd: "CHAIN_ID={{ cerc_chain_id }} EARLY_SUPPORTS_ACC_ADDRESS={{ early_supports_acc_address }} {{ ansible_env.HOME }}/cerc/laconicd-stack/scripts/generate-mainnet-genesis.sh {{ ansible_env.HOME }}/cerc/laconicd-stack/testnet-state.json {{ lps_distribution_path }}"
|
||||
cmd: "CHAIN_ID={{ cerc_chain_id }} EARLY_SUPPORTS_ACC_ADDRESS={{ early_supports_acc_address }} {{ ansible_env.HOME }}/cerc/laconicd-stack/scripts/generate-mainnet-genesis.sh {{ exported_state_path }} {{ lps_distribution_path }}"
|
||||
chdir: "{{ lookup('env', 'PWD') }}"
|
||||
always:
|
||||
- name: Clean up temporary genesis directory
|
||||
@@ -42,11 +27,6 @@
|
||||
path: "{{ ansible_env.HOME }}/cerc/laconicd-stack/playbooks/first-validator/mainnet-genesis"
|
||||
state: absent
|
||||
|
||||
- name: Remove temporary copied state file
|
||||
ansible.builtin.file:
|
||||
path: "~/cerc/laconicd-stack/testnet-state.json"
|
||||
state: absent
|
||||
|
||||
- name: Display genesis file location
|
||||
ansible.builtin.debug:
|
||||
msg: "Mainnet genesis file generated at output/genesis.json"
|
||||
@@ -55,30 +35,34 @@
|
||||
ansible.builtin.debug:
|
||||
msg: "Staking amount written to output/staking-amount.json"
|
||||
|
||||
- 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: Ensure tmp directory exists inside laconicd-data
|
||||
- name: Create data directory
|
||||
file:
|
||||
path: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp"
|
||||
path: "{{ gentx_genesis_dir }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Copy staking amount file to laconicd-data tmp directory
|
||||
- name: Ensure tmp directory exists inside gentx genesis directory
|
||||
file:
|
||||
path: "{{gentx_genesis_dir}}/tmp"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Ensure output directory exists inside gentx genesis directory
|
||||
file:
|
||||
path: "{{gentx_genesis_dir}}/output"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Copy staking amount file to gentx genesis tmp directory
|
||||
copy:
|
||||
src: "{{ lookup('env', 'PWD') }}/output/staking-amount.json"
|
||||
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/staking-amount.json"
|
||||
dest: "{{gentx_genesis_dir}}/tmp/staking-amount.json"
|
||||
mode: '0644'
|
||||
|
||||
- name: Copy genesis file to laconicd-data tmp directory
|
||||
- name: Copy genesis file to gentx genesis tmp directory
|
||||
copy:
|
||||
src: "{{ lookup('env', 'PWD') }}/output/genesis.json"
|
||||
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/genesis.json"
|
||||
dest: "{{gentx_genesis_dir}}/tmp/genesis.json"
|
||||
mode: '0644'
|
||||
|
||||
- name: Prompt for validator private key
|
||||
@@ -97,8 +81,8 @@
|
||||
- name: Run script to create and collect gentx
|
||||
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 \
|
||||
-v {{gentx_genesis_dir}}:/root/generate-gentx-genesis \
|
||||
-v ~/cerc/laconicd-stack/stack-orchestrator/config/mainnet-laconicd:/scripts \
|
||||
-e "PVT_KEY={{ private_key_input.user_input }}" \
|
||||
-e "KEY_NAME={{ key_name }}" \
|
||||
-e "CERC_MONIKER={{ cerc_moniker }}" \
|
||||
@@ -108,11 +92,11 @@
|
||||
|
||||
- name: Update genesis file in output
|
||||
copy:
|
||||
src: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/config/genesis.json"
|
||||
src: "{{gentx_genesis_dir}}/output/genesis.json"
|
||||
dest: "{{ lookup('env', 'PWD') }}/output/genesis.json"
|
||||
mode: '0644'
|
||||
|
||||
- name: Clear tmp directory
|
||||
file:
|
||||
path: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp"
|
||||
path: "{{gentx_genesis_dir}}/tmp"
|
||||
state: absent
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
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 '' }}"
|
||||
tasks:
|
||||
- name: Fail if DATA_DIRECTORY or MAINNET_DEPLOYMENT_DIR env vars are not set
|
||||
fail:
|
||||
@@ -16,9 +17,6 @@
|
||||
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: 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
|
||||
@@ -26,7 +24,7 @@
|
||||
|
||||
- name: Build container images
|
||||
shell: |
|
||||
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers --force-rebuild
|
||||
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers {{ build_args }}
|
||||
|
||||
- name: Create deployment spec file
|
||||
shell: |
|
||||
|
||||
Reference in New Issue
Block a user