main.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ---
  2. # Configure and start joystream-node RPC service on the servers
  3. - name: Print bootNodes
  4. debug:
  5. var: result.result.bootNodes
  6. run_once: true
  7. - name: Create a service file
  8. template:
  9. src: joystream-node.service.j2
  10. dest: /etc/systemd/system/joystream-node.service
  11. vars:
  12. template_remote_chain_spec_path: '{{ remote_chain_spec_path }}'
  13. boot_nodes: '{{ result.result.bootNodes }}'
  14. become: yes
  15. - name: Start service joystream-node, if not started
  16. service:
  17. name: joystream-node
  18. state: started
  19. enabled: yes
  20. become: yes
  21. - name: Build required packages
  22. shell: yarn build:packages
  23. args:
  24. chdir: '{{ remote_code_path }}'
  25. # Run in async fashion for max duration of 1 hr
  26. async: 3600
  27. poll: 0
  28. register: build_result
  29. - name: Check on build async task
  30. async_status:
  31. jid: '{{ build_result.ansible_job_id }}'
  32. register: job_result
  33. until: job_result.finished
  34. # Max number of times to check for status
  35. retries: 36
  36. # Check for the status every 100s
  37. delay: 100
  38. - name: Run service containers
  39. command: yarn start
  40. environment:
  41. PERSIST: 'true'
  42. JOYSTREAM_NODE_WS: 'ws://{{ inventory_hostname }}:9944/'
  43. COLOSSUS_1_URL: 'https://{{ inventory_hostname }}.nip.io/colossus-1/'
  44. DISTRIBUTOR_1_URL: 'https://{{ inventory_hostname }}.nip.io/distributor-1/'
  45. SKIP_NODE: 'true'
  46. args:
  47. chdir: '{{ remote_code_path }}'
  48. async: 1800
  49. poll: 0
  50. register: compose_result
  51. - name: Check on yarn start task
  52. async_status:
  53. jid: '{{ compose_result.ansible_job_id }}'
  54. register: job_result
  55. until: job_result.finished
  56. # Max number of times to check for status
  57. retries: 18
  58. # Check for the status every 100s
  59. delay: 100
  60. - name: Set websocket and http endpoint variables
  61. set_fact:
  62. nip_domain: '{{ inventory_hostname }}.nip.io'
  63. run_once: yes
  64. - name: Install and configure Caddy
  65. include_role:
  66. name: caddy_ansible.caddy_ansible
  67. apply:
  68. become: yes
  69. vars:
  70. caddy_config: "{{ lookup('template', 'templates/Caddyfile.j2') }}"
  71. caddy_systemd_capabilities_enabled: true
  72. caddy_update: false
  73. - name: Set endpoints
  74. set_fact:
  75. all_services: |
  76. websocket_rpc: wss://{{ nip_domain }}/ws-rpc
  77. http_rpc: https://{{ nip_domain }}/http-rpc
  78. colossus: https://{{ nip_domain }}/colossus-1
  79. distributor: https://{{ nip_domain }}/distributor-1
  80. graphql_server: https://{{ nip_domain }}/query-node/server/graphql
  81. graphql_server_websocket: wss://{{ nip_domain }}/query-node/server/graphql
  82. indexer: https://{{ nip_domain }}/query-node/indexer/graphql
  83. member_faucet: https://{{ nip_domain }}/member-faucet/register
  84. config: https://{{ nip_domain }}/network/config.json
  85. run_once: yes
  86. - name: Print endpoints
  87. debug:
  88. msg: '{{ all_services | from_yaml }}'
  89. run_once: yes
  90. - name: Create config.json to serve as Caddy endpoint
  91. copy:
  92. content: '{{ all_services | from_yaml | to_json }}'
  93. dest: '/home/ubuntu/config.json'
  94. - name: Save output as file on local
  95. copy:
  96. content: '{{ all_services | from_yaml | to_json }}'
  97. dest: 'endpoints.json'
  98. delegate_to: localhost