-
-
Save MagedSaeed/3d0b00ee615eed09177a6f2e0fd19bef to your computer and use it in GitHub Desktop.
[Ansible Playbook] Setup UFW to allow only incoming ssh connections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
become: true | |
tasks: | |
- name: ensure ufw installed | |
apt: name=ufw update_cache=true | |
- name: ufw deny incoming | |
ufw: | |
direction: incoming | |
proto: any | |
policy: deny | |
notify: | |
- reload ufw | |
- name: ufw allow outgoing | |
ufw: | |
direction: outgoing | |
proto: any | |
policy: allow | |
notify: | |
- reload ufw | |
- name: ufw allow ssh | |
ufw: | |
rule: allow | |
name: OpenSSH | |
notify: | |
- reload ufw | |
- name: enable ufw service | |
ufw: | |
state: enabled | |
handlers: | |
- name: reload ufw | |
ufw: | |
state: reloaded |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment