Tip

Check out the repository on GitHub

2 - Reload

STATE: stable

TESTS: Playbook

Info

This module can reload the running/loaded configuration for a specified part of the OPNSense system.

Most modules of this collection will automatically reload its relevant running config on change - but you can speed up mass-management of items when disabling reload on single module-calls (reload: false), and do it afterward using THIS module.

Alternatively you can use the ansibleguy.opnsense.service module with action reload if you like it better.

Definition

Definition

Parameter

Type

Required

Default

Aliases

Comment

target

string

true

-

tgt, t

What part of the running config should be reloaded. One of: ‘alias’, ‘route’, ‘cron’, ‘unbound’, ‘syslog’, ‘ipsec’, ‘shaper’, ‘monit’, ‘wireguard’, ‘interface_vlan’, ‘interface_vxlan’, ‘frr’, ‘webproxy’

For basic parameters see: Basic

Examples

- hosts: localhost
  gather_facts: no
  module_defaults:
    group/ansibleguy.opnsense.all:
      firewall: 'opnsense.template.ansibleguy.net'
      api_credential_file: '/home/guy/.secret/opn.key'

  tasks:
    - name: Reloading aliases
      ansibleguy.opnsense.reload:
        target: 'alias'

    - name: Reloading routes
      ansibleguy.opnsense.reload:
        target: 'route'

Practical

- hosts: localhost
  gather_facts: no
  module_defaults:
    group/ansibleguy.opnsense.all:
      firewall: 'opnsense.template.ansibleguy.net'
      api_credential_file: '/home/guy/.secret/opn.key'

  tasks:
    - name: Adding routes
      ansibleguy.opnsense.route:
        network: "{{ item.nw }}"
        gateway: "{{ item.gw }}"
        reload: false
      loop:
        - {nw: '10.206.0.0/16', gw: 'VPN_GW'}
        - {nw: '10.67.0.0/16', gw: 'VPN2_GW'}

    - name: Adding DNS overrides
      ansibleguy.opnsense.unbound_host:
        hostname: "{{ item.host }}"
        domain: 'opnsense.template.ansibleguy.net'
        value: "{{ item.value }}"
        reload: false
      loop:
        - {host: 'a', value: '192.168.0.1'}
        - {host: 'd', value: '192.168.0.5'}

    - name: Reloading
      ansibleguy.opnsense.reload:
        target: "{{ item }}"
      loop:
        - 'route'
        - 'unbound'