Skip to content

Instantly share code, notes, and snippets.

@andreacarriero
Created February 28, 2018 21:46
Show Gist options
  • Save andreacarriero/f9b09815b0f5d3290f3cf859bbb6fdb8 to your computer and use it in GitHub Desktop.
Save andreacarriero/f9b09815b0f5d3290f3cf859bbb6fdb8 to your computer and use it in GitHub Desktop.
[Ansible Playbook] Setup UFW for SSH and OpenVPN than install OpenVPN management script
---
- hosts: vpn
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 OpenSSH
ufw:
rule: allow
name: OpenSSH
notify:
- reload ufw
- name: ufw allow OpenVPN UDP
ufw:
rule: allow
direction: in
proto: udp
port: 1194
notify:
- reload ufw
- name: enable ufw service
ufw:
state: enabled
- name: download openvpn management script
get_url:
url: https://raw.githubusercontent.com/Angristan/OpenVPN-install/master/openvpn-install.sh
dest: /root/openvpn-management.sh
mode: 755
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