Awx: Support object reference by (unique) name globally

Created on 1 Oct 2019  路  5Comments  路  Source: ansible/awx

ISSUE TYPE
  • Feature Idea
SUMMARY


I would like to be able to refer to IDs of things by their unique names when possible, globally. It appears that some functions are able to use this, such as getting a credential:

$ /data/awx/virtualenv/bin/awx credential get omgjlk-via-vault -f human
id name
== ================
18 omgjlk-via-vault

But if I try to use that when creating a credential input source I get an error

$ /data/awx/virtualenv/bin/awx credential_input_sources create --target_credential omgjlk-via-vault --input_field_name ssh_key_data --source_credential gtower-vault --metadata "{'secret_key': 'ssh_key_data', 'secret_path': '/secret/apps/gtower-keys/omgjlk'}" -f yaml
source_credential:
- Incorrect type. Expected pk value, received str.
target_credential:
- Incorrect type. Expected pk value, received str.

Allowing the name to be used in one place but not another is pretty annoying. Now I'll have to query the API to discover the ID of these things, parse the output, etc... If I could just use the names then I can rely on the data I already have _outside_ of AWX, the source of my config.

cli medium bug

All 5 comments

@omgjlk I think this is just a CLI bug, not an intentional design decision; I'll take a look soon.

I did some digging. It looks like awxkit is adding the pk_or_name functionality on get, modify, or delete methods instead of build_detail_actions. However since this is a create method, and the things which should take a pk_or_name are custom named, the function mapping never takes place.

I have no idea how to influence build_detail_actions how to properly attach the pk_or_name functionality to source_credential or target_credential options.

@omgjlk mind giving this a shot?

https://github.com/ansible/awx/pull/4899

That seems to do the right thing in this case.

WFM with awxkit/awx cli installed from devel. Closing the issue as this is fixed

Was this page helpful?
0 / 5 - 0 ratings