chain-spec-node-keys.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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: '{{ admin_code_dir }}/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: '{{ admin_code_dir }}/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. {{ admin_code_dir }}/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 {{ admin_code_dir }}/initial-balances.json{% endif %}
  26. {% if initial_balances_file is defined and initial_balances_file|length > 0 %}--initial-members-path {{ admin_code_dir }}/initial-members.json{% endif %}
  27. register: chain_spec_output
  28. delegate_to: '{{ local_or_admin }}'
  29. run_once: true
  30. - name: Run subkey to generate node keys
  31. shell: subkey generate-node-key
  32. delegate_to: '{{ local_or_admin }}'
  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: '{{ local_or_admin }}'
  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: '{{ local_or_admin }}'
  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: '{{ admin_code_dir }}/target/release/joystream-node build-spec --chain {{ chain_spec_path }} --raw > {{ raw_chain_spec_path }}'
  62. delegate_to: '{{ local_or_admin }}'
  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. when: run_on_admin_server|bool
  71. - name: Copy joystream-node binary to localhost
  72. fetch:
  73. src: '{{ admin_code_dir }}/target/release/joystream-node'
  74. dest: '{{ data_path }}/joystream-node'
  75. flat: yes
  76. delegate_to: '{{ local_or_admin }}'
  77. run_once: true
  78. when: run_on_admin_server|bool
  79. - name: Copying raw chain spec file to all servers
  80. copy:
  81. src: '{{ local_raw_chain_spec_path }}'
  82. dest: '{{ remote_chain_spec_path }}'