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

Inventory module? #97

Open
cidrbl0ck opened this issue May 2, 2023 · 8 comments
Open

Inventory module? #97

cidrbl0ck opened this issue May 2, 2023 · 8 comments
Labels
accepted This issue can reproduced and was accepted enhancement New feature or request help wanted Extra attention is needed

Comments

@cidrbl0ck
Copy link

Is your feature request related to a problem? Please describe.
Phpipam seems to be one of those source of truth, that is ignored to a huge degree, as an inventory source. Yes, the API is useful and it's easy to make a playbook that calls and creates an inventory file. However for a lot of folks, like me, whose Python skills are quite horrible.. finding a plugin or a module to use for inventory purposes has ended in empty hands.

Describe the solution you'd like
You guys already have a nice, well-rounded Collection. Including an inventory plugin or module would be icing on the cake.

Describe alternatives you've considered
So far I've tried a playbook/template that makes an API call with various filters, to create an inventory.yaml file using a template. Also testing the ansible.builtin.script module to perform the same basic thing, except the yml calls a python script (translated from the playbook) to perform the same functions. Inventory scripts, while still technically supported, plugins are recommended by the Community and RH.

Additional context
If this functionality already exists in some form please correct me. I was not able to find anything related to this in the existing documentation.

@cidrbl0ck cidrbl0ck added the enhancement New feature or request label May 2, 2023
@cmeissner cmeissner added help wanted Extra attention is needed accepted This issue can reproduced and was accepted labels May 2, 2023
@cmeissner
Copy link
Member

Hi @cidrbl0ck,

Thank you for bringing this to our attention. I also had this topic in mind already and it would be great to have such an inventory plugin.

Before it can implemented it would be great to have a collection of use cases as there are not only IPs and host names. You can also have many other properties which needs to be taken into account for building up an inventory. We can use this issue to track ideas for the implementation first.

Unfortunately I will not find time in the near future to take over the implementation. It would be highly appreciated to have someone volunteering for this.

@cidrbl0ck
Copy link
Author

Hey @cmeissner Totally understood. I'd like to throw my use case out there while I'm here. For my company or more specifically my team.. our networking group is just getting their feet wet in Ansible and they've been using Phpipam for the better part of 3 years now. It is the only consistent SOT we have for networking devices (think routers, switches, firewalls, etc).
We bought into AAP at the beginning of this year, which has added its own unique difficulties. Anyone I'm getting off track a bit. So yeah our use case is networking equipment inventory source using Phpipam with Ansible Automation Platform.

So far we're looking at pulling from only the Addresses controller to form a very basic inventory.yaml containing hostnames, ip's, and up to three custom_fields. One of which is custom_fields:custom_managed which is the key to inclusion.

Also understood on the implementation time or lack thereof. Would this be the appropriate place to include the information/code if I stumble across something that works?

@cmeissner
Copy link
Member

cmeissner commented May 2, 2023

So far we're looking at pulling from only the Addresses controller to form a very basic inventory.yaml containing hostnames, ip's, and up to three custom_fields. One of which is custom_fields:custom_managed which is the key to inclusion.

I think this is the simplest use case but also some implementation effort is needed.

Another aspect is that #72 is also related to this feature request here. As it is suggested to cut off the api interaction stuff from phpipam_utils.py to have a common way to interact with the api and no need to implement it ever and ever again for each new feature besides the existing module.

I started to work on this but it is much harder as expected and is not soonish available.

Also understood on the implementation time or lack thereof. Would this be the appropriate place to include the information/code if I stumble across something that works?

If you have some code I would appreciate if you open a PR to discuss the code there. Here we should discuss the idea and the use-cases but no code fragments or implementations.

@cidrbl0ck
Copy link
Author

Understood, many thanks! As I said I do have a working Python script that makes use of an ENV lookup for the phpipam API token. I can change the remainder of the static variables to lookups as well and define them in a custom credential type within AAP (which I believe is the preferred method from RH above any sort of group:vars).

@cidrbl0ck
Copy link
Author

Hey @cmeissner So I wanted to comment back here.. while I was not able to develop a working plugin, I do have a pretty good inventory script now if interested. Maybe it's trivial work turning a script into a plugin? I have no idea really. But I can share it if you think it'd help.

@cmeissner
Copy link
Member

Hey @cmeissner So I wanted to comment back here.. while I was not able to develop a working plugin

I think it is not trivial on the first. I did some research before my first plugin was working as expected.

I do have a pretty good inventory script now if interested. Maybe it's trivial work turning a script into a plugin? I have no idea really. But I can share it if you think it'd help.

May I recommend to put it in a personal GitHub repo and like it in this issue?
So any other interested person can access it.

@cidrbl0ck
Copy link
Author

Here you go: https://github.com/bicarbonate/ansible_phpipam

@github-actions
Copy link

github-actions bot commented Sep 5, 2023

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Sep 5, 2023
@cmeissner cmeissner removed the Stale label Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This issue can reproduced and was accepted enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants