stdevel / ansible-collection-uyuni

Ansible Collection for Uyuni / SUSE Manager
https://galaxy.ansible.com/stdevel/uyuni
GNU General Public License v3.0
21 stars 6 forks source link

inventory plugin: allow environment vars instead of cfg file options #41

Closed azrdev closed 6 months ago

azrdev commented 6 months ago

needed for usage in AAP/AWX

modeled after https://github.com/ansible-collections/community.general/commit/f1a31611b77ceaeb6ee4697815b8fd5ae62d4fde

untested so far

mat-ti commented 6 months ago

This is what I need, this looks very good, thank you @azrdev. I've tested it and your intergration works like charm.

Tested Versions:

azrdev commented 6 months ago

I just tested it successfully, too.

demo project contains:

# requirements.yml
collections:
  - name: https://github.com/azrdev/ansible-collection-uyuni
    type: git
    version: feature-inventory-in-awx-aap

and

# suma.uyuni.yml
---
plugin: stdevel.uyuni.inventory
verify_ssl: false
show_custom_values: true

AWX has a custom credential type with the following config:

# inpug config
fields:
  - id: host
    type: string
    label: Hostname
  - id: username
    type: string
    label: Username
  - id: password
    type: string
    label: Password
    secret: true
required:
  - host
  - username
  - password
# injector config
env:
  UYUNI_HOST: '{{ host }}'
  UYUNI_USER: '{{ username }}'
  UYUNI_PASSWORD: '{{ password }}'

and an instance of that CCT attached to the inventory source

stdevel commented 6 months ago

This is awesome, thanks a lot for supplying a fix and documenting/testing this so fast. 🎉 I just merged it and released the new version 0.2.0.