chain-spec-node-keys.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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: Run chain-spec-builder to generate chainspec.json file
  8. command: "{{ admin_code_dir }}/target/release/chain-spec-builder generate -a {{ number_of_validators }} --chain-spec-path {{ chain_spec_path }} --deployment live --endowed 1 --keystore-path {{ data_path }}"
  9. register: chain_spec_output
  10. delegate_to: "{{ local_or_admin }}"
  11. run_once: true
  12. - name: Run subkey to generate node keys
  13. shell: subkey generate-node-key
  14. delegate_to: "{{ local_or_admin }}"
  15. register: subkey_output
  16. - name: Print to stdout
  17. debug:
  18. msg:
  19. - "Public Key: {{ subkey_output.stderr }}"
  20. - "Private Key: {{ subkey_output.stdout }}"
  21. - name: Print to stdout chain spec
  22. debug: var=chain_spec_output.stdout
  23. run_once: true
  24. - name: Save output of chain spec to local file
  25. copy:
  26. content: '{{ chain_spec_output.stdout | regex_replace("\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]", "") }}'
  27. dest: "{{ data_path }}/chain_spec_output.txt"
  28. delegate_to: "{{ local_or_admin }}"
  29. run_once: true
  30. - name: Change chain spec name, id, protocolId
  31. json_modify:
  32. chain_spec_path: "{{ chain_spec_path }}"
  33. prefix: "{{ network_suffix }}"
  34. all_nodes: "{{ hostvars }}"
  35. delegate_to: "{{ local_or_admin }}"
  36. register: result
  37. run_once: true
  38. - name: Print output of modified chainspec
  39. debug:
  40. var: result.result
  41. run_once: true
  42. - name: Run build-spec to generate raw chainspec file
  43. shell: "{{ admin_code_dir }}/target/release/joystream-node build-spec --chain {{ chain_spec_path }} --raw > {{ raw_chain_spec_path }}"
  44. delegate_to: "{{ local_or_admin }}"
  45. run_once: true
  46. - name: Copying chain spec files to localhost
  47. synchronize:
  48. src: "/home/ubuntu/{{ data_path }}/"
  49. dest: "{{ data_path }}"
  50. mode: pull
  51. run_once: true
  52. when: run_on_admin_server|bool
  53. - name: Copy joystream-node binary to localhost
  54. fetch:
  55. src: "{{ admin_code_dir }}/target/release/joystream-node"
  56. dest: "{{ data_path }}/joystream-node"
  57. flat: yes
  58. delegate_to: "{{ local_or_admin }}"
  59. run_once: true
  60. when: run_on_admin_server|bool
  61. - name: Copying raw chain spec file to all servers
  62. copy:
  63. src: "{{ raw_chain_spec_path }}"
  64. dest: "{{ remote_chain_spec_path }}"