chain-spec-node-keys.yml 3.2 KB

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