From f3feb35046278d25df57209b2cd9855e1d89d122 Mon Sep 17 00:00:00 2001 From: matt01671 <matt01671@gmail.com> Date: Tue, 5 May 2020 19:16:59 +1200 Subject: [PATCH] ready for react --- ansible/all-in-one.yaml | 68 +++++++++---------- ansible/host_vars/nectar.yaml | 10 +-- ansible/hosts | 1 - ansible/roles/react-build/defaults/main.yaml | 2 - ansible/roles/react-build/tasks/main.yaml | 66 +++++------------- .../templates/docker-compose.yaml.j2 | 9 --- 6 files changed, 57 insertions(+), 99 deletions(-) delete mode 100755 ansible/roles/react-build/defaults/main.yaml mode change 100755 => 100644 ansible/roles/react-build/tasks/main.yaml delete mode 100755 ansible/roles/react-build/templates/docker-compose.yaml.j2 diff --git a/ansible/all-in-one.yaml b/ansible/all-in-one.yaml index b9180c8..33bb47a 100755 --- a/ansible/all-in-one.yaml +++ b/ansible/all-in-one.yaml @@ -1,43 +1,43 @@ -# - hosts: localhost -# vars_files: -# - host_vars/nectar.yaml -# gather_facts: true - -# roles: -# - role: openstack-common -# - role: openstack-volume -# - role: openstack-security-group -# - role: cluster-security-group -# - role: openstack-instance - -# - hosts: instances -# vars_files: -# - host_vars/docker.yaml -# gather_facts: true - -# roles: -# - role: openstack-proxy -# - role: all-dependencies -# - role: all-mount -# - role: all-docker - -# - hosts: dbs +- hosts: localhost + vars_files: + - host_vars/nectar.yaml + gather_facts: true + + roles: + - role: openstack-common + - role: openstack-volume + - role: openstack-security-group + - role: cluster-security-group + - role: openstack-instance + +- hosts: instances + vars_files: + - host_vars/docker.yaml + gather_facts: true + + roles: + - role: openstack-proxy + - role: all-dependencies + - role: all-mount + - role: all-docker + +- hosts: web + vars_files: + - host_vars/react.yaml + gather_facts: true + + roles: + - role: react-build + +- hosts: dbs -# roles: -# - role: cluster-build + roles: + - role: cluster-build - hosts: master roles: - role: slaves-cluster -# - hosts: web -# vars_files: -# - host_vars/react.yaml -# gather_facts: true - - # roles: - # - role: react-build - \ No newline at end of file diff --git a/ansible/host_vars/nectar.yaml b/ansible/host_vars/nectar.yaml index 42a7206..6824b82 100755 --- a/ansible/host_vars/nectar.yaml +++ b/ansible/host_vars/nectar.yaml @@ -24,7 +24,7 @@ security_groups: description: "Security group for HTTP" protocol: tcp port_range_min: 80 - port_range_max: 80 + port_range_max: 3000 remote_ip_prefix: 0.0.0.0/0 - name: couchDB-cluster4 description: "Security group for CouchDB cluster" @@ -67,10 +67,10 @@ instances: volumes: ['dbvolume3'] meta: group: slaves - # - name: web - # volumes: ['webvolume'] - # meta: - # group: web + - name: web + volumes: ['webvolume'] + meta: + group: web instance_image: 45225edb-66d8-4fd0-bf41-132a31a18166 instance_key_name: test-moh diff --git a/ansible/hosts b/ansible/hosts index 2df0052..db10760 100644 --- a/ansible/hosts +++ b/ansible/hosts @@ -1,7 +1,6 @@ [web] [master] -172.26.129.221 ansible_host=172.26.129.221 [slaves] diff --git a/ansible/roles/react-build/defaults/main.yaml b/ansible/roles/react-build/defaults/main.yaml deleted file mode 100755 index 051c48b..0000000 --- a/ansible/roles/react-build/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -react_dir: react-app \ No newline at end of file diff --git a/ansible/roles/react-build/tasks/main.yaml b/ansible/roles/react-build/tasks/main.yaml old mode 100755 new mode 100644 index 9b24b58..6dc7c71 --- a/ansible/roles/react-build/tasks/main.yaml +++ b/ansible/roles/react-build/tasks/main.yaml @@ -1,53 +1,23 @@ ---- -- name: Create React directory - tags: 'react-app' +- name: make sure the latest npm is installed + tags: 'node' become: yes - file: - path: "{{ react_dir }}" - owner: "{{ ansible_user }}" - group: "{{ ansible_user }}" - recurse: yes - state: directory + npm: + name: npm + global: yes + state: latest -- name: Configure compose - tags: 'react-app' +- name: install pm2 server + tags: 'pm2' become: yes - template: - src: docker-compose.yaml.j2 - dest: "{{ react_dir }}/docker-compose.yaml" - owner: "{{ ansible_user }}" - group: "{{ ansible_user }}" + npm: + name: pm2 + global: yes + state: latest -- name: Log into Dockerhub +- name: install react + tags: 'react' become: yes - docker_login: - username: matt01671 - password: comp90024 - -# - name: Configure ignore -# tags: 'react-app' -# become: yes -# template: -# src: .dockerignore -# dest: "{{ react_dir }}/.dockerignore" -# owner: "{{ ansible_user }}" -# group: "{{ ansible_user }}" - -# - name: Configure Dockerfile -# tags: 'react-app' -# become: yes -# template: -# src: Dockerfile -# dest: "{{ react_dir }}/Dockerfile" -# owner: "{{ ansible_user }}" -# group: "{{ ansible_user }}" - -- name: Run docker compose - tags: 'react-app' - become: yes - docker_compose: - project_src: "{{ react_dir }}" - pull: yes - state: present - remove_orphans: yes - recreate: always \ No newline at end of file + npm: + name: create-react-app + global: yes + state: present \ No newline at end of file diff --git a/ansible/roles/react-build/templates/docker-compose.yaml.j2 b/ansible/roles/react-build/templates/docker-compose.yaml.j2 deleted file mode 100755 index 27e82b4..0000000 --- a/ansible/roles/react-build/templates/docker-compose.yaml.j2 +++ /dev/null @@ -1,9 +0,0 @@ -version: '3.7' - -services: - - react_app: - image: matt01671/comp90024:1.0 - restart: always - ports: - - 8001:8000 \ No newline at end of file -- GitLab