Created
February 28, 2018 19:25
-
-
Save andreacarriero/1b5adcde61906fb5c6342bfa88ceeb0c 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