ansible/awx

awxkit: selecting inventory by name fails if name is a number

Open

#7541 aperta il 3 lug 2020

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)Python (3333 fork)batch import
component:clihelp wantedtype:bug

Metriche repository

Star
 (13.071 star)
Metriche merge PR
 (Merge medio 24g 6h) (30 PR mergiate in 30 g)

Descrizione

ISSUE TYPE
  • Bug Report
SUMMARY

If an inventory or an inventory_source name consists only of numbers then this inventory or inventory_source can not be selected by name. But this is stated in the help description.

usage: awx inventory get [-h] [-f {json,yaml,jq,human}] [--filter TEXT] [--conf.color BOOLEAN] [-v] id

positional arguments:
  id                    the ID (or unique name) of the resource

I'm in the progress of porting a script from tower-cli to awxkit and now I'm in a situation where I can not select any inventory or inventory_source because all these are named as customer numbers. This is probably a corner case, but in this case awxkit behaves differently than tower-cli.

ENVIRONMENT
  • AWX version: 11.2.0
  • AWX install method: docker
  • Ansible version: 2.9.9
  • Operating System: Fedora 32
  • Web Browser: Firefox 74
STEPS TO REPRODUCE
awx --conf.host https://awx.example.com --conf.token mytoken --conf.insecure inventory create --name 123 --organization 1
{
     "id": 10,
     ...
     "name": "123",
     "description": "",
     "organization": 1,
}

awx --conf.host https://awx.example.com --conf.token mytoken --conf.insecure inventory get 123
{"detail": "Not found."}
EXPECTED RESULTS

The awx cli should be able to find inventories explicitly by name as tower-cli was doing it:

tower-cli inventory get -n 123 --insecure -t mytoken -h awx.example.com
{
  "id": 10,
  ...
}

tower-cli uses an additional parameter instead of the positional argument.

ACTUAL RESULTS

The awx cli failes to find the inventory with name "123"

awx --conf.host https://awx.example.com --conf.token mytoken --conf.insecure inventory get 123
{"detail": "Not found."}

Guida contributor