
- Enable ufw and by default deny incoming traffic - in other roles: if ufw (role) is enabled, then allow necessary ports
47 lines
817 B
JSON
47 lines
817 B
JSON
[
|
|
{
|
|
"name": "install packages",
|
|
"become": true,
|
|
"ansible.builtin.apt": {
|
|
"update_cache": true,
|
|
"pkg": [
|
|
"nginx"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "Check wether enabling UFW would be considered a changed",
|
|
"check_mode": true,
|
|
"community.general.ufw": {
|
|
"state": "enabled",
|
|
"register": "ufw_enable_check"
|
|
}
|
|
},
|
|
{
|
|
"name": "Allow port 80 in ufw",
|
|
"community.general.ufw": {
|
|
"rule": "allow",
|
|
"port": "80",
|
|
"proto": "tcp"
|
|
},
|
|
"when": "not ufw_enable_check.changed"
|
|
},
|
|
{
|
|
"name": "Allow port 443 in ufw",
|
|
"community.general.ufw": {
|
|
"rule": "allow",
|
|
"port": "443",
|
|
"proto": "tcp"
|
|
},
|
|
"when": "not ufw_enable_check.changed"
|
|
},
|
|
{
|
|
"name": "restart service",
|
|
"become": true,
|
|
"ansible.builtin.systemd_service": {
|
|
"state": "restarted",
|
|
"name": "nginx"
|
|
}
|
|
}
|
|
]
|
|
|