|
@@ -0,0 +1,66 @@
|
|
|
+---
|
|
|
+# 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: Creat 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 }}'
|
|
|
+
|
|
|
+ - name: Build Node image
|
|
|
+ command: yarn build:node:docker
|
|
|
+ args:
|
|
|
+ chdir: '{{ remote_code_path }}'
|
|
|
+
|
|
|
+ - name: Run docker-compose
|
|
|
+ command: yarn start
|
|
|
+ args:
|
|
|
+ chdir: '{{ remote_code_path }}'
|
|
|
+ async: 180
|
|
|
+ poll: 0
|
|
|
+
|
|
|
+ - 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/Caddyfile.j2') }}"
|
|
|
+ caddy_systemd_capabilities_enabled: true
|
|
|
+ caddy_update: false
|