[fix] role:nginx

This commit is contained in:
roydfalk 2024-06-06 14:50:15 +02:00
parent 8084f33676
commit 958630599d
3 changed files with 95 additions and 1 deletions

View file

@ -1,3 +1,3 @@
{ {
"var_nginx_auto_reload_interval": null
} }

View file

@ -0,0 +1,86 @@
[
{
"name": "install packages",
"become": true,
"ansible.builtin.apt": {
"update_cache": true,
"pkg": [
"nginx"
]
}
},
{
<<<<<<< HEAD
=======
"name": "generate dhparams file",
"become": true,
"ansible.builtin.command": {
"cmd": "openssl dhparam -out /etc/nginx/dhparam 4096"
},
"args": {
"creates": "/etc/nginx/dhparam"
}
},
{
"name": "place hardening config",
"become": true,
"ansible.builtin.copy": {
"src": "ssl-hardening.conf",
"dest": "/etc/nginx/ssl-hardening.conf"
}
},
{
"name": "ufw | check",
"become": true,
"check_mode": true,
"community.general.ufw": {
"state": "enabled"
},
"register": "ufw_enable_check"
},
{
"name": "ufw | allow port 80",
"when": "not ufw_enable_check.changed",
"become": true,
"community.general.ufw": {
"rule": "allow",
"port": "80",
"proto": "tcp"
}
},
{
"name": "ufw | allow port 443",
"when": "not ufw_enable_check.changed",
"become": true,
"community.general.ufw": {
"rule": "allow",
"port": "443",
"proto": "tcp"
}
},
{
"name": "auto reload",
"when": "auto_reload_interval != None",
"become": true,
"ansible.builtin.cron": {
"name": "nginx_auto_reload",
"disabled": true,
"minute": "0",
"hour": "*/{{var_nginx_auto_reload_interval | string}}",
"day": "*",
"month": "*",
"weekday": "*",
"job": "systemctl reload nginx"
}
},
{
>>>>>>> f55f317 ([fix] role:nginx)
"name": "restart service",
"become": true,
"ansible.builtin.systemd_service": {
"state": "restarted",
"name": "nginx"
}
}
]

8
roles/nginx/vardef.json Normal file
View file

@ -0,0 +1,8 @@
{
"auto_reload_interval": {
"description": "in hours",
"nullable": true,
"type": "integer",
"mandatory": false
}
}