Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing elements to netbox_fhrp_group #1348

Open
wants to merge 9 commits into
base: devel
Choose a base branch
from

Conversation

Hramoff
Copy link

@Hramoff Hramoff commented Nov 2, 2024

New Behavior

I can't specify a virtual IP when creating an FHRP group via Ansible, so I added this functionality

Contrast to Current Behavior

Two new keys ip_address and ip_status have been added to netbox_fhrp_group.py

Discussion: Benefits and Drawbacks

My solution is backwards compatible because I use required=False and user tasks will not stop working.
Next. This functionality is needed to conveniently manage FHRP groups.

Changes to the Documentation

As far as I know, the documentation in the wiki is automatically generated from the DOCUMENTATION variable in the module, so I added a description there of what I did and how to work with it

Proposed Release Note Entry

Add missing elements to netbox_fhrp_group

  • I have read the comments and followed the CONTRIBUTING.md.
  • I have explained my PR according to the information in the comments or in a linked issue.
  • My PR targets the devel branch.

@Hramoff
Copy link
Author

Hramoff commented Nov 7, 2024

I confused how additional ones are added.

I wanted to add functionality so that the IP address could be added to the FHRP group. I thought that the keys from the json that is sent to the web interface coincide with the keys in Ansible, but as it turns out, they do not.

I looked at what the debug outputs:

    - name:
      debug:
        msg: "{{ query('netbox.netbox.nb_lookup', 'ip-addresses', api_endpoint=netbox_url, token=netbox_user_token, api_filter=filter_description)  }}"
        {
            "key": 11186,
            "value": {
                "address": "10.22.5.88/32",
                "assigned_object": {
                    "description": "demo-network",
                    "display": "keepalived-vip VRRPv3: 3 (10.22.5.88/32)",
                    "group_id": 3,
                    "id": 30,
                    "protocol": "vrrp3",
                    "url": "https://netbox.local/api/ipam/fhrp-groups/30/"
                },
                "assigned_object_id": 30,
                "assigned_object_type": "ipam.fhrpgroup",
        }
}

I saw that in order to link an address to a fhrp group you need to specify its ID and type, respectively assigned_object_id and assigned_object_type

I decided to add these two parameters because I think they will be universal for other types and IDs.

@Hramoff
Copy link
Author

Hramoff commented Nov 7, 2024

I think that it is better to search using the name key rather than group_id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant