add files
This commit is contained in:
parent
6c5e01af67
commit
247dc3ee34
35
deploy.yml
Executable file
35
deploy.yml
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
- name: Deploy Stamhoofd application
|
||||||
|
hosts: development
|
||||||
|
vars_prompt:
|
||||||
|
- name: mysql_root_password
|
||||||
|
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:
|
||||||
|
- install_packages
|
||||||
|
- clone
|
||||||
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
- name: Setup MySQL and deploy to production
|
||||||
|
hosts: production
|
||||||
|
vars_prompt:
|
||||||
|
- name: mysql_root_password
|
||||||
|
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:
|
||||||
|
- install_packages
|
||||||
|
- mysql_setup
|
||||||
|
- coredns_setup
|
||||||
|
- caddy_setup
|
||||||
|
- deploy
|
5
hosts.ini
Executable file
5
hosts.ini
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
[development]
|
||||||
|
dev_server ansible_host=dev.stamhoofd.geyskens.eu ansible_user=sam
|
||||||
|
|
||||||
|
[production]
|
||||||
|
prod_server ansible_host=prod.stamhoofd.geyskens.eu ansible_user=sam
|
6
roles/build/tasks/main.yml
Executable file
6
roles/build/tasks/main.yml
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: Build application
|
||||||
|
shell: |
|
||||||
|
cd /home/your_user/stamhoofd
|
||||||
|
./build.sh
|
||||||
|
register: build_output
|
6
roles/clone/tasks/main.yml
Executable file
6
roles/clone/tasks/main.yml
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: Clone repository
|
||||||
|
git:
|
||||||
|
repo: 'https://github.com/stamhoofd/stamhoofd.git'
|
||||||
|
dest: /home/sam/stamhoofd
|
||||||
|
register: git_output
|
13
roles/coredns_setup/tasks/main.yml
Executable file
13
roles/coredns_setup/tasks/main.yml
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
- name: Configure CoreDNS
|
||||||
|
template:
|
||||||
|
src: coredns.j2
|
||||||
|
dest: /etc/coredns/Corefile
|
||||||
|
notify:
|
||||||
|
- Restart CoreDNS
|
||||||
|
|
||||||
|
- name: Ensure CoreDNS is running
|
||||||
|
service:
|
||||||
|
name: coredns
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
23
roles/coredns_setup/templates/coredns.j2
Executable file
23
roles/coredns_setup/templates/coredns.j2
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
# All domains with the stamhoofd TLD are resolved to localhost
|
||||||
|
stamhoofd."{{ coredns_domain }}" {
|
||||||
|
log
|
||||||
|
|
||||||
|
template IN A {
|
||||||
|
answer "{{ .Name }} 60 IN A 127.0.0.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
template IN AAAA {
|
||||||
|
answer "{{ .Name }} 60 IN AAAA 127.0.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# This prevents Firefox from using DoH
|
||||||
|
# https://support.mozilla.org/en-US/kb/canary-domain-use-application-dnsnet
|
||||||
|
use-application-dns.net {
|
||||||
|
log
|
||||||
|
}
|
||||||
|
|
||||||
|
# Forward other DNS requests to Google DNS, or Quad9 DNS
|
||||||
|
. {
|
||||||
|
forward . 8.8.8.8 9.9.9.9
|
||||||
|
}
|
10
roles/deploy/tasks/main.yml
Executable file
10
roles/deploy/tasks/main.yml
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
- name: Copy build to production
|
||||||
|
copy:
|
||||||
|
src: /home/your_user/stamhoofd/build/
|
||||||
|
dest: /home/your_user/stamhoofd_prod/
|
||||||
|
delegate_to: prod_server
|
||||||
|
|
||||||
|
- name: Restart application
|
||||||
|
shell: |
|
||||||
|
systemctl restart stamhoofd
|
27
roles/install_packages/tasks/main.yml
Executable file
27
roles/install_packages/tasks/main.yml
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
- name: Install MySQL
|
||||||
|
apt:
|
||||||
|
name: mysql-server
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install Git
|
||||||
|
apt:
|
||||||
|
name: git
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install Caddy
|
||||||
|
apt:
|
||||||
|
name: caddy
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install CoreDNS
|
||||||
|
apt:
|
||||||
|
name: coredns
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install NVM
|
||||||
|
shell: |
|
||||||
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
|
||||||
|
export NVM_DIR="$HOME/.nvm"
|
||||||
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||||
|
nvm install node
|
16
roles/mysql_setup/tasks/main.yml
Executable file
16
roles/mysql_setup/tasks/main.yml
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
- name: Create MySQL database
|
||||||
|
mysql_db:
|
||||||
|
name: stamhoofd_db
|
||||||
|
state: present
|
||||||
|
login_user: root
|
||||||
|
login_password: "{{ mysql_root_password }}"
|
||||||
|
|
||||||
|
- name: Create MySQL user
|
||||||
|
mysql_user:
|
||||||
|
name: stamhoofd_user
|
||||||
|
password: "{{ mysql_user_password }}"
|
||||||
|
priv: 'stamhoofd_db.*:ALL'
|
||||||
|
state: present
|
||||||
|
login_user: root
|
||||||
|
login_password: "{{ mysql_root_password }}"
|
Loading…
Reference in New Issue
Block a user