diff --git a/deploy/ansible/roles/platform/tasks/main.yml b/deploy/ansible/roles/platform/tasks/main.yml new file mode 100644 index 0000000..b0add77 --- /dev/null +++ b/deploy/ansible/roles/platform/tasks/main.yml @@ -0,0 +1,68 @@ +--- +- name: Create Platform deployment directory + ansible.builtin.file: + path: /opt/platform + state: directory + owner: deploy + group: deploy + mode: "0755" + +- name: Copy Platform backend source + ansible.builtin.copy: + src: "{{ playbook_dir }}/../../platform/backend/" + dest: /opt/platform/platform/backend/ + owner: deploy + group: deploy + mode: "0644" + +- name: Copy Platform frontend source + ansible.builtin.copy: + src: "{{ playbook_dir }}/../../platform/frontend/" + dest: /opt/platform/platform/frontend/ + owner: deploy + group: deploy + mode: "0644" + +- name: Copy Platform backend Dockerfile + ansible.builtin.copy: + src: "{{ playbook_dir }}/../../platform-backend.Dockerfile" + dest: /opt/platform/platform-backend.Dockerfile + owner: deploy + group: deploy + mode: "0644" + +- name: Copy Platform frontend Dockerfile + ansible.builtin.copy: + src: "{{ playbook_dir }}/../../platform-frontend.Dockerfile" + dest: /opt/platform/platform-frontend.Dockerfile + owner: deploy + group: deploy + mode: "0644" + +- name: Copy Platform Nginx configuration + ansible.builtin.copy: + src: "{{ playbook_dir }}/../../platform-nginx.conf" + dest: /opt/platform/platform-nginx.conf + owner: deploy + group: deploy + mode: "0644" + +- name: Copy Platform Compose file + ansible.builtin.copy: + src: "{{ playbook_dir }}/../../platform-compose.yml" + dest: /opt/platform/platform-compose.yml + owner: deploy + group: deploy + mode: "0644" + +- name: Build and start Platform + ansible.builtin.command: + cmd: docker compose -f /opt/platform/platform-compose.yml up -d --build + become: true + become_user: deploy + register: platform_compose_result + changed_when: true + +- name: Show Platform deployment result + ansible.builtin.debug: + var: platform_compose_result.stdout_lines \ No newline at end of file diff --git a/deploy/ansible/site.yml b/deploy/ansible/site.yml index 046ff52..3a7b0c9 100644 --- a/deploy/ansible/site.yml +++ b/deploy/ansible/site.yml @@ -1,9 +1,15 @@ --- -- name: Prepare Platfom infrastructure +- name: Deploy Platform hosts: test become: true gather_facts: true roles: - common - - docker \ No newline at end of file + - docker + + tasks: + - name: Deploy Platform on devops-test + ansible.builtin.include_role: + name: platform + when: inventory_hostname == "devops-test" \ No newline at end of file diff --git a/deploy/platform-compose.yml b/deploy/platform-compose.yml index 48da3ca..1af4c64 100644 --- a/deploy/platform-compose.yml +++ b/deploy/platform-compose.yml @@ -2,8 +2,8 @@ services: platform-backend: build: - context: .. - dockerfile: deploy/platform-backend.Dockerfile + context: /opt/platform + dockerfile: platform-backend.Dockerfile restart: unless-stopped @@ -40,8 +40,8 @@ services: platform-frontend: build: - context: .. - dockerfile: deploy/platform-frontend.Dockerfile + context: /opt/platform + dockerfile: platform-frontend.Dockerfile restart: unless-stopped