Tip

Check out the repository on GitHub

DHCP

STATE: unstable

TESTS: Playbook

API Docs: Core - KEA

Service Docs: DHCP

Contribution

Thanks to @KalleDK for helping with the Reservation module!


Definition

For basic parameters see: Basic

ansibleguy.opnsense.dhcp_reservation

Definition

Parameter

Type

Required

Default

Aliases

Comment

ip

string

true

ip_address

IP address to offer to the client

mac

string

false for state changes, else true

mac_address

MAC/Ether address of the client in question

subnet

string

false for state changes, else true

-

Subnet this reservation belongs to

hostname

string

false

-

Offer a hostname to the client

description

string

false

-

Optional description

reload

boolean

false

true

-

If the running config should be reloaded on change - this may take some time. For mass-managing items you might want to reload it ‘manually’ after all changes are done => using the ansibleguy.opnsense.reload module.


Examples

ansibleguy.opnsense.dhcp_reservation

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

    ansibleguy.opnsense.list:
      target: 'dhcp_reservation'

  tasks:
    - name: Example
      ansibleguy.opnsense.dhcp_reservation:
        ip: '192.168.0.1'
        subnet: '192.168.0.0/24'
        mac: 'aa:aa:aa:bb:bb:bb'
        # hostname: 'test'
        # description: ''
        # state: 'present'
        # reload: true
        # debug: false

    - name: Adding
      ansibleguy.opnsense.dhcp_reservation:
        subnet: '192.168.0.0/24'
        ip: '192.168.0.1'
        mac: 'aa:aa:aa:bb:bb:bb'

    - name: Removing
      ansibleguy.opnsense.dhcp_reservation:
        ip: '192.168.0.1'
        state: 'absent'

    - name: Listing
      ansibleguy.opnsense.list:
      #  target: 'dhcp_reservation'
      register: existing_entries

    - name: Show existing reservations
      ansible.builtin.debug:
        var: existing_entries.data