123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- ---
- # Run the docker-compose setup on a new EC2 instance
- - name: Setup EC2 instance and start docker-compose services
- hosts: all
- gather_facts: yes
- tasks:
- - name: Get code from git repo
- include_role:
- name: common
- tasks_from: get-code-git
- - name: Create bash profile file
- command: 'touch /home/ubuntu/.bash_profile'
- - name: Run setup script
- command: ./setup.sh
- args:
- chdir: '{{ remote_code_path }}'
- - name: Copy bash_profile content
- shell: cat ~/.bash_profile
- register: bash_data
- - name: Copy bash_profile content to bashrc for non-interactive sessions
- blockinfile:
- block: '{{ bash_data.stdout }}'
- path: ~/.bashrc
- insertbefore: BOF
- - name: Make sure docker is running
- command: systemctl start docker
- become: yes
- - name: Build packages
- command: yarn build:packages
- args:
- chdir: '{{ remote_code_path }}'
- async: 3600
- poll: 0
- register: build_result
- - name: Check on build async task
- async_status:
- jid: '{{ build_result.ansible_job_id }}'
- register: job_result
- until: job_result.finished
- # Max number of times to check for status
- retries: 36
- # Check for the status every 100s
- delay: 100
- - name: Build Node image
- command: yarn build:node:docker
- args:
- chdir: '{{ remote_code_path }}'
- environment:
- RUNTIME_PROFILE: '{{ runtime_profile }}'
- async: 3600
- poll: 0
- register: node_build_result
- - name: Check on build node image async task
- async_status:
- jid: '{{ node_build_result.ansible_job_id }}'
- register: job_result
- until: job_result.finished
- # Max number of times to check for status
- retries: 36
- # Check for the status every 100s
- delay: 100
- - name: Run docker-compose
- command: yarn start
- args:
- chdir: '{{ remote_code_path }}'
- environment:
- RUNTIME_PROFILE: '{{ runtime_profile }}'
- PERSIST: 'true'
- COLOSSUS_1_URL: 'https://{{ inventory_hostname }}.nip.io/colossus-1/'
- DISTRIBUTOR_1_URL: 'https://{{ inventory_hostname }}.nip.io/distributor-1/'
- SKIP_CHAIN_SETUP: '{{ skip_chain_setup }}'
- async: 1800
- poll: 0
- register: compose_result
- - name: Check on yarn start task
- async_status:
- jid: '{{ compose_result.ansible_job_id }}'
- register: job_result
- until: job_result.finished
- # Max number of times to check for status
- retries: 18
- # Check for the status every 100s
- delay: 100
- - name: Set nip.io domain with IP
- set_fact:
- nip_domain: '{{ inventory_hostname }}.nip.io'
- run_once: yes
- - name: Install and configure Caddy
- include_role:
- name: caddy_ansible.caddy_ansible
- apply:
- become: yes
- vars:
- caddy_config: "{{ lookup('template', 'templates/Playground-Caddyfile.j2') }}"
- caddy_systemd_capabilities_enabled: true
- caddy_update: false
- - name: Set endpoints
- set_fact:
- all_services: |
- websocket_rpc: wss://{{ nip_domain }}/ws-rpc
- http_rpc: https://{{ nip_domain }}/http-rpc
- colossus: https://{{ nip_domain }}/colossus-1
- distributor: https://{{ nip_domain }}/distributor-1
- graphql_server: https://{{ nip_domain }}/query-node/server/graphql
- graphql_server_websocket: wss://{{ nip_domain }}/query-node/server/graphql
- indexer: https://{{ nip_domain }}/query-node/indexer/graphql
- member_faucet: https://{{ nip_domain }}/member-faucet/register
- orion: https://{{ nip_domain }}/orion/graphql
- config: https://{{ nip_domain }}/network/config.json
- stack_name: {{ stack_name }}
- run_once: yes
- - name: Print endpoints
- debug:
- msg: '{{ all_services | from_yaml }}'
- run_once: yes
- - name: Create config.json to serve as Caddy endpoint
- copy:
- content: '{{ all_services | from_yaml | to_json }}'
- dest: '/home/ubuntu/config.json'
- - name: Save output as file on local
- copy:
- content: '{{ all_services | from_yaml | to_json }}'
- dest: 'endpoints.json'
- delegate_to: localhost
|