ansible / tower-cli

THIS TOOL IS NO LONGER UNDER ACTIVE DEVELOPMENT. This tool is being phased out in favor of the new official AWX CLI
https://github.com/ansible/awx/tree/devel/awxkit/awxkit/cli/docs
Apache License 2.0
363 stars 151 forks source link

[v2] Allow direct input of popular credential fields in v2 #356

Open AlanCoding opened 7 years ago

AlanCoding commented 7 years ago

from prior suggestion:

what if we kept shortcuts for the v1 fields (i.e., --username, --password, etc... are still available, they just auto-map to the inputs dict), and for custom types, you just have to pass in JSON?

Keep the simple use-cases simple. Let the complex things be possible.

akcrisp commented 6 years ago

this should support directly pointing it at the ssh key file ie --inputs'{"ssh_key_data": ~/.ssh/id_rsa}' rather than expecting the actual key.

This needs fixing asap.

AlanCoding commented 6 years ago

Feel free to have a stab at it. The thinking here is to have options like --ssh-key-data=..., then you could accept files. The syntax pattern needs consideration, I think that older versions like 3.1.8 would consider ... to be a file.

This would require a translation layer to be added, and I think we have a good example with unified_job_template_options. This decorator could implement options ssh_key_data and inputs together, and combine them.

https://github.com/ansible/tower-cli/blob/master/tower_cli/utils/resource_decorators.py#L22

But this is different from the problem that $(cat ~/.ssh/id_rsa) won't really work - that's because the line breaks are removed. tower-cli could have a conditional to convert spaces into line breaks, but that kind of highly-automatic behavior can have surprising consequences.

akcrisp commented 6 years ago

Alan,can you explain why the user param is still required ? given I assume this is the user that ssh will login as ? there’s no other user associated with the cred in awx.

tower-cli credential create --name="SSH example" --user=$userval --inputs="$machine_cred_inputs" --credential-type=“Machine"

On 13 Dec 2017, at 15:29, Alan Rominger notifications@github.com wrote:

Feel free to have a stab at it. The thinking here is to have options like --ssh-key-data=..., then you could accept files. The syntax pattern needs consideration, I think that older versions like 3.1.8 would consider ... to be a file.

This would require a translation layer to be added, and I think we have a good example with unified_job_template_options. This decorator could implement options ssh_key_data and inputs together, and combine them.

https://github.com/ansible/tower-cli/blob/master/tower_cli/utils/resource_decorators.py#L22 https://github.com/ansible/tower-cli/blob/master/tower_cli/utils/resource_decorators.py#L22 But this is different from the problem that $(cat ~/.ssh/id_rsa) won't really work - that's because the line breaks are removed. tower-cli could have a conditional to convert spaces into line breaks, but that kind of highly-automatic behavior can have surprising consequences.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ansible/tower-cli/issues/356#issuecomment-351425279, or mute the thread https://github.com/notifications/unsubscribe-auth/ATZJnNFG5l2TcW3vxvJ1ei4htf2YncNXks5s_-1GgaJpZM4PcvN-.

AlanCoding commented 6 years ago

I believe --user is for the owner of the credential in AWX. It's not required in the code I have here, that might have been changed, I don't remember.

akcrisp commented 6 years ago

Ok

Sent from my iPhone

On 13 Dec 2017, at 16:38, Alan Rominger notifications@github.com wrote:

I believe --user is for the owner of the credential in AWX. It's not required in the code I have here, that might have been changed, I don't remember.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.