Forge Home

opnsense

Manage OPNsense firewalls

4,391 downloads

285 latest version

3.1 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 2.3.0 (latest)
  • 2.2.0
  • 2.1.0
  • 2.0.0
  • 1.5.0
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.1
  • 1.1.0
  • 1.0.0
released Jun 17th 2021
This version is compatible with:
  • Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x
  • Puppet >= 6.21.0 < 8.0.0
  • , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'andeman-opnsense', '1.0.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add andeman-opnsense
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install andeman-opnsense --version 1.0.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

andeman/opnsense — version 1.0.0 Jun 17th 2021

Unit Tests Acceptance Tests Puppet Forge Puppet Forge Downloads

opnsense

Table of Contents

Description

The opnsense module configures OPNsense firewalls with custom types and providers.

It allows administrators to manage an OPNsense firewall directly via the sysutils/puppet-agent opnsense plugin and/or manage multiple firewalls from a bastion host running a puppet-agent with opn-cli installed.

Setup

OPNsense firewall

If you want to manage your firewall directly with a puppet-agent running on the device.

Requirements

Install requirements

Menu->Firmware->Plugins

Install Plugin: sysutils/puppet-agent

Bastion host

If you want a bastion hosts running a puppet-agent which could manage multiple firewalls via https API calls.

Requirements

  • opn-cli
  • puppetlabs/resource_api (puppet < 6.0)

Install requirements

$packages = [
    'python3',
    'python3-pip',
]
$pip_packages = [
    'opn-cli',
]
package { $packages:
    ensure => present,
}
-> package { $pip_packages:
    ensure   => latest,
    provider => 'pip3',
}

Usage

Creating the device

If you want to manage an OPNsense Firewall, you need to supply credentials and connection information for the device.

For each device you want to mange create an opnsense_device type:

opnsense_device { 'opnsense.example.com':
  url        => 'https://opnsense.example.com/api',
  api_key    => 'your_api_key',
  api_secret => Sensitive('your_api_secret'),
  timeout    => 60,
  ssl_verify => true,
  ca         => '/path/to/ca.pem',
  ensure     => 'present',
}

To create an api_key and api_secret see: https://docs.opnsense.org/development/how-tos/api.html#creating-keys.

If you want to use ssl verification (recommended):

To download the default self-signed cert, open the OPNsense web gui and go to System->Trust->Certificates. Search for the name: "Web GUI SSL certificate" and press the "export user cert" button.

If you use a ca signed certificate, go to System->Trust->Authorities and press the "export CA cert" button to download the ca.

Save the cert or ca and make sure the puppet agent is able to read it.

Configure your OPNsense Firewall

If you have at least one configured opnsense_device, you could start to use other puppet types to manage the device.

In the following example we use the opnsense_plugin type to manage the installed plugins on the opnsense device "opnsense.example.com":

opnsense_plugin { 'os-helloworld':
  device => 'opnsense.example.com',
  ensure => 'present',
}

See Reference.md for all available puppet types to manage your OPNsense firewall.

Reference

Types and providers are documented in REFERENCE.md.

Limitations

For an extensive list of supported operating systems, see metadata.json

CI/CD

CI/CD is done via Github Actions.

Development

Install the you following requirements if you need alocal development environment:

Create the local development environment

scripts/create_test_env 

Running unit tests

Unit testing uses pdk

scripts/unit_tests

Running acceptance tests

Acceptance testing uses puppet litmus.

scripts/acceptance_tests

Teardown

scripts/remove_test_env

Contributing

Please use the GitHub issues functionality to report any bugs or requests for new features. Feel free to fork and submit pull requests for potential contributions.

All contributions must pass all existing tests, new features should provide additional unit/acceptance tests.