diff --git a/changelogs/fragments/9962-nmcli-add-infiniband-mac-support.yml b/changelogs/fragments/9962-nmcli-add-infiniband-mac-support.yml new file mode 100644 index 0000000000..0942788868 --- /dev/null +++ b/changelogs/fragments/9962-nmcli-add-infiniband-mac-support.yml @@ -0,0 +1,2 @@ +minor_changes: + - nmcli - add support for Infiniband MAC setting when ``type`` is ``infiniband`` (https://github.com/ansible-collections/community.general/pull/9962). diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 3c895e76ec..43cf041ddb 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -99,6 +99,11 @@ options: type: str choices: [datagram, connected] version_added: 5.8.0 + infiniband_mac: + description: + - MAC address of the Infiniband IPoIB devices. + type: str + version_added: 10.6.0 slave_type: description: - Type of the device of this slave's master connection (for example V(bond)). @@ -1764,6 +1769,7 @@ class Nmcli(object): self.wireguard = module.params['wireguard'] self.vpn = module.params['vpn'] self.transport_mode = module.params['transport_mode'] + self.infiniband_mac = module.params['infiniband_mac'] self.sriov = module.params['sriov'] if self.method4: @@ -2034,6 +2040,8 @@ class Nmcli(object): options.update({ 'infiniband.transport-mode': self.transport_mode, }) + if self.infiniband_mac: + options['infiniband.mac-address'] = self.infiniband_mac elif self.type == 'vrf': options.update({ 'table': self.table, @@ -2708,9 +2716,12 @@ def main(): tap=dict(type='bool'))), wireguard=dict(type='dict'), vpn=dict(type='dict'), - transport_mode=dict(type='str', choices=['datagram', 'connected']), sriov=dict(type='dict'), table=dict(type='int'), + # infiniband specific vars + transport_mode=dict(type='str', choices=['datagram', 'connected']), + infiniband_mac=dict(type='str'), + ), mutually_exclusive=[['never_default4', 'gw4'], ['routes4_extended', 'routes4'], diff --git a/tests/unit/plugins/modules/test_nmcli.py b/tests/unit/plugins/modules/test_nmcli.py index 45875cb15b..614c58a842 100644 --- a/tests/unit/plugins/modules/test_nmcli.py +++ b/tests/unit/plugins/modules/test_nmcli.py @@ -4485,8 +4485,10 @@ def test_bond_connection_unchanged(mocked_generic_connection_diff_check, capfd): macvlan=dict(type='dict'), wireguard=dict(type='dict'), vpn=dict(type='dict'), - transport_mode=dict(type='str', choices=['datagram', 'connected']), sriov=dict(type='dict'), + # infiniband specific vars + transport_mode=dict(type='str', choices=['datagram', 'connected']), + infiniband_mac=dict(type='str'), ), mutually_exclusive=[['never_default4', 'gw4'], ['routes4_extended', 'routes4'],