mirror of
https://github.com/MatteZ02/infra.git
synced 2026-06-26 10:35:15 +00:00
Compare commits
15 Commits
mpp
..
4fd8d7b889
| Author | SHA1 | Date | |
|---|---|---|---|
| 4fd8d7b889 | |||
| 3efc266ffe | |||
| 31468b561f | |||
| eec548f5c1 | |||
| a30224c35f | |||
| 2ed12a16fc | |||
| f0601c105c | |||
| ecfa10fe1c | |||
| eba463147c | |||
| d4796323d8 | |||
| 1b0a05421e | |||
| 2c3303ac1c | |||
| 45edbeead4 | |||
| 24c3e1c5f1 | |||
| 5f802adeb6 |
+2
-2
@@ -1,12 +1,12 @@
|
||||
[defaults]
|
||||
inventory = inventories/mpp
|
||||
inventory = inventories/matte
|
||||
hash_behaviour = merge
|
||||
gathering = smart
|
||||
transport = local
|
||||
display_skipped_hosts = false
|
||||
interpreter_python = auto_silent
|
||||
localhost_warning = false
|
||||
collections_path = collections
|
||||
collections_path = collections:~/.ansible/collections
|
||||
inject_facts_as_vars = false
|
||||
force_handlers = true
|
||||
action_warnings = false
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo -n "$CERTBOT_VALIDATION" > /root/nginx/html/.well-known/acme-challenge/$CERTBOT_TOKEN
|
||||
mkdir -p /root/nginx/html/.well-known/acme-challenge
|
||||
/opt/ansible/bin/ansible-pull -U ssh://git@github.com/MatteZ02/mpp-infra --accept-host-key --private-key ~/.ssh/id_rsa --vault-password-file ~/.ansible/vault.yml tasks.yml -t nginx &> /dev/null
|
||||
@@ -1,105 +0,0 @@
|
||||
server {
|
||||
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
server_name _;
|
||||
|
||||
expires off;
|
||||
etag off;
|
||||
if_modified_since off;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1000;
|
||||
gzip_proxied any;
|
||||
gzip_types *;
|
||||
gunzip on;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
if ($request_method !~ ^(GET|HEAD|POST)$ )
|
||||
{
|
||||
return 405;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
|
||||
listen 443 ssl default_server;
|
||||
listen [::]:443 ssl default_server;
|
||||
|
||||
server_name _;
|
||||
|
||||
http2 on;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/mpp/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/certs/mpp/privkey.pem;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES256-CCM8:DHE-RSA-AES256-CCM:ECDHE-ARIA256-GCM-SHA384:DHE-RSA-ARIA256-GCM-SHA384:ECDHE-ARIA128-GCM-SHA256:DHE-RSA-ARIA128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-CCM8:DHE-RSA-AES128-CCM';
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_session_cache shared:SSL:20m;
|
||||
ssl_session_timeout 180m;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
ssl_trusted_certificate /etc/nginx/certs/mpp/chain.pem;
|
||||
|
||||
expires off;
|
||||
etag off;
|
||||
if_modified_since off;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1000;
|
||||
gzip_proxied any;
|
||||
gzip_types *;
|
||||
gunzip on;
|
||||
|
||||
client_max_body_size 256M;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:5000/;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:3000/api/;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
location /uploads/ {
|
||||
proxy_pass http://127.0.0.1:3000/uploads/;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
location /docs/ {
|
||||
proxy_pass http://127.0.0.1:3000/docs/;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
if ($request_method !~ ^(GET|HEAD|POST|PUT|DELETE)$ )
|
||||
{
|
||||
return 405;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
user nginx;
|
||||
worker_processes 1;
|
||||
|
||||
error_log /var/log/nginx/error.log error;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '[$time_local] $host - $remote_addr - $remote_user "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
server_tokens off;
|
||||
|
||||
sendfile off;
|
||||
#tcp_nopush on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
resolver 1.1.1.1;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! "$BASH_VERSION" ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "
|
||||
==============================
|
||||
|
||||
MatteZ02 - Infra
|
||||
Install Script
|
||||
|
||||
------------------------------
|
||||
"
|
||||
|
||||
stop () {
|
||||
|
||||
echo "
|
||||
==============================
|
||||
"
|
||||
|
||||
exit 1
|
||||
|
||||
}
|
||||
|
||||
mkdir -p ~/.ssh/keys/matte &> /dev/null
|
||||
if [[ ! -f ~/.ssh/keys/matte/infra ]]
|
||||
then
|
||||
ssh-keygen -f ~/.ssh/keys/matte/infra -t ed25519 -N '' &> /dev/null
|
||||
fi
|
||||
|
||||
python3 -m venv ~/.venv/ansible &> /dev/null
|
||||
~/.venv/ansible/bin/pip3 install cryptography dnspython hvac jmespath netaddr pexpect &> /dev/null
|
||||
~/.venv/ansible/bin/pip3 install ansible &> /dev/null
|
||||
|
||||
~/.venv/ansible/bin/ansible-galaxy collection install community.general containers.podman --upgrade &> /dev/null
|
||||
|
||||
|
||||
mkdir -p ~/.ansible &> /dev/null
|
||||
|
||||
if [[ ! -f ~/.ansible/vault/matte.yml ]]
|
||||
then
|
||||
echo -n "Vault Password: "
|
||||
read PASSWORD
|
||||
echo "$PASSWORD" > ~/.ansible/vault/matte.yml
|
||||
fi
|
||||
|
||||
~/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/MatteZ02/infra -d ~/.ansible/pull/matte/infra --accept-host-key --private-key ~/.ssh/keys/matte/infra --vault-password-file ~/.ansible/vault/matte.yml tasks.yml -t installer
|
||||
|
||||
echo "
|
||||
==============================
|
||||
"
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! "$BASH_VERSION" ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "
|
||||
==============================
|
||||
|
||||
MPP - Infra
|
||||
Install Script
|
||||
|
||||
------------------------------
|
||||
"
|
||||
|
||||
stop () {
|
||||
|
||||
echo "
|
||||
==============================
|
||||
"
|
||||
|
||||
exit 1
|
||||
|
||||
}
|
||||
|
||||
mkdir -p ~/.ssh &> /dev/null
|
||||
|
||||
apt-get update &> /dev/null
|
||||
apt-get install -y python3-pip python3-venv jq git curl &> /dev/null
|
||||
python3 -m venv /opt/ansible &> /dev/null
|
||||
/opt/ansible/bin/pip3 install ansible hvac netaddr jmespath pexpect &> /dev/null
|
||||
|
||||
/opt/ansible/bin/ansible-galaxy collection install -r requirements.yml --upgrade &> /dev/null
|
||||
|
||||
mkdir -p ~/.ansible &> /dev/null
|
||||
|
||||
if [[ ! -f ~/.ansible/vault.yml ]]
|
||||
then
|
||||
echo -n "Vault Password: "
|
||||
read PASSWORD
|
||||
echo "$PASSWORD" > ~/.ansible/vault.yml
|
||||
fi
|
||||
|
||||
ssh-keyscan github.com 1> ~/.ssh/known_hosts 2> /dev/null
|
||||
|
||||
/opt/ansible/bin/ansible-pull -U ssh://git@github.com/MatteZ02/mpp-infra --accept-host-key --private-key ~/.ssh/id_rsa --vault-password-file ~/.ansible/vault.yml tasks.yml -t installer
|
||||
|
||||
echo "
|
||||
==============================
|
||||
"
|
||||
@@ -0,0 +1,6 @@
|
||||
$ANSIBLE_VAULT;1.2;AES256;matte
|
||||
62346136653335363162326162383931386537613938323936313137303431373664326165613562
|
||||
3833613232666134346465313164393265313866396438640a396463376165633535636261656161
|
||||
65666130663862303234623932643131353539623635306266663330626666383533363039653737
|
||||
3736626335343832360a373961343766633963363766393333396366343737333630636531646362
|
||||
6564
|
||||
@@ -0,0 +1,6 @@
|
||||
$ANSIBLE_VAULT;1.2;AES256;matte
|
||||
65326434306632636332646164346332366430303930656231353538613062323762303131346630
|
||||
3264653933373331373638363134633562643932326333660a393065303336306162373733316634
|
||||
61333437313261393336353235323862353538386563356132393532623439383231653665323163
|
||||
3665323733306635640a353366346639346133646331653637353530653431623132343932616465
|
||||
3466
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
matte:
|
||||
children:
|
||||
arcadiamc:
|
||||
hosts:
|
||||
rainbow.devices.waren.io:
|
||||
vars:
|
||||
ansible_user: wxl62975
|
||||
ansible_ssh_common_args: "-o StrictHostKeyChecking=accept-new -o LogLevel=error"
|
||||
@@ -1,14 +0,0 @@
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
36633733326433396538646338333139653337336137336662666538363861353933386536313164
|
||||
3532643739643661356161653064346436623531656134610a363565386431393536626238356331
|
||||
31326564633533613763366431353661663238313562333763623638653832663236633266373437
|
||||
3061373230313636610a333834303633626663353237396237376465303631396363396535393932
|
||||
61636661373930323931643062343538623231643835636662316138646161626436323937366333
|
||||
35653031363730613166353033343038616534343464393761363033356133306164646666306536
|
||||
31643061333537393333623633366463303335646336656635343434396233333032383037613934
|
||||
31653262396436336537666563376463663430356564623034316634333139656333373863623433
|
||||
63663563383139663561356539393939366333363033666636653763373339336239356334633432
|
||||
37643264386531653265643637373363633038663532333531613963633039653134633465316239
|
||||
34626366373465646535643139363539633138653133623164616431353730313461616638373166
|
||||
34626363643334643663633561336566393437356338343339313661623136323839313066356164
|
||||
65353038626338663736356330333464363366373731646636633064373031616663
|
||||
@@ -1,7 +0,0 @@
|
||||
---
|
||||
all:
|
||||
hosts:
|
||||
divari.northeurope.cloudapp.azure.com:
|
||||
vars:
|
||||
ansible_connection: local
|
||||
ansible_python_interpreter: "{{ansible_playbook_python}}"
|
||||
+3
-3
@@ -5,17 +5,17 @@ nounderline=`tput rmul`
|
||||
bold=$(tput bold)
|
||||
normal=$(tput sgr0)
|
||||
|
||||
echo "${bold}MPP / Infra / Protect${normal}"
|
||||
echo "${bold}MatteZ02 / Infra / Protect${normal}"
|
||||
action=$1
|
||||
|
||||
encrypt() {
|
||||
echo "${underline}Encrypting...${nounderline}"
|
||||
execute "ansible-vault encrypt --vault-id default@vault/mpp"
|
||||
execute "ansible-vault encrypt --vault-id matte@vault/matte"
|
||||
}
|
||||
|
||||
decrypt() {
|
||||
echo "${underline}Decrypting...${nounderline}"
|
||||
execute "ansible-vault decrypt --vault-id default@vault/mpp"
|
||||
execute "ansible-vault decrypt --vault-id matte@vault/matte"
|
||||
}
|
||||
|
||||
list() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
---
|
||||
collections:
|
||||
- community.general
|
||||
- containers.podman
|
||||
|
||||
@@ -8,18 +8,32 @@
|
||||
tasks:
|
||||
- name: "Installer"
|
||||
import_tasks: tasks/installer.yml
|
||||
vars:
|
||||
ansible_python_interpreter: "{{ ansible_facts.user_dir }}/.venv/ansible/bin/python3"
|
||||
tags:
|
||||
- installer
|
||||
- never
|
||||
|
||||
- name: "Maintenance"
|
||||
import_tasks: tasks/maintenance.yml
|
||||
vars:
|
||||
ansible_python_interpreter: "{{ ansible_facts.user_dir }}/.venv/ansible/bin/python3"
|
||||
tags:
|
||||
- maintenance
|
||||
- never
|
||||
|
||||
- name: "Deployer"
|
||||
import_tasks: tasks/deployer.yml
|
||||
vars:
|
||||
ansible_python_interpreter: "{{ ansible_facts.user_dir }}/.venv/ansible/bin/python3"
|
||||
tags:
|
||||
- deployer
|
||||
- never
|
||||
|
||||
- name: "Backup"
|
||||
import_tasks: tasks/backup.yml
|
||||
vars:
|
||||
ansible_python_interpreter: "{{ ansible_facts.user_dir }}/.venv/ansible/bin/python3"
|
||||
tags:
|
||||
- backup
|
||||
- never
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
- name: "Backup - Minecraft - Stop"
|
||||
containers.podman.podman_container:
|
||||
name: minecraft
|
||||
state: stopped
|
||||
|
||||
- name: "Backup - Minecraft - Create Directory"
|
||||
ansible.builtin.file:
|
||||
path: ~/data/backups/tmp
|
||||
state: directory
|
||||
|
||||
- name: "Backup - Minecraft - Copy"
|
||||
ansible.builtin.copy:
|
||||
src: "~/data/minecraft"
|
||||
dest: "~/data/backups/tmp/minecraft"
|
||||
follow: true
|
||||
|
||||
- name: "Backup - Minecraft - Delete"
|
||||
ansible.builtin.file:
|
||||
path: ~/data/backups/tmp/minecraft/plugins/dynmap/web/tiles
|
||||
state: absent
|
||||
|
||||
- name: "Backup - Minecraft - Save"
|
||||
community.general.archive:
|
||||
path:
|
||||
- "~/data/backups/tmp/minecraft"
|
||||
dest: "~/data/backups/minecraft-{{ ansible_facts.date_time.date }}.zip"
|
||||
format: zip
|
||||
|
||||
- name: "Backup - Minecraft - Clean"
|
||||
ansible.builtin.file:
|
||||
path: ~/data/backups/tmp/minecraft
|
||||
state: absent
|
||||
|
||||
- name: "Backup - Minecraft - Start"
|
||||
containers.podman.podman_container:
|
||||
name: minecraft
|
||||
state: started
|
||||
+21
-227
@@ -1,240 +1,34 @@
|
||||
---
|
||||
- name: "Deployer - Certbot - Renew Certificates"
|
||||
command: "certbot renew"
|
||||
containers.podman.podman_container:
|
||||
name: certbot
|
||||
image: "docker.io/certbot/certbot:latest"
|
||||
state: started
|
||||
network: host
|
||||
volumes:
|
||||
- "{{ ansible_facts.user_dir }}/data/certbot:/etc/letsencrypt"
|
||||
command: "renew"
|
||||
detach: false
|
||||
register: task
|
||||
changed_when: task.stdout.find("No renewals were attempted.") == -1
|
||||
changed_when:
|
||||
- task.stdout.find("No renewals were attempted.") == -1
|
||||
tags:
|
||||
- certbot
|
||||
- tls
|
||||
|
||||
- name: "Deployer - Certbot - Copy Certificates"
|
||||
copy:
|
||||
src: "/etc/letsencrypt/live/mpp/"
|
||||
dest: "/root/certs/mpp/"
|
||||
ansible.builtin.copy:
|
||||
src: "~/data/certbot/live/{{ cert }}/"
|
||||
dest: "~/data/certificates/{{ cert }}/"
|
||||
follow: true
|
||||
loop: "{{ certs }}"
|
||||
loop_control:
|
||||
label: "{{ cert }}"
|
||||
loop_var: "cert"
|
||||
vars:
|
||||
certs:
|
||||
- arcadiamc
|
||||
register: task
|
||||
tags:
|
||||
- certbot
|
||||
- tls
|
||||
|
||||
- name: "Deployer - MariaDB - Create Folder"
|
||||
file:
|
||||
path: "/root/mariadb"
|
||||
state: directory
|
||||
tags:
|
||||
- mariadb
|
||||
|
||||
- name: "Deployer - MariaDB - Pull Image"
|
||||
containers.podman.podman_image:
|
||||
name: docker.io/mariadb
|
||||
tag: latest
|
||||
force: on
|
||||
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:
|
||||
MYSQL_ROOT_PASSWORD: "{{ secrets.mariadb.users.root.password }}"
|
||||
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
|
||||
|
||||
- name: "Deployer - MariaDB - Upgrade"
|
||||
containers.podman.podman_container_exec:
|
||||
name: mariadb
|
||||
command: "mariadb-upgrade --host=127.0.0.1 --user=root --password={{ secrets.mariadb.users.root.password }}"
|
||||
register: task
|
||||
ignore_errors: yes
|
||||
changed_when:
|
||||
- task.stdout is defined
|
||||
- task.stdout.find("This installation of MariaDB is already upgraded") == -1
|
||||
when:
|
||||
- (deployerTask102 is defined and deployerTask102.changed) or deployerTask102 is undefined
|
||||
tags:
|
||||
- mariadb
|
||||
|
||||
- name: "Deployer - MariaDB - Create Users"
|
||||
mysql_user:
|
||||
login_host: "127.0.0.1"
|
||||
login_user: root
|
||||
login_password: "{{ secrets.mariadb.users.root.password }}"
|
||||
name: "mpp"
|
||||
host: "%"
|
||||
password: "{{ secrets.mariadb.users.mpp.password }}"
|
||||
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"
|
||||
login_password: "{{ secrets.mariadb.users.mpp.password }}"
|
||||
name: "mpp"
|
||||
vars:
|
||||
ansible_python_interpreter: "/opt/ansible/bin/python3"
|
||||
when:
|
||||
- (deployerTask102 is defined and deployerTask102.changed) or deployerTask102 is undefined
|
||||
tags:
|
||||
- mariadb
|
||||
|
||||
- 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
|
||||
force: on
|
||||
register: deployerTask3
|
||||
|
||||
- name: "Deployer - Nginx - Run Container"
|
||||
containers.podman.podman_container:
|
||||
name: nginx
|
||||
image: docker.io/nginx
|
||||
state: started
|
||||
recreate: on
|
||||
network: host
|
||||
volumes:
|
||||
- "/root/nginx/html:/usr/share/nginx/html:ro"
|
||||
- "/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
|
||||
|
||||
- name: "Deployer - Frontend - Git Operations"
|
||||
git:
|
||||
repo: https://github.com/MetroHege/MPP-Frontend.git
|
||||
dest: /root/frontend
|
||||
version: main
|
||||
register: deployerTask531
|
||||
|
||||
- name: "Deployer - Frontend - Build Image"
|
||||
containers.podman.podman_image:
|
||||
name: mpp/frontend
|
||||
tag: latest
|
||||
path: /root/frontend
|
||||
build:
|
||||
file: Dockerfile
|
||||
format: docker
|
||||
cache: off
|
||||
force: on
|
||||
register: deployerTask532
|
||||
when:
|
||||
- (deployerTask531 is defined and deployerTask531.changed) or deployerTask531 is undefined
|
||||
tags:
|
||||
- frontend
|
||||
|
||||
- name: "Deployer - Frontend - Run Container"
|
||||
containers.podman.podman_container:
|
||||
name: frontend
|
||||
image: mpp/frontend:latest
|
||||
state: started
|
||||
recreate: on
|
||||
network: host
|
||||
volumes:
|
||||
- "/root/frontend/.env:/usr/src/app/.env"
|
||||
restart_policy: always
|
||||
command: "npm start"
|
||||
when:
|
||||
- deployerTask532 is defined
|
||||
- deployerTask532.changed
|
||||
tags:
|
||||
- frontend
|
||||
|
||||
- name: "Deployer - Backend - Git Operations"
|
||||
git:
|
||||
repo: https://github.com/MetroHege/MPP-Backend.git
|
||||
dest: /root/backend
|
||||
version: main
|
||||
register: deployerTask521
|
||||
|
||||
- name: "Deployer - Backend - Build Image"
|
||||
containers.podman.podman_image:
|
||||
name: mpp/backend
|
||||
tag: latest
|
||||
path: /root/backend
|
||||
build:
|
||||
file: Dockerfile
|
||||
format: docker
|
||||
cache: off
|
||||
force: on
|
||||
register: deployerTask522
|
||||
when:
|
||||
- (deployerTask521 is defined and deployerTask521.changed) or deployerTask521 is undefined
|
||||
tags:
|
||||
- backend
|
||||
|
||||
- name: "Deployer - Backend - Run Container"
|
||||
containers.podman.podman_container:
|
||||
name: backend
|
||||
image: mpp/backend:latest
|
||||
state: started
|
||||
recreate: on
|
||||
network: host
|
||||
volumes:
|
||||
- "/root/backend/uploads:/usr/src/app/uploads"
|
||||
- "/root/backend/.env:/usr/src/app/.env:ro"
|
||||
restart_policy: always
|
||||
command: "npm start"
|
||||
when:
|
||||
- deployerTask522 is defined
|
||||
- deployerTask522.changed
|
||||
tags:
|
||||
- backend
|
||||
|
||||
+71
-174
@@ -1,25 +1,31 @@
|
||||
---
|
||||
- name: "Installer - Ansible - Python Library"
|
||||
pip:
|
||||
ansible.builtin.pip:
|
||||
name: ansible
|
||||
state: latest
|
||||
extra_args: --upgrade
|
||||
virtualenv: /opt/ansible
|
||||
virtualenv: ~/.venv/ansible
|
||||
virtualenv_command: "python3 -m venv"
|
||||
tags:
|
||||
- ansible
|
||||
|
||||
- name: "Installer - Ansible - Create Symbolic Links"
|
||||
- name: "Installer : Ansible : Create Folder"
|
||||
ansible.builtin.file:
|
||||
src: /opt/ansible/bin/{{ binary }}
|
||||
dest: /usr/bin/{{ binary }}
|
||||
path: ~/bin
|
||||
state: directory
|
||||
tags:
|
||||
- ansible
|
||||
|
||||
- name: "Installer : Ansible : Create Symbolic Links"
|
||||
ansible.builtin.file:
|
||||
src: ~/.venv/ansible/bin/{{ binary }}
|
||||
dest: ~/bin/{{ binary }}
|
||||
state: link
|
||||
vars:
|
||||
binaries:
|
||||
- ansible
|
||||
- ansible-community
|
||||
- ansible-config
|
||||
- ansible-connection
|
||||
- ansible-console
|
||||
- ansible-doc
|
||||
- ansible-galaxy
|
||||
@@ -35,199 +41,90 @@
|
||||
tags:
|
||||
- ansible
|
||||
|
||||
- name: "Installer - Ansible - Dependencies / Python Library : hvac"
|
||||
pip:
|
||||
name: hvac
|
||||
- name: "Installer - Ansible - Dependencies / Python Libraries"
|
||||
ansible.builtin.pip:
|
||||
name: "{{ library }}"
|
||||
state: latest
|
||||
extra_args: --upgrade
|
||||
virtualenv: /opt/ansible
|
||||
virtualenv: ~/.venv/ansible
|
||||
virtualenv_command: "python3 -m venv"
|
||||
tags:
|
||||
- ansible
|
||||
|
||||
- name: "Installer - Ansible - Dependencies / Python Library : netaddr"
|
||||
pip:
|
||||
name: netaddr
|
||||
state: latest
|
||||
extra_args: --upgrade
|
||||
virtualenv: /opt/ansible
|
||||
virtualenv_command: "python3 -m venv"
|
||||
tags:
|
||||
- ansible
|
||||
|
||||
- name: "Installer - Ansible - Dependencies / Python Library : jmespath"
|
||||
pip:
|
||||
name: jmespath
|
||||
state: latest
|
||||
extra_args: --upgrade
|
||||
virtualenv: /opt/ansible
|
||||
virtualenv_command: "python3 -m venv"
|
||||
tags:
|
||||
- ansible
|
||||
|
||||
- name: "Installer - Ansible - Dependencies / Python Library : pexpect"
|
||||
pip:
|
||||
name: pexpect
|
||||
state: latest
|
||||
extra_args: --upgrade
|
||||
virtualenv: /opt/ansible
|
||||
virtualenv_command: "python3 -m venv"
|
||||
tags:
|
||||
- ansible
|
||||
|
||||
- name: "Installer - Podman"
|
||||
apt:
|
||||
name: podman
|
||||
state: latest
|
||||
tags:
|
||||
- podman
|
||||
|
||||
- name: "Installer : Podman : Configure - Subordinate Ids : Users : root"
|
||||
lineinfile:
|
||||
path: /etc/subuid
|
||||
regexp: "^root"
|
||||
line: "root:100000:65536"
|
||||
|
||||
- name: "Installer : Podman : Configure - Subordinate Ids : Groups : root"
|
||||
lineinfile:
|
||||
path: /etc/subgid
|
||||
regexp: "^root"
|
||||
line: "root:100000:65536"
|
||||
|
||||
- name: "Installer - Certbot - Create Folder"
|
||||
file:
|
||||
path: "{{ path }}"
|
||||
state: directory
|
||||
vars:
|
||||
paths:
|
||||
- /root/certs/mpp
|
||||
- /etc/letsencrypt/renewal-hooks/pre
|
||||
loop: "{{ paths }}"
|
||||
libraries:
|
||||
- cryptography
|
||||
- dnspython
|
||||
- hvac
|
||||
- jmespath
|
||||
- netaddr
|
||||
- pexpect
|
||||
loop: "{{ libraries }}"
|
||||
loop_control:
|
||||
label: "{{ path }}"
|
||||
loop_var: "path"
|
||||
tags:
|
||||
- certbot
|
||||
label: "{{ library }}"
|
||||
loop_var: "library"
|
||||
|
||||
- name: "Installer - Certbot - Python Library"
|
||||
pip:
|
||||
name: certbot
|
||||
state: latest
|
||||
extra_args: --upgrade
|
||||
virtualenv: /opt/ansible
|
||||
virtualenv_command: "python3 -m venv"
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: "Installer - Certbot - Create Symbolic Links"
|
||||
- name: "Installer : Certbot : Auth Hook - Create Folder"
|
||||
ansible.builtin.file:
|
||||
src: /opt/ansible/bin/{{ binary }}
|
||||
dest: /usr/bin/{{ binary }}
|
||||
state: link
|
||||
vars:
|
||||
binaries:
|
||||
- certbot
|
||||
loop: "{{ binaries }}"
|
||||
loop_control:
|
||||
label: "{{ binary }}"
|
||||
loop_var: "binary"
|
||||
path: ~/data/certbot/auth-hooks
|
||||
state: directory
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: "Installer - Certbot - Self-Signed Certificates - Generate Private Key"
|
||||
community.crypto.openssl_privatekey:
|
||||
path: "/root/certs/mpp/privkey.pem"
|
||||
type: RSA
|
||||
size: 2048
|
||||
regenerate: never
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: "Installer - Certbot - Self-Signed Certificates - Create Certificate Signing Request"
|
||||
community.crypto.openssl_csr:
|
||||
common_name: "{{ ansible_facts.fqdn }}"
|
||||
privatekey_path: "/root/certs/mpp/privkey.pem"
|
||||
path: "/root/certs/mpp/csr.pem"
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: "Installer - Certbot - Self-Signed Certificates - Generate Certificate"
|
||||
community.crypto.x509_certificate:
|
||||
path: "/root/certs/mpp/fullchain.pem"
|
||||
privatekey_path: "/root/certs/mpp/privkey.pem"
|
||||
csr_path: "/root/certs/mpp/csr.pem"
|
||||
provider: selfsigned
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: "Installer - Certbot - Self-Signed Certificates - Copy Certificate"
|
||||
copy:
|
||||
src: "/root/certs/mpp/fullchain.pem"
|
||||
dest: "/root/certs/mpp/chain.pem"
|
||||
force: true
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: "Installer - Certbot - Auth Hook"
|
||||
copy:
|
||||
src: "../files/certbot/nginx.sh"
|
||||
dest: "/etc/letsencrypt/renewal-hooks/pre/nginx.sh"
|
||||
- name: "Installer : Certbot : Auth Hook - Download"
|
||||
ansible.builtin.get_url:
|
||||
url: "https://git.waren.io/warengroup/acme-dns-auth/raw/branch/master/acme-dns-auth.py"
|
||||
dest: "~/data/certbot/auth-hooks/acme-dns.py"
|
||||
mode: '700'
|
||||
force: true
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: "Installer - Certbot - Create Certificates"
|
||||
command: "certbot certonly --cert-name {{ cert.name }} --manual --preferred-challenges http-01 --email {{ cert.email }} --server https://acme-v02.api.letsencrypt.org/directory --agree-tos -n --manual-auth-hook /etc/letsencrypt/renewal-hooks/pre/nginx.sh --debug-challenges --preferred-chain='ISRG Root X1' --key-type rsa -d {{ cert.domains | join(' -d ') }}"
|
||||
- name: "Installer : Certbot : Create Certificates"
|
||||
containers.podman.podman_container:
|
||||
name: certbot
|
||||
image: "docker.io/certbot/certbot:latest"
|
||||
state: started
|
||||
network: host
|
||||
volumes:
|
||||
- "{{ ansible_facts.user_dir }}/data/certbot:/etc/letsencrypt"
|
||||
command: "certonly --cert-name {{ cert.name }} --manual --preferred-challenges dns-01 --email {{ cert.email }} --server https://acme-v02.api.letsencrypt.org/directory --agree-tos -n --manual-auth-hook /etc/letsencrypt/auth-hooks/acme-dns.py --debug-challenges --key-type rsa -d {{ cert.domains | join(' -d ') }}"
|
||||
detach: false
|
||||
register: task
|
||||
changed_when: task.stdout.find("Certificate not yet due for renewal; no action taken.") == -1
|
||||
changed_when:
|
||||
- task.stdout.find("Certificate not yet due for renewal; no action taken.") == -1
|
||||
loop: "{{ certs }}"
|
||||
loop_control:
|
||||
label: "{{ cert.name }}"
|
||||
loop_var: "cert"
|
||||
vars:
|
||||
cert:
|
||||
name: mpp
|
||||
email: "{{ secrets.certbot.email }}"
|
||||
domains:
|
||||
- "{{ ansible_facts.fqdn }}"
|
||||
certs:
|
||||
- name: arcadiamc
|
||||
email: mattez02.contact@gmail.com
|
||||
domains:
|
||||
- arcadiamc.wgi.fi
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: "Installer - MariaDB - Dependencies / Python Library : pymysql"
|
||||
pip:
|
||||
name: pymysql
|
||||
state: latest
|
||||
extra_args: --upgrade
|
||||
virtualenv: /opt/ansible
|
||||
virtualenv_command: "python3 -m venv"
|
||||
tags:
|
||||
- mariadb
|
||||
|
||||
- name: "Installer - MariaDB - Dependencies / Package : mariadb-client"
|
||||
apt:
|
||||
name: "mariadb-client"
|
||||
state: latest
|
||||
when:
|
||||
- ansible_facts.distribution == "Debian" or ansible_facts.distribution == "Ubuntu" or ansible_facts.distribution == "Linux Mint"
|
||||
tags:
|
||||
- mariadb
|
||||
|
||||
- name: "Installer - Schedule - Setup"
|
||||
cron:
|
||||
name: PATH
|
||||
env: yes
|
||||
value: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
|
||||
- name: "Installer - Schedule - Maintenance"
|
||||
cron:
|
||||
name: Maintenance
|
||||
- name: "Installer : Schedule : Maintenance"
|
||||
ansible.builtin.cron:
|
||||
name: "Matte - Infra - Maintenance"
|
||||
hour: "*/3"
|
||||
minute: "0"
|
||||
job: "/opt/ansible/bin/ansible-pull -U ssh://git@github.com/MatteZ02/mpp-infra --accept-host-key --private-key ~/.ssh/id_rsa --vault-password-file ~/.ansible/vault.yml tasks.yml -t maintenance"
|
||||
job: "~/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/MatteZ02/infra -d ~/.ansible/pull/matte/infra --accept-host-key --private-key ~/.ssh/keys/matte/infra --vault-password-file ~/.ansible/vault/matte.yml tasks.yml -t maintenance"
|
||||
tags:
|
||||
- cron
|
||||
|
||||
- name: "Installer - Schedule - Deployer"
|
||||
cron:
|
||||
name: Deployer
|
||||
- name: "Installer : Schedule : Deployer"
|
||||
ansible.builtin.cron:
|
||||
name: "Matte - Infra - Deployer"
|
||||
minute: "*/5"
|
||||
job: "/opt/ansible/bin/ansible-pull -U ssh://git@github.com/MatteZ02/mpp-infra --accept-host-key --private-key ~/.ssh/id_rsa --vault-password-file ~/.ansible/vault.yml tasks.yml -t deployer"
|
||||
job: "~/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/MatteZ02/infra -d ~/.ansible/pull/matte/infra --accept-host-key --private-key ~/.ssh/keys/matte/infra --vault-password-file ~/.ansible/vault/matte.yml tasks.yml -t deployer"
|
||||
tags:
|
||||
- cron
|
||||
|
||||
- name: "Installer : Schedule : Backup"
|
||||
ansible.builtin.cron:
|
||||
name: "Matte - Infra - Backup"
|
||||
hour: "4"
|
||||
minute: "0"
|
||||
job: "~/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/MatteZ02/infra -d ~/.ansible/pull/matte/infra --accept-host-key --private-key ~/.ssh/keys/matte/infra --vault-password-file ~/.ansible/vault/matte.yml tasks.yml -t backup"
|
||||
tags:
|
||||
- cron
|
||||
|
||||
+27
-28
@@ -1,37 +1,36 @@
|
||||
---
|
||||
- name: "Maintenance - OS Update"
|
||||
apt:
|
||||
upgrade: dist
|
||||
update_cache: yes
|
||||
|
||||
- name: "Maintenance - Ansible : Dependencies - Python Library : hvac"
|
||||
pip:
|
||||
name: hvac
|
||||
- name: "Installer - Ansible - Dependencies / Python Libraries"
|
||||
ansible.builtin.pip:
|
||||
name: "{{ library }}"
|
||||
state: latest
|
||||
extra_args: --upgrade
|
||||
virtualenv: /opt/ansible
|
||||
virtualenv: ~/.venv/ansible
|
||||
virtualenv_command: "python3 -m venv"
|
||||
vars:
|
||||
libraries:
|
||||
- cryptography
|
||||
- dnspython
|
||||
- hvac
|
||||
- jmespath
|
||||
- netaddr
|
||||
- pexpect
|
||||
loop: "{{ libraries }}"
|
||||
loop_control:
|
||||
label: "{{ library }}"
|
||||
loop_var: "library"
|
||||
|
||||
- name: "Maintenance - Ansible : Dependencies - Python Library : netaddr"
|
||||
pip:
|
||||
name: netaddr
|
||||
- name: "Maintenance : Ansible : Update"
|
||||
ansible.builtin.pip:
|
||||
name: ansible
|
||||
state: latest
|
||||
extra_args: --upgrade
|
||||
virtualenv: /opt/ansible
|
||||
virtualenv: ~/.venv/ansible
|
||||
virtualenv_command: "python3 -m venv"
|
||||
|
||||
- name: "Maintenance - Ansible : Dependencies - Python Library : jmespath"
|
||||
pip:
|
||||
name: jmespath
|
||||
state: latest
|
||||
extra_args: --upgrade
|
||||
virtualenv: /opt/ansible
|
||||
virtualenv_command: "python3 -m venv"
|
||||
|
||||
- name: "Maintenance - Ansible : Dependencies - Python Library : pexpect"
|
||||
pip:
|
||||
name: pexpect
|
||||
state: latest
|
||||
extra_args: --upgrade
|
||||
virtualenv: /opt/ansible
|
||||
virtualenv_command: "python3 -m venv"
|
||||
- name: "Maintenance : Podman : Prune"
|
||||
containers.podman.podman_prune:
|
||||
container: yes
|
||||
image: yes
|
||||
image_filters:
|
||||
dangling_only: no
|
||||
volume: yes
|
||||
|
||||
Reference in New Issue
Block a user