ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
838 stars 1.54k forks source link

xen_orchestra inventory plugin problematic environment variable names ( Error in AWX) #4501

Open kebl-reflact opened 2 years ago

kebl-reflact commented 2 years ago

Summary

When unsing the Inventory Plugin xenorchestra with AWX, I am unable to inject the environment Variabels. AWX seems to have an issue with environment Variables in credentials starting with ANSIBLE since these could affect Ansible itself.

Since I think it's a valid error, I would propose a new environment variable naming structure for this module by removing the "ANSIBLE" part of it and starting with "XO" instead. This would be more in line with other inventory plugins in this collection, by simultaniously shorten and make the vars more complicit

Issue Type

Bug Report

Component Name

xen_orchestra https://docs.ansible.com/ansible/latest/collections/community/general/xen_orchestra_inventory.html

Ansible Version

ansible 5.6.0

Community.general Version

community.general 4.7.0

Configuration

No response

OS / Environment

AWX 20.1.0

Steps to Reproduce

https://awx.example.com/#/credential_types/ Input configuration

fields:
  - id: XO_USER
    type: string
    label: XenOrchestra User
  - id: XO_PASSWORD
    type: string
    label: XenOrchestra Password
    secret: true
  - id: XO_HOST
    type: string
    label: XenOrchestra Host
required:
  - XO_USER
  - XO_PASSWORD
  - XO_HOST

Injector configuration

env:
  ANSIBLE_XO_HOST: '{{ XO_HOST }}'
  ANSIBLE_XO_USER: '{{ XO_USER }}'
  ANSIBLE_XO_PASSWORD: '{{ XO_PASSWORD }}'

Expected Results

No error because of the variable name.

Actual Results

Environment variable ANSIBLE_XO_HOST may affect Ansible configuration so its use is not allowed in credentials.

Code of Conduct

ansibullbot commented 2 years ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 2 years ago

cc @ddelnano @shinuza click here for bot help

felixfontein commented 2 years ago

Since I think it's a valid error, I would propose a new environment variable naming structure for this module by removing the "ANSIBLE" part of it and starting with "XO" instead.

We generally require all Ansible specific environment variables to start with ANSIBLE_. Possible exceptions so far have only been backwards compatibility and if that environment variable is also used by the product / tool / CLI program itself (in the same form), if applicable.

fanuelsen commented 6 months ago

I have the same problem, i cant inject the credentials from awx as its not allowd to use environemnt varialbles that starts with ANSIBLE. This works on other inventory scripts that do not follow that practice.

felixfontein commented 6 months ago

A discussion about this is happening here: https://forum.ansible.com/t/environment-variables-prefix-with-ansible-and-awx/5737