-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ea4e5f
commit 39c6a14
Showing
15 changed files
with
310 additions
and
22 deletions.
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
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
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
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
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,66 @@ | ||
# FRR General | ||
|
||
**STATE**: stable | ||
|
||
**TESTS**: [frr_general](https://github.com/ansibleguy/collection_opnsense/blob/latest/tests/frr_general.yml) | ||
|
||
**API Docs**: [Plugins - Quagga](https://docs.opnsense.org/development/api/plugins/quagga.html) | ||
|
||
**Service Docs**: [Dynamic Routing](https://docs.opnsense.org/manual/dynamic_routing.html) | ||
|
||
**FRR Docs**: [FRRouting](https://docs.frrouting.org/) (_make sure you are looking at the current OPNSense package version!_) | ||
|
||
## Prerequisites | ||
|
||
You need to install the FRR plugin: | ||
``` | ||
os-frr | ||
``` | ||
|
||
You can also install it using the [package module](https://github.com/ansibleguy/collection_opnsense/blob/latest/docs/use_package.md). | ||
|
||
## Definition | ||
|
||
For basic parameters see: [Basics](https://github.com/ansibleguy/collection_opnsense/blob/latest/docs/use_basic.md#definition) | ||
|
||
### ansibleguy.opnsense.frr_general | ||
|
||
| Parameter | Type | Required | Default value | Aliases | Comment | | ||
|:----------|:-------|:---------|:----------------------------|:--------------|:---------------------------------------------------------------------------------------------------------------------------------------------| | ||
| enabled | bool | false | true | - | En- or disable the FRR service | | ||
| profile | string | false | 'traditional' | - | One of: 'traditional', 'datacenter'. The 'datacenter' profile is more aggressive. Please refer to the FRR documentation for more information | | ||
| log | bool | false | true | logging | En- or disable (syslog) logging | | ||
| log_level | string | false | 'notifications' | - | One of: 'critical', 'emergencies', 'errors', 'alerts', 'warnings', 'notifications', 'informational', 'debugging'. | | ||
| carp | bool | false | false | carp_failover | Will activate the routing service only on the primary device | | ||
| snmp_agentx | bool | false | false | - | En- or disable support for Net-SNMP AgentX | | ||
|
||
|
||
## Examples | ||
|
||
### ansibleguy.opnsense.frr_general | ||
|
||
```yaml | ||
- 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: Example | ||
ansibleguy.opnsense.frr_general: | ||
# enabled: true | ||
# profile: 'traditional' | ||
# log: true | ||
# log_level: 'notifications' | ||
# snmp_agentx: false | ||
# carp: false | ||
|
||
- name: Enabling FRR | ||
ansibleguy.opnsense.frr_general: | ||
enabled: true | ||
profile: 'traditional' | ||
log: true | ||
log_level: 'notifications' | ||
``` |
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
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
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
namespace: 'ansibleguy' | ||
name: 'opnsense' | ||
version: 1.2.3 | ||
version: 1.2.4 | ||
readme: 'README.md' | ||
authors: | ||
- 'AnsibleGuy <[email protected]>' | ||
|
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
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,34 @@ | ||
from ansible.module_utils.basic import AnsibleModule | ||
|
||
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.base.api import \ | ||
Session | ||
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.base.cls import GeneralModule | ||
|
||
|
||
class General(GeneralModule): | ||
CMDS = { | ||
'set': 'set', | ||
'search': 'get', | ||
} | ||
API_KEY_PATH = 'general' | ||
API_MOD = 'quagga' | ||
API_CONT = 'general' | ||
API_CONT_REL = 'service' | ||
API_CMD_REL = 'reconfigure' | ||
FIELDS_CHANGE = [ | ||
'enabled', 'profile', 'carp', 'log', 'snmp_agentx', 'log_level', | ||
] | ||
FIELDS_ALL = FIELDS_CHANGE | ||
FIELDS_TRANSLATE = { | ||
'carp': 'enablecarp', | ||
'log': 'enablesyslog', | ||
'snmp_agentx': 'enablesnmp', | ||
'log_level': 'sysloglevel', | ||
} | ||
FIELDS_TYPING = { | ||
'bool': ['enabled', 'carp', 'log', 'snmp_agentx'], | ||
'select': ['log_level', 'profile'], | ||
} | ||
|
||
def __init__(self, module: AnsibleModule, result: dict, session: Session = None): | ||
GeneralModule.__init__(self=self, m=module, r=result, s=session) |
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,99 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright: (C) 2023, AnsibleGuy <[email protected]> | ||
# GNU General Public License v3.0+ (see https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
# see: https://docs.opnsense.org/development/api/plugins/quagga.html | ||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
|
||
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.base.handler import \ | ||
module_dependency_error, MODULE_EXCEPTIONS | ||
|
||
try: | ||
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.helper.utils import profiler | ||
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.helper.main import \ | ||
diff_remove_empty | ||
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.defaults.main import \ | ||
OPN_MOD_ARGS, EN_ONLY_MOD_ARG, RELOAD_MOD_ARG | ||
from ansible_collections.ansibleguy.opnsense.plugins.module_utils.main.frr_general import General | ||
|
||
except MODULE_EXCEPTIONS: | ||
module_dependency_error() | ||
|
||
PROFILE = False # create log to profile time consumption | ||
|
||
DOCUMENTATION = 'https://opnsense.ansibleguy.net/en/latest/modules/frr_general.html' | ||
EXAMPLES = 'https://opnsense.ansibleguy.net/en/latest/modules/frr_general.html' | ||
|
||
|
||
def run_module(): | ||
module_args = dict( | ||
carp=dict( | ||
type='bool', required=False, default=False, aliases=['carp_failover'], | ||
description='Will activate the routing service only on the primary device' | ||
), | ||
profile=dict( | ||
type='str', required=False, default='traditional', | ||
options=['traditional', 'datacenter'], | ||
description="The 'datacenter' profile is more aggressive. " | ||
"Please refer to the FRR documentation for more information" | ||
), | ||
snmp_agentx=dict( | ||
type='bool', required=False, default=False, | ||
description='En- or disable support for Net-SNMP AgentX' | ||
), | ||
log=dict( | ||
type='bool', required=False, default=True, aliases=['logging'], | ||
), | ||
log_level=dict( | ||
type='str', required=False, default='notifications', | ||
options=[ | ||
'critical', 'emergencies', 'errors', 'alerts', 'warnings', 'notifications', | ||
'informational', 'debugging', | ||
], | ||
), | ||
**RELOAD_MOD_ARG, | ||
**EN_ONLY_MOD_ARG, | ||
**OPN_MOD_ARGS, | ||
) | ||
|
||
result = dict( | ||
changed=False, | ||
diff={ | ||
'before': {}, | ||
'after': {}, | ||
} | ||
) | ||
|
||
module = AnsibleModule( | ||
argument_spec=module_args, | ||
supports_check_mode=True, | ||
) | ||
|
||
g = General(module=module, result=result) | ||
|
||
def process(): | ||
g.check() | ||
g.process() | ||
if result['changed'] and module.params['reload']: | ||
g.reload() | ||
|
||
if PROFILE or module.params['debug']: | ||
profiler(check=process, log_file='frr_general.log') | ||
# log in /tmp/ansibleguy.opnsense/ | ||
|
||
else: | ||
process() | ||
|
||
g.s.close() | ||
result['diff'] = diff_remove_empty(result['diff']) | ||
module.exit_json(**result) | ||
|
||
|
||
def main(): | ||
run_module() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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
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
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
Oops, something went wrong.