-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
108 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,84 @@ | ||
Role Name | ||
========= | ||
|
||
A brief description of the role goes here. | ||
|
||
Requirements | ||
------------ | ||
|
||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. | ||
Configure FreeBSD [pf](https://docs.freebsd.org/en/books/handbook/firewalls/#firewalls-pf) firewall. | ||
|
||
Role Variables | ||
-------------- | ||
|
||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. | ||
### `pf_rules_debug` | ||
|
||
Boolean controlling whether to dump final rules set during playbook run for debugging purposes. Default `false`. | ||
|
||
### `pf_rules_global`, `pf_rules_group`, `pf_rules_host` | ||
|
||
Variables storing actual `pf` rules on global, group and host level. The variables are merged across all groups, contrasting with the default Ansible behaviour (overwrite). When the host is a member of several groups, it will receive rules from _all_ of these groups. | ||
|
||
Rules are also sorted alphabetically by the key name, which impacts the ordering of output rules in the final `/etc/pf.conf`. This allows very precise ordering of rules even in case of complex architectures with many groups and hosts. It is recommended that a consistent ranges are used across all projects, for example ranges 000-100 and 900-999 for global rules, 101-499 for group rules and 500-899 for host-level rules. | ||
|
||
Examples: | ||
|
||
``` | ||
# host_vars/localhost.yaml | ||
pf_rules_host: | ||
500 nfs: | ||
- nfs="{ sunrpc, nfsd-status, nfsd-keepalive, nfsd, lockd, 2050 }" | ||
- pass in quick inet6 proto { tcp, udp } from 2a02:390:79ef::/48 to any port $nfs | ||
# group_vars/all.yaml | ||
pf_rules_global: | ||
900 policy: | ||
- pass in log | ||
000 lo0: | ||
- set skip on lo0 | ||
# group_vars/group1.yaml | ||
pf_rules_group: | ||
101 rules for group1: | ||
- pass in quick inet proto tcp from 192.168.0.0/16 to any port = ssh | ||
# group_vars/group2.yaml | ||
pf_rules_group: | ||
201 rules for group2: | ||
- "pass in quick inet6 proto tcp from { 2001:db8::/32 } to any port = ssh" | ||
``` | ||
|
||
Dependencies | ||
------------ | ||
This will produce the following `pf.conf`: | ||
|
||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. | ||
``` | ||
# 000 lo0 | ||
set skip on lo0 | ||
# 101 rules for group1 | ||
pass in quick inet proto tcp from 192.168.0.0/16 to any port = ssh | ||
# 201 rules for group2 | ||
pass in quick inet6 proto tcp from { 2001:db8::/32 } to any port = ssh | ||
# 500 nfs | ||
nfs="{ sunrpc, nfsd-status, nfsd-keepalive, nfsd, lockd, 2050 }" | ||
pass in quick inet6 proto { tcp, udp } from 2a02:390:79ef::/48 to any port $nfs | ||
# 900 policy | ||
pass in log | ||
``` | ||
|
||
Example Playbook | ||
---------------- | ||
|
||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: | ||
Assuming the above example variables configured in respective group and host files: | ||
|
||
- hosts: servers | ||
roles: | ||
- { role: username.rolename, x: 42 } | ||
``` | ||
- hosts: localhost | ||
become: true | ||
become_user: root | ||
name: Test | ||
roles: | ||
- kravietz.freebsd.pf | ||
``` | ||
|
||
License | ||
------- | ||
|
||
BSD | ||
GPL-3.0-or-later | ||
|
||
Author Information | ||
------------------ | ||
|
||
An optional section for the role authors to include contact information, or a website (HTML is not allowed). | ||
Paweł Krawczyk https://krvtz.net/ |