Skip to content

Commit

Permalink
rename oto-NAT-module to use 'nat_' prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
ansibleguy committed Feb 7, 2025
1 parent 6ac7009 commit b7f1d35
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 35 deletions.
2 changes: 1 addition & 1 deletion docs/source/modules/2_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ In most cases the returned type of this module ist a list of dictionaries.
:header: "Parameter", "Type", "Required", "Default", "Aliases", "Comment"
:widths: 15 10 10 10 10 45

"target","string","true","\-","tgt, t","What part of the running config should be queried/listed. One of: 'alias', 'rule', 'route', 'cron', 'syslog', 'package', 'unbound_general', 'unbound_acl', 'unbound_host', 'unbound_dot', 'unbound_forward', 'unbound_host_alias', 'ipsec_cert', 'shaper_pipe', 'shaper_queue', 'shaper_rule', 'monit_service', 'monit_test', 'monit_alert', 'wireguard_server', 'wireguard_peer', 'interface_lagg', 'interface_vlan', 'interface_vxlan', 'source_nat', 'frr_bfd', 'frr_bgp_general', 'frr_bgp_neighbor', 'frr_bgp_prefix_list', 'frr_bgp_community_list', 'frr_bgp_as_path', 'frr_bgp_route_map', 'frr_ospf_general', 'frr_ospf_prefix_list', 'frr_ospf_interface', 'frr_ospf_route_map', 'frr_ospf_network', 'frr_ospf3_general', 'frr_ospf3_interface', 'frr_rip', 'bind_general', 'bind_blocklist', 'bind_acl', 'bind_domain', 'bind_record', 'interface_vip', 'webproxy_general', 'webproxy_cache', 'webproxy_parent', 'webproxy_traffic', 'webproxy_forward', 'webproxy_acl', 'webproxy_icap', 'webproxy_auth', 'webproxy_remote_acl', 'webproxy_pac_proxy', 'webproxy_pac_match', 'webproxy_pac_rule', 'unbound_dnsbl', 'one_to_one', 'interface_gre', 'postfix_general', 'postfix_domain', 'postfix_recipient', 'postfix_recipientbcc', 'postfix_sender', 'postfix_senderbcc', 'postfix_sendercanonical', 'postfix_headercheck', 'postfix_address'"
"target","string","true","\-","tgt, t","What part of the running config should be queried/listed. One of: 'alias', 'rule', 'route', 'cron', 'syslog', 'package', 'unbound_general', 'unbound_acl', 'unbound_host', 'unbound_dot', 'unbound_forward', 'unbound_host_alias', 'ipsec_cert', 'shaper_pipe', 'shaper_queue', 'shaper_rule', 'monit_service', 'monit_test', 'monit_alert', 'wireguard_server', 'wireguard_peer', 'interface_lagg', 'interface_vlan', 'interface_vxlan', 'nat_source', 'nat_one_to_one', 'frr_bfd', 'frr_bgp_general', 'frr_bgp_neighbor', 'frr_bgp_prefix_list', 'frr_bgp_community_list', 'frr_bgp_as_path', 'frr_bgp_route_map', 'frr_ospf_general', 'frr_ospf_prefix_list', 'frr_ospf_interface', 'frr_ospf_route_map', 'frr_ospf_network', 'frr_ospf3_general', 'frr_ospf3_interface', 'frr_rip', 'bind_general', 'bind_blocklist', 'bind_acl', 'bind_domain', 'bind_record', 'interface_vip', 'webproxy_general', 'webproxy_cache', 'webproxy_parent', 'webproxy_traffic', 'webproxy_forward', 'webproxy_acl', 'webproxy_icap', 'webproxy_auth', 'webproxy_remote_acl', 'webproxy_pac_proxy', 'webproxy_pac_match', 'webproxy_pac_rule', 'unbound_dnsbl', 'interface_gre', 'postfix_general', 'postfix_domain', 'postfix_recipient', 'postfix_recipientbcc', 'postfix_sender', 'postfix_senderbcc', 'postfix_sendercanonical', 'postfix_headercheck', 'postfix_address'"

.. include:: ../_include/param_basic.rst

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
.. _modules_one_to_one:
.. _modules_nat_one_to_one:

.. include:: ../_include/head.rst

==============
One-To-One NAT
NAT One-To-One
==============

**STATE**: unstable

**TESTS**: `Playbook <https://github.com/ansibleguy/collection_opnsense/blob/latest/tests/one_to_one.yml>`_
**TESTS**: `Playbook <https://github.com/ansibleguy/collection_opnsense/blob/latest/tests/nat_one_to_one.yml>`_

**API Docs**: `one_to_one <https://docs.opnsense.org/development/api/core/firewall.html>`_

**Service Docs**: `one_to_one <https://docs.opnsense.org/manual/nat.html#one-to-one>`_

Contribution
************

Thanks to `@jiuka <https://github.com/jiuka>`_ for developing this module!

----

Info
****

Expand Down Expand Up @@ -51,6 +58,8 @@ Definition

.. include:: ../_include/param_basic.rst

----

Usage
*****

Expand All @@ -69,14 +78,14 @@ Examples
api_credential_file: '/home/guy/.secret/opn.key'
ansibleguy.opnsense.list:
target: 'one_to_one'
target: 'nat_one_to_one'
tasks:
# add optional parameters commented-out
# required ones normally
# add their default values to get a brief overview of how the module works
- name: Example
ansibleguy.opnsense.one_to_one:
ansibleguy.opnsense.nat_one_to_one:
#sequence: 1
interface: 'lan'
#type: binnat
Expand All @@ -93,7 +102,7 @@ Examples
- name: Listing jobs
ansibleguy.opnsense.list:
# target: 'one_to_one'
# target: 'nat_one_to_one'
register: existing_one_to_one
- name: Printing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.. _modules_source_nat:
.. _modules_nat_source:

.. include:: ../_include/head.rst

==========
Source NAT
NAT Source
==========

**STATE**: stable

**TESTS**: `Playbook <https://github.com/ansibleguy/collection_opnsense/blob/latest/tests/source_nat.yml>`_
**TESTS**: `Playbook <https://github.com/ansibleguy/collection_opnsense/blob/latest/tests/nat_source.yml>`_

**API Docs**: `Core - Firewall <https://docs.opnsense.org/development/api/core/firewall.html>`_

Expand All @@ -32,6 +32,7 @@ This plugin has some limitations you need to know of:
* per example see menu: 'Interface - Assignments - Interface ID (in brackets)'
* this brings problems if the interface-names are not the same on both nodes when using HA-setups

----

Info
****
Expand Down Expand Up @@ -81,6 +82,8 @@ Module alias: ansibleguy.opnsense.snat

.. include:: ../_include/param_basic.rst

----

Usage
*****

Expand All @@ -107,15 +110,15 @@ Examples
firewall: 'opnsense.template.ansibleguy.net'
api_credential_file: '/home/guy/.secret/opn.key'
ansibleguy.opnsense.source_nat:
ansibleguy.opnsense.nat_source:
match_fields: ['description']
ansibleguy.opnsense.list:
target: 'source_nat'
target: 'nat_source'
tasks:
- name: Example
ansibleguy.opnsense.source_nat:
ansibleguy.opnsense.nat_source:
description: 'example'
match_fields: ['description']
target: '192.168.0.1'
Expand All @@ -139,7 +142,7 @@ Examples
# reload: true
- name: Adding rule
ansibleguy.opnsense.source_nat:
ansibleguy.opnsense.nat_source:
description: 'test1'
source: '192.168.0.0/24'
destination: '10.0.0.0/24'
Expand All @@ -148,7 +151,7 @@ Examples
# match_fields: ['description']
- name: Disabling rule
ansibleguy.opnsense.source_nat:
ansibleguy.opnsense.nat_source:
description: 'test1'
source: '192.168.0.0/24'
destination: '10.0.0.0/24'
Expand All @@ -159,15 +162,15 @@ Examples
- name: Listing
ansibleguy.opnsense.list:
# target: 'source_nat'
# target: 'nat_source'
register: existing_entries
- name: Printing peers
ansible.builtin.debug:
var: existing_entries.data
- name: Removing rule
ansibleguy.opnsense.source_nat:
ansibleguy.opnsense.nat_source:
description: 'test1'
state: 'absent'
# match_fields: ['description']
5 changes: 3 additions & 2 deletions docs/source/modules/savepoint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Here is the basic process:
It currently just works with the 'Firewall' plugin:

- :ref:`ansibleguy.opnsense.rule <modules_rule>`
- :ref:`ansibleguy.opnsense.source_nat <modules_source_nat>`
- :ref:`ansibleguy.opnsense.nat_source <modules_nat_source>`
- :ref:`ansibleguy.opnsense.nat_one_to_one <modules_nat_one_to_one>`

Definition
**********
Expand All @@ -38,7 +39,7 @@ Definition

"name","string","false","'create'","Action to execute. One of: 'create', 'revert', 'apply', 'cancel_rollback', 'cancel'"
"revision","string","false, true if action is one of 'apply', 'revert' or 'cancel_rollback'","\-","Savepoint revision to apply, revert or cancel_rollback"
"controller","string","false","'filter'","Controller to manage the savepoint of. One of: 'source_nat', 'filter'"
"controller","string","false","'filter'","Controller to manage the savepoint of. One of: 'source_nat', 'filter', 'one_to_one'"
"api_module","string","false","'firewall'","Module to manage the savepoint of. Currently only supports 'firewall'"

.. include:: ../_include/param_basic.rst
Expand Down
8 changes: 6 additions & 2 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ action_groups:
- ansibleguy.opnsense.route
- ansibleguy.opnsense.gateway
nat:
- ansibleguy.opnsense.source_nat
- ansibleguy.opnsense.one_to_one
- ansibleguy.opnsense.nat_source
- ansibleguy.opnsense.nat_one_to_one
system:
- ansibleguy.opnsense.list
- ansibleguy.opnsense.reload
Expand Down Expand Up @@ -223,3 +223,7 @@ plugin_routing:
redirect: ansibleguy.opnsense.acme_validation
acme_automation:
redirect: ansibleguy.opnsense.acme_action
source_nat:
redirect: ansibleguy.opnsense.nat_source
one_to_one:
redirect: ansibleguy.opnsense.nat_one_to_one
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions plugins/modules/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
'interface_lagg', 'interface_loopback', 'unbound_dnsbl', 'dhcp_reservation', 'acme_general', 'acme_account',
'acme_validation', 'acme_action', 'acme_certificate', 'postfix_general', 'postfix_domain', 'postfix_recipient',
'postfix_recipientbcc', 'postfix_sender', 'postfix_senderbcc', 'postfix_sendercanonical', 'postfix_headercheck',
'postfix_address', 'dhcp_subnet', 'dhcp_general', 'interface_gre', 'one_to_one',
'postfix_address', 'dhcp_subnet', 'dhcp_general', 'interface_gre', 'nat_one_to_one', 'nat_source',
]


Expand Down Expand Up @@ -190,12 +190,12 @@ def run_module():
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.main.interface_gre import \
Gre as Target_Obj

elif target == 'source_nat':
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.main.source_nat import \
elif target in ['source_nat', 'nat_source']:
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.main.nat_source import \
SNat as Target_Obj

elif target == 'one_to_one':
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.main.one_to_one import \
elif target == 'nat_one_to_one':
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.main.nat_one_to_one import \
OneToOne as Target_Obj

elif target == 'frr_general':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
RULE_MOD_ARGS, RULE_MOD_ARG_ALIASES
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.defaults.main import \
OPN_MOD_ARGS, STATE_MOD_ARG, RELOAD_MOD_ARG
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.main.one_to_one import OneToOne
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.main.nat_one_to_one import OneToOne

except MODULE_EXCEPTIONS:
module_dependency_error()


# DOCUMENTATION = 'https://opnsense.ansibleguy.net/modules/one_to_one.html'
# EXAMPLES = 'https://opnsense.ansibleguy.net/modules/one_to_one.html'
# DOCUMENTATION = 'https://opnsense.ansibleguy.net/modules/nat_one_to_one.html'
# EXAMPLES = 'https://opnsense.ansibleguy.net/modules/nat_one_to_one.html'


def run_module():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
RULE_MOD_ARGS
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.defaults.main import \
OPN_MOD_ARGS, STATE_MOD_ARG, RELOAD_MOD_ARG
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.main.source_nat import SNat
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.main.nat_source import SNat

except MODULE_EXCEPTIONS:
module_dependency_error()


# DOCUMENTATION = 'https://opnsense.ansibleguy.net/modules/source_nat.html'
# EXAMPLES = 'https://opnsense.ansibleguy.net/modules/source_nat.html'
# DOCUMENTATION = 'https://opnsense.ansibleguy.net/modules/nat_source.html'
# EXAMPLES = 'https://opnsense.ansibleguy.net/modules/nat_source.html'


def run_module():
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/savepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def run_module():
),
controller=dict(
type='str', required=False, default='filter', description='Target API controller',
choices=['source_nat', 'filter']
choices=['source_nat', 'filter', 'one_to_one']
),
api_module=dict(type='str', required=False, default='firewall', choices=['firewall']),
**OPN_MOD_ARGS
Expand Down
3 changes: 2 additions & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ run_test 'interface_vip' 1
run_test 'interface_lagg' 1
run_test 'interface_loopback' 1
run_test 'interface_gre' 1
run_test 'source_nat' 1
run_test 'nat_source' 1
run_test 'nat_one_to_one' 1
run_test 'frr_diagnostic' 1
run_test 'frr_general' 1
run_test 'frr_bfd_general' 1
Expand Down
2 changes: 1 addition & 1 deletion tests/one_to_one.yml → tests/nat_one_to_one.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# match_fields: ['description']

ansibleguy.opnsense.list:
target: 'one_to_one'
target: 'nat_one_to_one'

tasks:
- name: Listing
Expand Down
File renamed without changes.

0 comments on commit b7f1d35

Please sign in to comment.