update roles, add new role, update hostss file

This commit is contained in:
oleg.vodyanov91@gmail.com 2025-05-21 00:44:02 +04:00
parent 996a5491d6
commit 9eb43b321e
8 changed files with 95 additions and 11 deletions

2
.gitignore vendored
View File

@ -5,3 +5,5 @@
terraform/.terraform.lock.hcl
**/.terraform/
.idea/
home.lab.local.crt
home.lab.local.key

View File

@ -6,19 +6,27 @@ homelab:
hosts:
dlna:
ansible_host: dlna.home.lab.local
torrent:
ansible_host: torrent.home.lab.local
microbin:
ansible_host: microbin.home.lab.local
sandbox:
ansible_host: 192.168.0.101
dns1:
ansible_host: ns1.home.lab.local
vars:
ansible_user: ovodianov
ansible_ssh_private_key_file: ~/.ssh/home.lab.local
debian:
hosts:
pve1:
ansible_host: pve.home.lab.local
pve2:
ansible_host: pve2.home.lab.local
vars:
ansible_user: root
ansible_ssh_private_key_file: ~/.ssh/home.lab.local
children:
proxmox:
hosts:
pve1:
ansible_host: pve.home.lab.local
pve2:
ansible_host: pve2.home.lab.local
pve3:
ansible_host: pve3.home.lab.local
vars:
ansible_user: root
vars:
ansible_ssh_private_key_file: ~/.ssh/home.lab.local

View File

@ -1,4 +1,5 @@
---
# ansible-playbook -i hosts install.yml
- hosts: homelab
become: true
roles:

7
ansible/nginx.yml Normal file
View File

@ -0,0 +1,7 @@
---
# if there is only password auth set on a server then run the following
# ansible-playbook -i hosts -l <host> nginx.yml --diff
- hosts: homelab
become: true
roles:
- nginx

View File

@ -0,0 +1,6 @@
---
- name: restart nginx
systemd_service:
state: restarted
daemon_reload: true
name: nginx

View File

@ -0,0 +1,26 @@
---
- name: delete default config
file:
path: /etc/nginx/sites-available/default
state: absent
- name: copy certs
copy:
src: "{{ item }}"
dest: /root
mode: '0600'
loop:
- home.lab.local.crt
- home.lab.local.key
no_log: true
- name: copy nginx config
template:
src: "{{ hostvars[inventory_hostname].group_names[2] }}"
dest: /etc/nginx/sites-available/
- name: make a link to nginx config in sites-enabled
file:
src: /etc/nginx/sites-available/{{ hostvars[inventory_hostname].group_names[2] }}
dest: /etc/nginx/sites-enabled/{{ hostvars[inventory_hostname].group_names[2] }}
state: link

View File

@ -0,0 +1,30 @@
upstream proxmox {
server 127.0.0.1:8006;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name _;
ssl_certificate /root/home.lab.local.crt;
ssl_certificate_key /root/home.lab.local.key;
proxy_redirect off;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass https://localhost:8006;
proxy_buffering off;
client_max_body_size 0;
proxy_connect_timeout 3600s;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
send_timeout 3600s;
}
}

View File

@ -1,5 +1,9 @@
---
- name: install packages
apt:
name: qemu-guest-agent
name: "{{ item }}"
state: present
loop:
- qemu-guest-agent
- vim
- nginx