main.yml 3.3 KB

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