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 plugin for OCP Virtualization #78

Open
6 of 9 tasks
jangel97 opened this issue Feb 6, 2023 · 4 comments
Open
6 of 9 tasks

Inventory plugin for OCP Virtualization #78

jangel97 opened this issue Feb 6, 2023 · 4 comments

Comments

@jangel97
Copy link

jangel97 commented Feb 6, 2023

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that AWX is open source software provided for free and that I might not receive a timely response.

Feature type

New Feature

Feature Summary

Hi,

I did not find a way to use dyamic inventory on AAP for OCP Virt.

I tried to create an Inventory Source using the community.okd.openshift inventory plugin, in order to do so, I created added an inventory sync from a project.

---
plugin: community.okd.openshift
connections:
  - namespaces:
      - jmorenas-dev
    verify_ssl: false

This plugin requires a kubeconfig or a token, but, since I can only use project inventory sync, i can't land token or kubeconfig for this inventory sync.

It would be cool if there was an inventory sync the type of which is OpenShift Virtualization.

Select the relevant components

  • UI
  • API
  • Docs
  • Collection
  • CLI
  • Other

Steps to reproduce

Try setting this in AAP and get VMs from OCP Virt https://docs.ansible.com/ansible/latest/collections/community/okd/openshift_inventory.html#ansible-collections-community-okd-openshift-inventory

Current results

Not possible to use dynamic inventory for ocp virt / kubevirt on AAP/AWX

Sugested feature result

Not possible to use dynamic inventory for ocp virt / kubevirt on AAP/AWX

Additional information

No response

@AlanCoding
Copy link
Member

AlanCoding commented Feb 8, 2023

This might be premature, but I would prefer that we solve this problem generally via custom credentials in inventory updates. You probably either have a custom credential type that puts the token into a known place, or an existing credential type already does that. But then you need to use what the credential makes available inside of the inventory plugin configuration, which may require ansible/ansible#79244 from @bcoca.

In addition to that, if you are using a credential type that puts the token in via extra_vars, then ansible/awx#7944 would be needed to support that. Since support for --extra-vars in ansible-inventory was added in ansible-core way back in version 2.11, I think we can seriously consider supporting it in AWX somehow.

Looking at:

https://github.com/openshift/community.okd/blob/main/plugins/inventory/openshift.py

I realize why this is hard to work with our current custom credential types. The inventory plugin requires that a path be hard-coded into the inventory file as one of the options there, without accepting an environment variable as a fallback. This is challenging to satisfy in a general sense, because it would require some kind of interplay between the credential model and the inventory model. Maybe it would be easiest to have the collection add an alternative means of specifying either a path to a config file or the token by environment variables, because I would argue that is generally desirable.

@bcoca
Copy link
Member

bcoca commented Feb 8, 2023

fyi, inventory plugins can just add an env: section and use the declared env vars as source of the data for the configuration entry.

@jangel97
Copy link
Author

Would it make sense to work on a plugin with ocp virt folks so we have an ocp inventory plugin in AAP, kinda like we have OSP inventory plugin or VMWare?

@AlanCoding AlanCoding removed their assignment Jan 3, 2025
@AlanCoding
Copy link
Member

Issue needs to be moved to

https://github.com/ansible/awx-plugins/

@AlanCoding AlanCoding transferred this issue from ansible/awx Jan 3, 2025
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

No branches or pull requests

3 participants