chain-spec-node-keys.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. ---
  2. # Create chain spec files and keys and copy to all the servers
  3. - name: Debug to test variable
  4. debug:
  5. msg: 'Remote Data path: {{ remote_data_path }}, Local Data path: {{ data_path }}, Chain Spec path: {{ chain_spec_path }}'
  6. run_once: true
  7. - name: Copying initial members file to the server
  8. copy:
  9. src: '{{ initial_members_file }}'
  10. dest: '{{ remote_code_path }}/query-node/mappings/src/bootstrap-data/data/members.json'
  11. when: initial_members_file is defined and initial_members_file|length > 0
  12. run_once: true
  13. - name: Copying initial balances file to the server
  14. copy:
  15. src: '{{ initial_balances_file }}'
  16. dest: '{{ remote_code_path }}/initial-balances.json'
  17. when: initial_balances_file is defined and initial_balances_file|length > 0
  18. run_once: true
  19. - name: Run chain-spec-builder to generate chainspec.json file (with initial data)
  20. shell: >
  21. {{ remote_code_path }}/target/release/chain-spec-builder generate -a {{ number_of_validators }}
  22. --chain-spec-path {{ chain_spec_path }}
  23. --endowed 1 --keystore-path {{ remote_data_path }}
  24. {% if deployment_type is defined and deployment_type|length > 0 %}--deployment {{ deployment_type }}{% endif %}
  25. {% if initial_members_file is defined and initial_members_file|length > 0 %}--initial-balances-path {{ remote_code_path }}/initial-balances.json{% endif %}
  26. {% if initial_balances_file is defined and initial_balances_file|length > 0 %}
  27. --initial-members-path {{ remote_code_path }}/query-node/mappings/src/bootstrap-data/data/members.json
  28. {% endif %}
  29. register: chain_spec_output
  30. delegate_to: '{{ build_instance }}'
  31. run_once: true
  32. - name: Run subkey to generate node keys
  33. shell: subkey generate-node-key
  34. delegate_to: '{{ build_instance }}'
  35. register: subkey_output
  36. - name: Print to stdout
  37. debug:
  38. msg:
  39. - 'Public Key: {{ subkey_output.stderr }}'
  40. - 'Private Key: {{ subkey_output.stdout }}'
  41. - name: Print to stdout chain spec
  42. debug: var=chain_spec_output.stdout
  43. run_once: true
  44. - name: Save output of chain spec to local file
  45. copy:
  46. content: '{{ chain_spec_output.stdout }}'
  47. dest: '{{ remote_data_path }}/chain_spec_output.txt'
  48. delegate_to: '{{ build_instance }}'
  49. run_once: true
  50. - name: Format chain spec output
  51. set_fact:
  52. chain_spec_output_formatted: '{{ chain_spec_output.stdout | regex_replace("=", ": ") | from_yaml }}'
  53. run_once: true
  54. - name: Extract keys from chain spec output
  55. set_fact:
  56. sudo_key: '{{ chain_spec_output_formatted.sudo }}'
  57. endowed_key: '{{ chain_spec_output_formatted.endowed_0 }}'
  58. delegate_to: '{{ build_instance }}'
  59. run_once: true
  60. - name: Change chain spec name, id, protocolId
  61. json_modify:
  62. chain_spec_path: '{{ chain_spec_path }}'
  63. prefix: '{{ network_suffix }}'
  64. all_nodes: '{{ hostvars }}'
  65. delegate_to: '{{ build_instance }}'
  66. register: result
  67. run_once: true
  68. - name: Print output of modified chainspec
  69. debug:
  70. var: result.result
  71. run_once: true
  72. - name: Run build-spec to generate raw chainspec file
  73. shell: '{{ remote_code_path }}/target/release/joystream-node build-spec --chain {{ chain_spec_path }} --raw > {{ raw_chain_spec_path }}'
  74. delegate_to: '{{ build_instance }}'
  75. run_once: true
  76. - name: Copying chain spec files to localhost
  77. synchronize:
  78. src: '/home/ubuntu/{{ remote_data_path }}/'
  79. dest: '{{ data_path }}'
  80. mode: pull
  81. run_once: true
  82. - name: Copy joystream-node binary to localhost
  83. fetch:
  84. src: '{{ remote_code_path }}/target/release/joystream-node'
  85. dest: '{{ data_path }}/joystream-node'
  86. flat: yes
  87. delegate_to: '{{ build_instance }}'
  88. run_once: true
  89. - name: Copying raw chain spec file to all servers
  90. copy:
  91. src: '{{ local_raw_chain_spec_path }}'
  92. dest: '{{ remote_chain_spec_path }}'