generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add opnsense config role #155
Open
DonGiovanni83
wants to merge
16
commits into
puzzle:main
Choose a base branch
from
DonGiovanni83:feature/add_opnsense_config_role
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2fe05d6
Init opnsense_configure role
DonGiovanni83 b14e2e2
Init system settings tasks in opnsense_config
DonGiovanni83 592a52e
Add system setting logging to opnsense_config role
DonGiovanni83 e6dd142
Add firewall_aliases to role
DonGiovanni83 0355e86
Add firewall rules to config role
DonGiovanni83 6b87667
Simplify role
DonGiovanni83 c473390
Add firewall rules var to default vars of role
DonGiovanni83 70ef101
Add user config to configure role
DonGiovanni83 d974d15
Add interfaces assignments to role
DonGiovanni83 44bbcc2
Refactor role variable structure
DonGiovanni83 9e49298
Add system HA to config role
DonGiovanni83 38b5605
Add conditionals to configurations in role
DonGiovanni83 5ddf346
Cleanup role
DonGiovanni83 7e8fb55
Document config rule
DonGiovanni83 66e5f2e
Add changelog fragment for new role
DonGiovanni83 a81c050
Lint role meta.yml
DonGiovanni83 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
minor_changes: | ||
- puzzle.opnsense.opnsense_configure - Addition of an ansible role to the collection |
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
- name: converge | ||
hosts: all | ||
become: true | ||
vars: | ||
system: | ||
access: | ||
users: | ||
- username: simple_user | ||
password: pass1234 | ||
high_availability: | ||
synchronize_interface: LAN | ||
synchronize_config_to_ip: 224.0.0.240 | ||
synchronize_peer_ip: 224.0.0.241 | ||
disable_preempt: true | ||
disconnect_dialup_interfaces: true | ||
synchronize_states: true | ||
remote_system_username: opnsense | ||
remote_system_password: v3rys3cure | ||
services_to_synchronize: | ||
- aliases | ||
- rules | ||
- ipsec | ||
settings: | ||
general: | ||
hostname: "firewall01" | ||
domain: "test.local" | ||
timezone: "Europe/Zurich" | ||
logging: | ||
preserve_logs: 10 | ||
interfaces: | ||
assignments: | ||
- device: em0 | ||
identifier: opt2 | ||
description: VAGRANT | ||
- device: em1 | ||
identifier: lan | ||
description: LAN | ||
- device: em2 | ||
identifier: wan | ||
description: WAN | ||
- device: em3 | ||
identifier: opt1 | ||
description: DMZ | ||
firewall: | ||
aliases: | ||
- name: TestAliasTypeHost | ||
type: host | ||
statistics: false | ||
description: Test Alias with type Host | ||
content: 10.0.0.1 | ||
- name: TestAliasTypeNetwork | ||
type: network | ||
statistics: false | ||
description: Test Alias with type Network | ||
content: 10.0.0.0/24 | ||
rules: | ||
- interface: lan | ||
description: Block SSH on LAN | ||
destination: | ||
port: 22 | ||
action: block | ||
roles: | ||
- role: puzzle.opnsense.opnsense_configure |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
scenario: | ||
name: opnsense_config | ||
test_sequence: | ||
# - dependency not relevant unless we have requirements | ||
- destroy | ||
- syntax | ||
- create | ||
- converge | ||
- idempotence | ||
- verify | ||
- destroy | ||
|
||
driver: | ||
name: vagrant | ||
parallel: true | ||
|
||
platforms: | ||
- name: "22.7" | ||
hostname: false | ||
box: puzzle/opnsense | ||
box_version: "22.7" | ||
memory: 1024 | ||
cpus: 2 | ||
instance_raw_config_args: | ||
- 'vm.guest = :freebsd' | ||
- 'ssh.sudo_command = "%c"' | ||
- 'ssh.shell = "/bin/sh"' | ||
- name: "23.1" | ||
box: puzzle/opnsense | ||
hostname: false | ||
box_version: "23.1" | ||
memory: 1024 | ||
cpus: 2 | ||
instance_raw_config_args: | ||
- 'vm.guest = :freebsd' | ||
- 'ssh.sudo_command = "%c"' | ||
- 'ssh.shell = "/bin/sh"' | ||
- name: "23.7" | ||
box: puzzle/opnsense | ||
hostname: false | ||
box_version: "23.7" | ||
memory: 1024 | ||
cpus: 2 | ||
instance_raw_config_args: | ||
- 'vm.guest = :freebsd' | ||
- 'ssh.sudo_command = "%c"' | ||
- 'ssh.shell = "/bin/sh"' | ||
- name: "24.1" | ||
box: puzzle/opnsense | ||
hostname: false | ||
box_version: "24.1" | ||
memory: 1024 | ||
cpus: 2 | ||
instance_raw_config_args: | ||
- 'vm.guest = :freebsd' | ||
- 'ssh.sudo_command = "%c"' | ||
- 'ssh.shell = "/bin/sh"' | ||
- name: "24.7" | ||
box: puzzle/opnsense | ||
hostname: false | ||
box_version: "24.7" | ||
memory: 1024 | ||
cpus: 2 | ||
instance_raw_config_args: | ||
- 'vm.guest = :freebsd' | ||
- 'ssh.sudo_command = "%c"' | ||
- 'ssh.shell = "/bin/sh"' | ||
|
||
provisioner: | ||
name: ansible | ||
env: | ||
ANSIBLE_VERBOSITY: 3 | ||
verifier: | ||
name: ansible | ||
options: | ||
become: true |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: Verify connectivity to server | ||
hosts: all | ||
tasks: | ||
- name: Ping the server | ||
ansible.builtin.ping: |
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 |
---|---|---|
@@ -0,0 +1,116 @@ | ||
opnsense_configure - OPNsense configuration role | ||
========= | ||
|
||
This role provides a generic approach to configure OPNsense instances by populating host variables | ||
according to this roles defaults specification. | ||
|
||
Role Variables | ||
-------------- | ||
|
||
The variables must be structured in a way that each puzzle.opnsense module has its own block. Each module related block | ||
is then structured just like the corresponding module parameters as documented in the modules themselves. | ||
The top level structure must be structured as follows: | ||
```yaml | ||
--- | ||
system: | ||
access: | ||
users: [] # list of users, where the users follows the system_access_users module parameter structure | ||
high_availability: | ||
# system_high_availability_settings module parameters | ||
settings: | ||
general: | ||
# system_settings_general module parameters | ||
logging: | ||
# system_settings_logging module parameters | ||
|
||
interfaces: | ||
assignments: [] # list of interface assignments, where the users follows the interfaces_assignments module parameter structure | ||
|
||
firewall: | ||
aliases: [] # list of aliases, where the users follows the firewall_alias module parameter structure | ||
rules: [] # list of rules, where the users follows the firewall_rules module parameter structure | ||
``` | ||
|
||
|
||
Example Playbook | ||
---------------- | ||
|
||
The usage of the role is straight forward, however the main thought should go into the building of the | ||
host variables. An example execution could look like this: | ||
|
||
```yaml | ||
--- | ||
- name: converge | ||
hosts: all | ||
become: true | ||
vars: | ||
system: | ||
access: | ||
users: | ||
- username: simple_user | ||
password: pass1234 | ||
high_availability: | ||
synchronize_interface: LAN | ||
synchronize_config_to_ip: 224.0.0.240 | ||
synchronize_peer_ip: 224.0.0.241 | ||
disable_preempt: true | ||
disconnect_dialup_interfaces: true | ||
synchronize_states: true | ||
remote_system_username: opnsense | ||
remote_system_password: v3rys3cure | ||
services_to_synchronize: | ||
- aliases | ||
- rules | ||
- ipsec | ||
settings: | ||
general: | ||
hostname: "firewall01" | ||
domain: "test.local" | ||
timezone: "Europe/Zurich" | ||
logging: | ||
preserve_logs: 10 | ||
interfaces: | ||
assignments: | ||
- device: em0 | ||
identifier: opt2 | ||
description: VAGRANT | ||
- device: em1 | ||
identifier: lan | ||
description: LAN | ||
- device: em2 | ||
identifier: wan | ||
description: WAN | ||
- device: em3 | ||
identifier: opt1 | ||
description: DMZ | ||
firewall: | ||
aliases: | ||
- name: TestAliasTypeHost | ||
type: host | ||
statistics: false | ||
description: Test Alias with type Host | ||
content: 10.0.0.1 | ||
- name: TestAliasTypeNetwork | ||
type: network | ||
statistics: false | ||
description: Test Alias with type Network | ||
content: 10.0.0.0/24 | ||
rules: | ||
- interface: lan | ||
description: Block SSH on LAN | ||
destination: | ||
port: 22 | ||
action: block | ||
roles: | ||
- role: puzzle.opnsense.opnsense_configure | ||
|
||
``` | ||
|
||
License | ||
------- | ||
|
||
GPLv3 | ||
|
||
Author Information | ||
------------------ | ||
- Fabio Bertagna (github.com/dongiovanni83) |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
# defaults file for opnsense_configure | ||
|
||
# | ||
# System variables should be provided in this structure | ||
# | ||
# system: | ||
# access: | ||
# users: [] # see system_access_users task args for user entry structure | ||
# high_availability: | ||
# disable_preempt: | ||
# disconnect_dialup_interfaces: | ||
# synchronize_states: | ||
# synchronize_interface: | ||
# sync_compatibility: | ||
# synchronize_peer_ip: | ||
# synchronize_config_to_ip: | ||
# remote_system_username: | ||
# remote_system_password: | ||
# services_to_synchronize: | ||
# settings: | ||
# general: | ||
# hostname: | ||
# domain: | ||
# timezone: | ||
# logging: | ||
# max_log_file_size_mb: | ||
# preserve_logs: | ||
|
||
system: | ||
settings: | ||
access: | ||
# Interface related variables: | ||
# | ||
# interfaces: | ||
# assignments: [] | ||
interfaces: | ||
|
||
# | ||
# Firewall related variables should be provided in this structure | ||
# | ||
# firewall: | ||
# aliases: [] | ||
# rules: [] | ||
firewall: |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
galaxy_info: | ||
author: Fabio Bertagna <bertagna@puzzle.ch> | ||
company: Puzzle ITC | ||
license: GPL-3.0-only | ||
min_ansible_version: 2.1 | ||
galaxy_tags: | ||
- opnsense | ||
|
||
dependencies: [ ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest rename this file to
changelogs/fragments/155-add-opnsense-config-role.yml