2024-04-09 11:42:03 +00:00
|
|
|
---
|
2024-04-18 15:03:37 +00:00
|
|
|
- name: "Deployer - Certbot - Renew Certificates"
|
|
|
|
command: "certbot renew"
|
|
|
|
register: task
|
|
|
|
changed_when: task.stdout.find("No renewals were attempted.") == -1
|
|
|
|
tags:
|
|
|
|
- certbot
|
|
|
|
- tls
|
2024-04-09 11:42:03 +00:00
|
|
|
|
2024-04-18 15:03:37 +00:00
|
|
|
- name: "Deployer - Certbot - Copy Certificates"
|
|
|
|
copy:
|
|
|
|
src: "/etc/letsencrypt/live/mpp/"
|
|
|
|
dest: "/root/certs/mpp/"
|
|
|
|
follow: true
|
|
|
|
register: task
|
|
|
|
tags:
|
|
|
|
- certbot
|
|
|
|
- tls
|
2024-04-09 11:42:03 +00:00
|
|
|
|
|
|
|
- name: "Deployer - MariaDB - Pull Image"
|
|
|
|
containers.podman.podman_image:
|
|
|
|
name: docker.io/mariadb
|
|
|
|
tag: latest
|
|
|
|
register: deployerTask101
|
|
|
|
|
|
|
|
- name: "Deployer - MariaDB - Run Container"
|
|
|
|
containers.podman.podman_container:
|
|
|
|
name: mariadb
|
|
|
|
image: docker.io/mariadb:latest
|
|
|
|
state: started
|
|
|
|
restart: on
|
|
|
|
network: host
|
|
|
|
volumes:
|
|
|
|
- "/root/mariadb:/var/lib/mysql"
|
|
|
|
restart_policy: always
|
|
|
|
env:
|
2024-04-16 18:19:53 +00:00
|
|
|
MYSQL_ROOT_PASSWORD: "y9ZmTmUKLaRrZ4SA"
|
2024-04-09 11:42:03 +00:00
|
|
|
register: deployerTask102
|
|
|
|
when:
|
|
|
|
- (deployerTask101 is defined and deployerTask101.changed) or deployerTask101 is undefined
|
|
|
|
tags:
|
|
|
|
- mariadb
|
|
|
|
|
|
|
|
- name: "Deployer - MariaDB - Wait"
|
|
|
|
wait_for:
|
|
|
|
host: "127.0.0.1"
|
|
|
|
port: "3306"
|
|
|
|
delay: 10
|
|
|
|
when:
|
|
|
|
- (deployerTask102 is defined and deployerTask102.changed) or deployerTask102 is undefined
|
|
|
|
tags:
|
|
|
|
- mariadb
|
|
|
|
|
2024-04-18 13:59:58 +00:00
|
|
|
- name: "Deployer - MariaDB - Upgrade"
|
|
|
|
containers.podman.podman_container_exec:
|
|
|
|
container: "mariadb"
|
|
|
|
command: "mariadb-upgrade --host=127.0.0.1 --user=root --password=y9ZmTmUKLaRrZ4SA"
|
|
|
|
register: task
|
|
|
|
ignore_errors: yes
|
|
|
|
changed_when: task.stdout.find("This installation of MariaDB is already upgraded") == -1
|
|
|
|
when:
|
|
|
|
- (deployerTask102 is defined and deployerTask102.changed) or deployerTask102 is undefined
|
|
|
|
tags:
|
|
|
|
- mariadb
|
2024-04-09 11:42:03 +00:00
|
|
|
|
|
|
|
- name: "Deployer - MariaDB - Create Users"
|
|
|
|
mysql_user:
|
|
|
|
login_host: "127.0.0.1"
|
|
|
|
login_user: root
|
2024-04-16 18:19:53 +00:00
|
|
|
login_password: "y9ZmTmUKLaRrZ4SA"
|
2024-04-09 11:42:03 +00:00
|
|
|
name: "mpp"
|
|
|
|
host: "%"
|
2024-04-16 18:19:53 +00:00
|
|
|
password: "JRrnk4Gia9gn24y5"
|
2024-04-09 11:42:03 +00:00
|
|
|
priv: "mpp.*:ALL"
|
|
|
|
vars:
|
|
|
|
ansible_python_interpreter: "/opt/ansible/bin/python3"
|
|
|
|
when:
|
|
|
|
- (deployerTask102 is defined and deployerTask102.changed) or deployerTask102 is undefined
|
|
|
|
tags:
|
|
|
|
- mariadb
|
|
|
|
|
|
|
|
- name: "Deployer - MariaDB - Create Database"
|
|
|
|
mysql_db:
|
|
|
|
login_host: "127.0.0.1"
|
|
|
|
login_user: "mpp"
|
2024-04-16 18:19:53 +00:00
|
|
|
login_password: "JRrnk4Gia9gn24y5"
|
2024-04-09 11:42:03 +00:00
|
|
|
name: "mpp"
|
|
|
|
vars:
|
|
|
|
ansible_python_interpreter: "/opt/ansible/bin/python3"
|
|
|
|
when:
|
|
|
|
- (deployerTask102 is defined and deployerTask102.changed) or deployerTask102 is undefined
|
|
|
|
tags:
|
|
|
|
- mariadb
|
|
|
|
|
2024-04-18 12:45:37 +00:00
|
|
|
- name: "Deployer - Nginx - Configure - Create Folder"
|
|
|
|
file:
|
|
|
|
path: "/root/nginx/"
|
|
|
|
state: directory
|
|
|
|
tags:
|
|
|
|
- nginx
|
|
|
|
|
|
|
|
- name: "Deployer - Nginx - Configure - Create Subfolders"
|
|
|
|
file:
|
|
|
|
dest: '/root/nginx/{{ item.path }}'
|
|
|
|
state: directory
|
|
|
|
with_filetree: './files/nginx/'
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.path }}"
|
|
|
|
when:
|
|
|
|
- item.state == 'directory'
|
|
|
|
tags:
|
|
|
|
- nginx
|
|
|
|
|
|
|
|
- name: "Deployer - Nginx - Configure - Generating & Transferring Files"
|
|
|
|
template:
|
|
|
|
src: '{{ item.src }}'
|
|
|
|
dest: '/root/nginx/{{ item.path }}'
|
|
|
|
with_filetree: './files/nginx/'
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.path }}"
|
|
|
|
when:
|
|
|
|
- item.state == 'file'
|
|
|
|
tags:
|
|
|
|
- nginx
|
|
|
|
|
|
|
|
- name: "Deployer - Nginx - Pull Image"
|
|
|
|
containers.podman.podman_image:
|
|
|
|
name: docker.io/nginx
|
|
|
|
tag: latest
|
|
|
|
register: deployerTask3
|
|
|
|
|
|
|
|
- name: "Deployer - Nginx - Run Container"
|
|
|
|
containers.podman.podman_container:
|
|
|
|
name: nginx
|
|
|
|
image: docker.io/nginx
|
|
|
|
state: started
|
|
|
|
recreate: on
|
|
|
|
network: host
|
|
|
|
volumes:
|
2024-04-18 14:50:57 +00:00
|
|
|
- "/root/nginx/html:/usr/share/nginx/html:ro"
|
2024-04-18 12:45:37 +00:00
|
|
|
- "/root/nginx/config.conf:/etc/nginx/nginx.conf:ro"
|
|
|
|
- "/root/nginx/conf/:/etc/nginx/conf.d/:ro"
|
|
|
|
- "/root/certs/:/etc/nginx/certs/:ro"
|
|
|
|
restart_policy: always
|
|
|
|
when:
|
|
|
|
- (deployerTask3 is defined and deployerTask3.changed) or deployerTask3 is undefined
|
|
|
|
tags:
|
|
|
|
- nginx
|
|
|
|
|
2024-04-18 14:11:37 +00:00
|
|
|
- name: "Deployer - Frontend - Git Operations"
|
2024-04-09 11:42:03 +00:00
|
|
|
git:
|
2024-04-18 14:11:37 +00:00
|
|
|
repo: https://github.com/MetroHege/MPP-Frontend.git
|
|
|
|
dest: /root/frontend
|
2024-04-18 12:44:45 +00:00
|
|
|
version: main
|
2024-04-18 14:11:37 +00:00
|
|
|
register: deployerTask531
|
2024-04-09 11:42:03 +00:00
|
|
|
|
2024-04-18 14:11:37 +00:00
|
|
|
- name: "Deployer - Frontend - Build Image"
|
2024-04-09 11:42:03 +00:00
|
|
|
containers.podman.podman_image:
|
2024-04-18 14:11:37 +00:00
|
|
|
name: mpp/frontend
|
2024-04-09 11:42:03 +00:00
|
|
|
tag: latest
|
2024-04-18 14:11:37 +00:00
|
|
|
path: /root/frontend
|
2024-04-09 11:42:03 +00:00
|
|
|
build:
|
|
|
|
file: Dockerfile
|
|
|
|
format: docker
|
|
|
|
cache: on
|
|
|
|
force: on
|
|
|
|
become: on
|
|
|
|
become_user: root
|
2024-04-18 14:11:37 +00:00
|
|
|
register: deployerTask532
|
2024-04-09 11:42:03 +00:00
|
|
|
when:
|
2024-04-18 14:11:37 +00:00
|
|
|
- (deployerTask531 is defined and deployerTask531.changed) or deployerTask531 is undefined
|
2024-04-09 11:42:03 +00:00
|
|
|
tags:
|
2024-04-18 14:11:37 +00:00
|
|
|
- frontend
|
2024-04-09 11:42:03 +00:00
|
|
|
|
2024-04-18 14:11:37 +00:00
|
|
|
- name: "Deployer - Frontend - Run Container"
|
2024-04-09 11:42:03 +00:00
|
|
|
containers.podman.podman_container:
|
2024-04-18 14:11:37 +00:00
|
|
|
name: frontend
|
|
|
|
image: mpp/frontend:latest
|
2024-04-09 11:42:03 +00:00
|
|
|
state: started
|
|
|
|
recreate: on
|
|
|
|
network: host
|
|
|
|
volumes:
|
2024-04-18 14:11:37 +00:00
|
|
|
- "/root/frontend/dist/:/usr/src/app/dist/"
|
|
|
|
- "/root/frontend/.env:/usr/src/app/.env"
|
2024-04-09 11:42:03 +00:00
|
|
|
restart_policy: always
|
2024-04-18 14:11:37 +00:00
|
|
|
command: "npm run build"
|
2024-04-09 11:42:03 +00:00
|
|
|
when:
|
2024-04-18 14:11:37 +00:00
|
|
|
- deployerTask532 is defined
|
|
|
|
- deployerTask532.changed
|
2024-04-09 11:42:03 +00:00
|
|
|
tags:
|
2024-04-18 14:11:37 +00:00
|
|
|
- frontend
|
2024-04-09 11:42:03 +00:00
|
|
|
|
2024-04-18 14:11:37 +00:00
|
|
|
- name: "Deployer - Backend - Git Operations"
|
2024-04-09 11:42:03 +00:00
|
|
|
git:
|
2024-04-18 14:11:37 +00:00
|
|
|
repo: https://github.com/MetroHege/MPP-Backend.git
|
|
|
|
dest: /root/backend
|
2024-04-18 12:44:45 +00:00
|
|
|
version: main
|
2024-04-18 14:11:37 +00:00
|
|
|
register: deployerTask521
|
2024-04-09 11:42:03 +00:00
|
|
|
|
2024-04-18 14:11:37 +00:00
|
|
|
- name: "Deployer - Backend - Build Image"
|
2024-04-09 11:42:03 +00:00
|
|
|
containers.podman.podman_image:
|
2024-04-18 14:11:37 +00:00
|
|
|
name: mpp/backend
|
2024-04-09 11:42:03 +00:00
|
|
|
tag: latest
|
2024-04-18 14:11:37 +00:00
|
|
|
path: /root/backend
|
2024-04-09 11:42:03 +00:00
|
|
|
build:
|
|
|
|
file: Dockerfile
|
|
|
|
format: docker
|
|
|
|
cache: on
|
|
|
|
force: on
|
|
|
|
become: on
|
|
|
|
become_user: root
|
2024-04-18 14:11:37 +00:00
|
|
|
register: deployerTask522
|
2024-04-09 11:42:03 +00:00
|
|
|
when:
|
2024-04-18 14:11:37 +00:00
|
|
|
- (deployerTask521 is defined and deployerTask521.changed) or deployerTask521 is undefined
|
2024-04-09 11:42:03 +00:00
|
|
|
tags:
|
2024-04-18 14:11:37 +00:00
|
|
|
- backend
|
2024-04-09 11:42:03 +00:00
|
|
|
|
2024-04-18 14:11:37 +00:00
|
|
|
- name: "Deployer - Backend - Run Container"
|
2024-04-09 11:42:03 +00:00
|
|
|
containers.podman.podman_container:
|
2024-04-18 14:11:37 +00:00
|
|
|
name: backend
|
|
|
|
image: mpp/backend:latest
|
2024-04-09 11:42:03 +00:00
|
|
|
state: started
|
|
|
|
recreate: on
|
|
|
|
network: host
|
|
|
|
volumes:
|
2024-04-18 14:11:37 +00:00
|
|
|
- "/root/backend/uploads:/usr/src/app/uploads"
|
|
|
|
- "/root/backend/.env:/usr/src/app/.env:ro"
|
2024-04-09 11:42:03 +00:00
|
|
|
restart_policy: always
|
2024-04-18 14:11:37 +00:00
|
|
|
command: "npm start"
|
2024-04-09 11:42:03 +00:00
|
|
|
when:
|
2024-04-18 14:11:37 +00:00
|
|
|
- deployerTask522 is defined
|
|
|
|
- deployerTask522.changed
|
2024-04-09 11:42:03 +00:00
|
|
|
tags:
|
2024-04-18 14:11:37 +00:00
|
|
|
- backend
|