main.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. COLOSSUS_1_TRANSACTOR_URI: '//Colossus1'
  46. SKIP_NODE: 'true'
  47. SKIP_CHAIN_SETUP: '{{ skip_chain_setup }}'
  48. args:
  49. chdir: '{{ remote_code_path }}'
  50. async: 1800
  51. poll: 0
  52. register: compose_result
  53. - name: Check on yarn start task
  54. async_status:
  55. jid: '{{ compose_result.ansible_job_id }}'
  56. register: job_result
  57. until: job_result.finished
  58. # Max number of times to check for status
  59. retries: 18
  60. # Check for the status every 100s
  61. delay: 100
  62. - name: Set websocket and http endpoint variables
  63. set_fact:
  64. nip_domain: '{{ inventory_hostname }}.nip.io'
  65. run_once: yes
  66. - name: Install and configure Caddy
  67. include_role:
  68. name: caddy_ansible.caddy_ansible
  69. apply:
  70. become: yes
  71. vars:
  72. caddy_config: "{{ lookup('template', 'templates/Caddyfile.j2') }}"
  73. caddy_systemd_capabilities_enabled: true
  74. caddy_update: false
  75. - name: Set endpoints
  76. set_fact:
  77. all_services: |
  78. websocket_rpc: wss://{{ nip_domain }}/ws-rpc
  79. http_rpc: https://{{ nip_domain }}/http-rpc
  80. colossus: https://{{ nip_domain }}/colossus-1
  81. distributor: https://{{ nip_domain }}/distributor-1
  82. graphql_server: https://{{ nip_domain }}/query-node/server/graphql
  83. graphql_server_websocket: wss://{{ nip_domain }}/query-node/server/graphql
  84. indexer: https://{{ nip_domain }}/query-node/indexer/graphql
  85. member_faucet: https://{{ nip_domain }}/member-faucet/register
  86. config: https://{{ nip_domain }}/network/config.json
  87. run_once: yes
  88. - name: Print endpoints
  89. debug:
  90. msg: '{{ all_services | from_yaml }}'
  91. run_once: yes
  92. - name: Create config.json to serve as Caddy endpoint
  93. copy:
  94. content: '{{ all_services | from_yaml | to_json }}'
  95. dest: '/home/ubuntu/config.json'
  96. - name: Save output as file on local
  97. copy:
  98. content: '{{ all_services | from_yaml | to_json }}'
  99. dest: 'endpoints.json'
  100. delegate_to: localhost