Added Caddy setup (template is on the todo), change prompts to secrets file and added support for dnf package manager (Fedora,...)

This commit is contained in:
Sam Geyskens 2024-08-03 22:11:58 +02:00
parent 247dc3ee34
commit f72fcd454b
6 changed files with 66 additions and 22 deletions

View File

@ -0,0 +1,3 @@
1. Pas het bestand secrets.yml aan met de correcte info
2. Versleutel het bestand met Ansible Vault: `ansible-vault encrypt secrets.yml`
3. voer het playbook uit: `ansible-playbook deploy.yml --ask-vault-pas`

View File

@ -1,15 +1,8 @@
--- ---
- name: Deploy Stamhoofd application - name: Deploy Stamhoofd application
hosts: development hosts: development
vars_prompt: vars_files:
- name: mysql_root_password - secrets.yml
prompt: "Enter MySQL root password"
private: yes
- name: mysql_user_password
prompt: "Enter MySQL user password"
private: yes
- name: coredns_domain
prompt: "Kies het hoofddomein waar Stamhoofd op moet draaien"
roles: roles:
- install_packages - install_packages
- clone - clone
@ -18,15 +11,8 @@
- name: Setup MySQL and deploy to production - name: Setup MySQL and deploy to production
hosts: production hosts: production
vars_prompt: vars_files:
- name: mysql_root_password - secrets.yaml
prompt: "Enter MySQL root password"
private: yes
- name: mysql_user_password
prompt: "Enter MySQL user password"
private: yes
- name: coredns_domain
prompt: "Kies het hoofddomein waar Stamhoofd op moet draaien"
roles: roles:
- install_packages - install_packages
- mysql_setup - mysql_setup

View File

@ -0,0 +1,13 @@
---
- name: Configure Caddy
template:
src: Caddyfile.j2
dest: /etc/caddy/Caddyfile
notify:
- Restart Caddy
- name: Ensure Caddy is running
service:
name: caddy
state: started
enabled: yes

View File

@ -0,0 +1,10 @@
#moet nog aangepast worden :-)
{{ caddy_domain }} {
reverse_proxy localhost:8080
log {
output file /var/log/caddy/access.log
}
errors {
404 /404.html
}
}

View File

@ -1,23 +1,51 @@
--- ---
- name: Install MySQL - name: Install MySQL on Debian-based systems
apt: apt:
name: mysql-server name: mysql-server
state: present state: present
when: ansible_facts['os_family'] == "Debian"
- name: Install Git - name: Install MySQL on RedHat-based systems
dnf:
name: mysql-server
state: present
when: ansible_facts['os_family'] == "RedHat"
- name: Install Git on Debian-based systems
apt: apt:
name: git name: git
state: present state: present
when: ansible_facts['os_family'] == "Debian"
- name: Install Caddy - name: Install Git on RedHat-based systems
dnf:
name: git
state: present
when: ansible_facts['os_family'] == "RedHat"
- name: Install Caddy on Debian-based systems
apt: apt:
name: caddy name: caddy
state: present state: present
when: ansible_facts['os_family'] == "Debian"
- name: Install CoreDNS - name: Install Caddy on RedHat-based systems
dnf:
name: caddy
state: present
when: ansible_facts['os_family'] == "RedHat"
- name: Install CoreDNS on Debian-based systems
apt: apt:
name: coredns name: coredns
state: present state: present
when: ansible_facts['os_family'] == "Debian"
- name: Install CoreDNS on RedHat-based systems
dnf:
name: coredns
state: present
when: ansible_facts['os_family'] == "RedHat"
- name: Install NVM - name: Install NVM
shell: | shell: |

4
secrets.yml Normal file
View File

@ -0,0 +1,4 @@
mysql_root_password: mysql_root_password
mysql_user_password: mysql_user_password
coredns_domain: your_coredns_domain
caddy_domain: your_caddy_domain