docker-setup-playbook.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ---
  2. # Run the docker-compose setup on a new EC2 instance
  3. - name: Setup EC2 instance and start docker-compose services
  4. hosts: all
  5. gather_facts: yes
  6. tasks:
  7. - name: Get code from git repo
  8. include_role:
  9. name: common
  10. tasks_from: get-code-git
  11. - name: Creat bash profile file
  12. command: 'touch /home/ubuntu/.bash_profile'
  13. - name: Run setup script
  14. command: ./setup.sh
  15. args:
  16. chdir: '{{ remote_code_path }}'
  17. - name: Copy bash_profile content
  18. shell: cat ~/.bash_profile
  19. register: bash_data
  20. - name: Copy bash_profile content to bashrc for non-interactive sessions
  21. blockinfile:
  22. block: '{{ bash_data.stdout }}'
  23. path: ~/.bashrc
  24. insertbefore: BOF
  25. - name: Make sure docker is running
  26. command: systemctl start docker
  27. become: yes
  28. - name: Build packages
  29. command: yarn build:packages
  30. args:
  31. chdir: '{{ remote_code_path }}'
  32. - name: Build Node image
  33. command: yarn build:node:docker
  34. args:
  35. chdir: '{{ remote_code_path }}'
  36. - name: Run docker-compose
  37. command: yarn start
  38. args:
  39. chdir: '{{ remote_code_path }}'
  40. environment:
  41. PERSIST: true
  42. - name: Set nip.io domain with IP
  43. set_fact:
  44. nip_domain: '{{ inventory_hostname }}.nip.io'
  45. run_once: yes
  46. - name: Install and configure Caddy
  47. include_role:
  48. name: caddy_ansible.caddy_ansible
  49. apply:
  50. become: yes
  51. vars:
  52. caddy_config: "{{ lookup('template', 'templates/Caddyfile.j2') }}"
  53. caddy_systemd_capabilities_enabled: true
  54. caddy_update: false
  55. - name: Print endpoints
  56. debug:
  57. msg:
  58. - 'The services should now be accesible at:'
  59. - 'Pioneer: {{ nip_domain }}/pioneer/'
  60. - 'WebSocket RPC: {{ nip_domain }}/ws-rpc'
  61. - 'HTTP RPC: {{ nip_domain }}/http-rpc'
  62. - 'Colossus: {{ nip_domain }}/colossus'
  63. - 'Distributor: {{ nip_domain }}/distributor'
  64. - 'GraphQL server: {{ nip_domain }}/graphql'
  65. - 'Indexer: {{ nip_domain }}/indexer'