diff --git a/changelogs/fragments/1349-add-additional-fhrp-arguments.yaml b/changelogs/fragments/1349-add-additional-fhrp-arguments.yaml new file mode 100644 index 00000000..3c078dab --- /dev/null +++ b/changelogs/fragments/1349-add-additional-fhrp-arguments.yaml @@ -0,0 +1,3 @@ +minor_changes: + - in netbox_ip_address added assigned_object_type and assigned_object_id options + - In the netbox_fhrp_group, the `name` parameter is now required, which is used to search. diff --git a/plugins/module_utils/netbox_ipam.py b/plugins/module_utils/netbox_ipam.py index 8d1b731f..8fa41258 100644 --- a/plugins/module_utils/netbox_ipam.py +++ b/plugins/module_utils/netbox_ipam.py @@ -189,7 +189,7 @@ def run(self): elif self.endpoint == "asns": name = data.get("asn") elif self.endpoint == "fhrp_groups": - name = data.get("group_id") + name = data.get("name") elif self.endpoint == "fhrp_group_assignments": name = "fhrp_group %s > %s %s" % ( data.get("group"), diff --git a/plugins/module_utils/netbox_utils.py b/plugins/module_utils/netbox_utils.py index ea76f43c..52eb975c 100644 --- a/plugins/module_utils/netbox_utils.py +++ b/plugins/module_utils/netbox_utils.py @@ -164,7 +164,7 @@ device_type="slug", export_targets="name", export_template="name", - fhrp_groups="group_id", + fhrp_groups="name", fhrp_group_assignments="id", group="slug", groups="name", @@ -493,7 +493,7 @@ "device_type": set(["slug"]), "export_template": set(["name"]), "fhrp_group": set( - ["id", "group_id", "interface_type", "device", "virtual_machine"] + ["id", "group_id","name", "interface_type", "device", "virtual_machine"] ), "fhrp_group_assignment": set(["group", "interface_type", "interface_id"]), "front_port": set(["name", "device", "rear_port"]), diff --git a/plugins/modules/netbox_fhrp_group.py b/plugins/modules/netbox_fhrp_group.py index 377dbada..f655a031 100644 --- a/plugins/modules/netbox_fhrp_group.py +++ b/plugins/modules/netbox_fhrp_group.py @@ -147,7 +147,7 @@ def main(): type="dict", required=True, options=dict( - name=dict(type="str"), + name=dict(type="str", required=True), protocol=dict( type="str", choices=[ diff --git a/plugins/modules/netbox_ip_address.py b/plugins/modules/netbox_ip_address.py index 961bab7b..412f0f34 100644 --- a/plugins/modules/netbox_ip_address.py +++ b/plugins/modules/netbox_ip_address.py @@ -110,6 +110,16 @@ - Hostname or FQDN required: false type: str + assigned_object_id: + description: + - ID of the assigned object + type: str + required: false + assigned_object_type: + description: + - Type of the assigned object + type: str + required: false assigned_object: description: - Definition of the assigned object. @@ -264,6 +274,16 @@ name: GigabitEthernet1 device: test100 state: new + + - name: Create an IP address using NetBox and add it to the FHRP group + netbox.netbox.netbox_ip_address: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + address: 192.168.1.10 + assigned_object_id: 30 + assigned_object_type: "ipam.fhrpgroup" + state: present """ RETURN = r""" @@ -333,6 +353,8 @@ def main(): description=dict(required=False, type="str"), nat_inside=dict(required=False, type="raw"), dns_name=dict(required=False, type="str"), + assigned_object_id=dict(required=False, type="str"), + assigned_object_type=dict(required=False, type="str"), assigned_object=dict( required=False, type="dict",