Skip to content

Commit

Permalink
Merging devel changes - 2024-10-22T01:00:44Z
Browse files Browse the repository at this point in the history
  • Loading branch information
urohit011 committed Oct 22, 2024
1 parent 0f1d80c commit aeff8d4
Show file tree
Hide file tree
Showing 9 changed files with 755 additions and 51 deletions.
52 changes: 21 additions & 31 deletions ansible_collections/f5networks/f5os/plugins/modules/f5os_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@
facility:
description: Filter logs on facility local0 or authpriv.
type: str
choices:
- local0
- authpriv
severity:
description: Specify the minimum seceverity to be forwarded to this server
description: Specify the minimum severity to be forwarded to this server
type: str
choices:
- debug
Expand All @@ -80,7 +83,7 @@
description: Filter logs on facility.
type: str
severity:
description: Specify the minimum seceverity to be forwarded to remote servers
description: Specify the minimum severity to be forwarded to remote servers
type: str
choices:
- debug
Expand Down Expand Up @@ -536,9 +539,8 @@ def exists(self, query=None):

if hasattr(self.want, 'servers') and self.want.servers is not None:
for server in self.want.servers:
uri = f'{base_uri}/remote-servers/remote-server="{server["address"]}"'
uri = f'{base_uri}/remote-servers/remote-server={server["address"]}'
response = self.client.get(uri)

if response['code'] == 200:
if query in ['any', 'still']:
return True
Expand Down Expand Up @@ -684,11 +686,7 @@ def create_on_device(self):
}
}
if 'authentication' in server and server['authentication'] is not None:
server_conf['config'] = {
'f5-openconfig-system-logging:authentication': {
'enabled': server['authentication']
}
}
server_conf['config'].update({'f5-openconfig-system-logging:authentication': {'enabled': server['authentication']}})
if 'logs' in server and server['logs'] is not None:
server_conf['selectors'] = {
'selector': list()
Expand All @@ -704,7 +702,6 @@ def create_on_device(self):
}
server_conf['selectors']['selector'].append(log_conf)
server_list.append(server_conf)

response = self.client.post(uri, data=payload)
if response['code'] == 409:
# This object exists already, so override it
Expand All @@ -731,7 +728,6 @@ def create_on_device(self):
def update_on_device(self):
params = self.changes.api_params()
base_uri = '/openconfig-system:system/logging'

if 'tls' in params and params['tls'] is not None:
uri = f'{base_uri}/f5-openconfig-system-logging:tls'
payload = {
Expand All @@ -741,7 +737,6 @@ def update_on_device(self):
response = self.client.put(uri, data=payload)
if response['code'] not in [200, 204]:
raise F5ModuleError(response['contents'])

if 'ca_bundles' in params and params['ca_bundles'] is not None:
for bundle in params['ca_bundles']:
uri = f'{base_uri}/f5-openconfig-system-logging:tls/ca-bundles/ca-bundle="{bundle["name"]}"'
Expand Down Expand Up @@ -789,16 +784,12 @@ def update_on_device(self):
response = self.client.put(uri, data=payload)
if response['code'] not in [200, 204]:
raise F5ModuleError(response['contents'])

if 'servers' in params and params['servers'] is not None:
uri = f'{base_uri}/remote-servers'
payload = {
'openconfig-system:remote-servers': {
'remote-server': list()
}
}
server_list = payload['openconfig-system:remote-servers']['remote-server']

for server in params['servers']:
payload = {'remote-server': list()}

server_conf = {
'host': server['address'],
'config': {
Expand All @@ -809,16 +800,13 @@ def update_on_device(self):
}

if 'authentication' in server and server['authentication'] is not None:
server_conf['config'] = {
'f5-openconfig-system-logging:authentication': {
'enabled': server['authentication']
}
}
server_conf['config']['f5-openconfig-system-logging:authentication'] = dict()
server_conf['config']['f5-openconfig-system-logging:authentication'] = {'enabled': server['authentication']}

if 'logs' in server and server['logs'] is not None:
server_conf['selectors'] = {
'selector': list()
}
server_conf['selectors'] = dict()
server_conf['selectors'] = {'selector': list()}

for log in server['logs']:
log_conf = {
'facility': f'f5-system-logging-types:{log["facility"].upper()}',
Expand All @@ -829,12 +817,11 @@ def update_on_device(self):
}
}
server_conf['selectors']['selector'].append(log_conf)
server_list.append(server_conf)

response = self.client.put(uri, data=payload)
payload['remote-server'].append(server_conf)
response = self.client.put(f'{uri}/remote-server={server["address"]}', data=payload)
if response['code'] not in [200, 204]:
raise F5ModuleError(response['contents'])

if 'include_hostname' in params and params['include_hostname'] is not None:
uri = f'{base_uri}/f5-openconfig-system-logging:config'
payload = {
Expand Down Expand Up @@ -969,7 +956,10 @@ def __init__(self):
type='list',
elements='dict',
options=dict(
facility=dict(type='str'),
facility=dict(
type='str',
choices=['local0', 'authpriv']
),
severity=dict(
type='str',
choices=ArgumentSpec.severities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
type: str
choices:
- rsa
- encrypted rsa
- encrypted-rsa
- ecdsa
- encrypted ecdsa
- encrypted-ecdsa
key_size:
description:
- This specifies the length of the key.
Expand Down Expand Up @@ -643,9 +643,9 @@ def __init__(self):
key_type=dict(
choices=[
"rsa",
"encrypted rsa",
"encrypted-rsa",
"ecdsa",
"encrypted ecdsa",
"encrypted-ecdsa",
]
),
key_size=dict(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"f5-openconfig-system-logging:host-logs": {
"config": {
"remote-forwarding": {
"enabled": true
},
"selectors": {
"selector": [
{
"facility": "openconfig-system-logging:LOCAL0",
"severity": "NOTICE"
},
{
"facility": "openconfig-system-logging:AUTHPRIV",
"severity": "EMERGENCY"
},
{
"facility": "openconfig-system-logging:AUTH",
"severity": "EMERGENCY"
}
]
},
"files": {
"file": [
{
"name": "anaconda"
},
{
"name": "ansible.log"
},
{
"name": "boot.log"
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
{
"code": 200,
"contents": {
"openconfig-system:config": {
"hostname": "appliance-1.chassis.local",
"login-banner": "pmlab-r5600",
"motd-banner": "pmlab-ravi-r5600",
"current-datetime": "2024-10-09 10:01:53+00:00",
"f5-system:base-mac": "00:94:a1:69:5d:00",
"f5-system:mac-pool-size": 256
"f5-system-settings:settings": {
"config": {
"f5-system-settings-pgwarn:portgroup-confirmation-warning": "on"
},
"openconfig-system:clock": {},
"f5-security-ciphers:service": {},
"f5-system-settings:settings": {}
"state": {
"sshd-idle-timeout": "0",
"f5-system-settings-pgwarn:portgroup-confirmation-warning": "on"
},
"f5-system-settings-dag:dag": {
"config": {
"gtp-u": {
"teid-hash": {
"enabled": false
}
}
},
"state": {
"gtp-u": {
"teid-hash": {
"enabled": false
}
}
}
},
"f5-gui-advisory:gui": {
"advisory": {
"config": {
"enabled": false
},
"state": {
"enabled": false
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"f5-security-ciphers:service": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"openconfig-system:clock": {
"config": {
"timezone-name": "Etc/UTC"
},
"state": {
"timezone-name": "Etc/UTC",
"f5-system-clock:appliance": {
"date-time": "2024-10-18 10:27:08+00:00"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"openconfig-system:config": {
"login-banner": "pmlab-r5600",
"motd-banner": "pmlab-ravi-r5600"
},
"openconfig-system:clock": {},
"f5-security-ciphers:service": {},
"f5-system-settings:settings": {}
}
Loading

0 comments on commit aeff8d4

Please sign in to comment.