diff --git a/changelogs/fragments/1978-vmware_vmkernel.yaml b/changelogs/fragments/1978-vmware_vmkernel.yaml new file mode 100644 index 000000000..93eb12fc8 --- /dev/null +++ b/changelogs/fragments/1978-vmware_vmkernel.yaml @@ -0,0 +1,3 @@ +minor_changes: + - vmware_vmkernel - Add the function to set the enable_backup_nfc setting + (https://github.com/ansible-collections/community.vmware/pull/1978) diff --git a/plugins/modules/vmware_vmkernel.py b/plugins/modules/vmware_vmkernel.py index ec01370e5..fb79e5b82 100644 --- a/plugins/modules/vmware_vmkernel.py +++ b/plugins/modules/vmware_vmkernel.py @@ -26,6 +26,7 @@ - Russell Teague (@mtnbikenc) - Abhijeet Kasurde (@Akasurde) - Christian Kotte (@ckotte) +- Nina Loser (@Nina2244) notes: - The option O(device) need to be used with DHCP because otherwise it's not possible to check if a VMkernel device is already present - You can only change from DHCP to static, and vSS to vDS, or vice versa, in one step, without creating a new device, with O(device) specified. @@ -139,6 +140,12 @@ - This option is only allowed if the default TCP/IP stack is used. type: bool default: false + enable_backup_nfc: + description: + - Enable vSphere Backup NFC traffic on the VMKernel adapter. + - This option is only allowed if the default TCP/IP stack is used. + type: bool + default: false state: description: - If set to V(present), the VMKernel adapter will be created with the given specifications. @@ -301,6 +308,7 @@ def __init__(self, module): self.enable_provisioning = self.params['enable_provisioning'] self.enable_replication = self.params['enable_replication'] self.enable_replication_nfc = self.params['enable_replication_nfc'] + self.enable_backup_nfc = self.params['enable_backup_nfc'] self.vswitch_name = self.params['vswitch_name'] self.vds_name = self.params['dvswitch_name'] @@ -494,7 +502,7 @@ def host_vmk_update(self): """ changed = changed_settings = changed_vds = changed_services = \ changed_service_vmotion = changed_service_mgmt = changed_service_ft = \ - changed_service_vsan = changed_service_prov = changed_service_rep = changed_service_rep_nfc = False + changed_service_vsan = changed_service_prov = changed_service_rep = changed_service_rep_nfc = changed_service_backup_nfc = False changed_list = [] results = dict(changed=False, msg='') @@ -623,6 +631,11 @@ def host_vmk_update(self): if (self.enable_replication_nfc and self.vnic.device not in service_type_vmks['vSphereReplicationNFC']) or \ (not self.enable_replication_nfc and self.vnic.device in service_type_vmks['vSphereReplicationNFC']): changed_services = changed_service_rep_nfc = True + + if (self.enable_backup_nfc and self.vnic.device not in service_type_vmks['vSphereBackupNFC']) or \ + (not self.enable_backup_nfc and self.vnic.device in service_type_vmks['vSphereBackupNFC']): + changed_services = changed_service_backup_nfc = True + if changed_services: changed_list.append("services") @@ -744,6 +757,14 @@ def host_vmk_update(self): vnic_manager=vnic_manager, vmk=self.vnic, service_type='vSphereReplicationNFC', operation=operation ) + if changed_service_backup_nfc: + if self.vnic.device in service_type_vmks['vSphereBackupNFC']: + services_previous.append('Backup_NFC') + operation = 'select' if self.enable_backup_nfc else 'deselect' + self.set_service_type( + vnic_manager=vnic_manager, vmk=self.vnic, service_type='vSphereBackupNFC', operation=operation + ) + if changed_service_vsan: if self.vnic.device in service_type_vmks['vsan']: services_previous.append('VSAN') @@ -918,7 +939,7 @@ def host_vmk_create(self): option is False for option in [self.enable_vsan, self.enable_vmotion, self.enable_mgmt, self.enable_ft, self.enable_provisioning, self.enable_replication, - self.enable_replication_nfc]): + self.enable_replication_nfc, self.enable_backup_nfc]): self.vnic = self.get_vmkernel_by_device(device_name=vmk_device) # VSAN @@ -945,6 +966,9 @@ def host_vmk_create(self): if self.enable_replication_nfc: self.set_service_type(host_vnic_manager, self.vnic, 'vSphereReplicationNFC') + if self.enable_backup_nfc: + self.set_service_type(host_vnic_manager, self.vnic, 'vSphereBackupNFC') + self.module.exit_json(**results) def set_service_type(self, vnic_manager, vmk, service_type, operation='select'): @@ -984,6 +1008,7 @@ def get_all_vmks_by_service_type(self): vSphereProvisioning=[], vSphereReplication=[], vSphereReplicationNFC=[], + vSphereBackupNFC=[], ) for service_type in list(service_type_vmk): @@ -1037,6 +1062,8 @@ def create_enabled_services_string(self): services.append('Repl') if self.enable_replication_nfc: services.append('Repl_NFC') + if self.enable_backup_nfc: + services.append('Backup_NFC') return ', '.join(services) @staticmethod @@ -1075,6 +1102,7 @@ def main(): enable_provisioning=dict(type='bool', default=False), enable_replication=dict(type='bool', default=False), enable_replication_nfc=dict(type='bool', default=False), + enable_backup_nfc=dict(type='bool', default=False), vswitch_name=dict(required=False, type='str', aliases=['vswitch']), dvswitch_name=dict(required=False, type='str', aliases=['dvswitch']), network=dict(