chain-spec-node-keys.yml 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 }}/initial-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 %}--initial-members-path {{ remote_code_path }}/initial-members.json{% endif %}
  27. register: chain_spec_output
  28. delegate_to: '{{ build_instance }}'
  29. run_once: true
  30. - name: Run subkey to generate node keys
  31. shell: subkey generate-node-key
  32. delegate_to: '{{ build_instance }}'
  33. register: subkey_output
  34. - name: Print to stdout
  35. debug:
  36. msg:
  37. - 'Public Key: {{ subkey_output.stderr }}'
  38. - 'Private Key: {{ subkey_output.stdout }}'
  39. - name: Print to stdout chain spec
  40. debug: var=chain_spec_output.stdout
  41. run_once: true
  42. - name: Save output of chain spec to local file
  43. copy:
  44. content: '{{ chain_spec_output.stdout | regex_replace("\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]", "") }}'
  45. dest: '{{ remote_data_path }}/chain_spec_output.txt'
  46. delegate_to: '{{ build_instance }}'
  47. run_once: true
  48. - name: Change chain spec name, id, protocolId
  49. json_modify:
  50. chain_spec_path: '{{ chain_spec_path }}'
  51. prefix: '{{ network_suffix }}'
  52. all_nodes: '{{ hostvars }}'
  53. delegate_to: '{{ build_instance }}'
  54. register: result
  55. run_once: true
  56. - name: Print output of modified chainspec
  57. debug:
  58. var: result.result
  59. run_once: true
  60. - name: Run build-spec to generate raw chainspec file
  61. shell: '{{ remote_code_path }}/target/release/joystream-node build-spec --chain {{ chain_spec_path }} --raw > {{ raw_chain_spec_path }}'
  62. delegate_to: '{{ build_instance }}'
  63. run_once: true
  64. - name: Copying chain spec files to localhost
  65. synchronize:
  66. src: '/home/ubuntu/{{ remote_data_path }}/'
  67. dest: '{{ data_path }}'
  68. mode: pull
  69. run_once: true
  70. - name: Copy joystream-node binary to localhost
  71. fetch:
  72. src: '{{ remote_code_path }}/target/release/joystream-node'
  73. dest: '{{ data_path }}/joystream-node'
  74. flat: yes
  75. delegate_to: '{{ build_instance }}'
  76. run_once: true
  77. - name: Copying raw chain spec file to all servers
  78. copy:
  79. src: '{{ local_raw_chain_spec_path }}'
  80. dest: '{{ remote_chain_spec_path }}'