Attaching machine credential using tower-cli

Here’s the deal:

tower-cli job_template create --name "bljak" --inventory 16 --credential "awx_key" --project "goolamaloo" --playbook "pull.yml" --job-type run --verbosity default --diff-mode true

Inventory, machine credential, playbook and project are present in awx before running this command and are in the same organization.

Problem: The command goes through without a hitch, template is created with all given attributes, but the Credential field in GUI remains empty and the playbook breaks because no credential is specified.
It is still possible to add the same credential manually in the GUI and then the playbook works.

I still haven’t found any way to attach a machine credential to a template (new or existing) using tower-cli. Pls halp.

AWX 6.0.0.0

Ansible 2.8.1

Tower CLI 3.3.4

It looks like the job template credential field was removed before AWX 6.0.0. Management is moved to a related “credentials” endpoint.

I’m guessing that it is sending the “credential” field, and it is just getting ignored in the result. You can confirm using the -v flag and the --format=json CLI option.

Well, Alan, you’re completely right.

tower-cli job_template create --name "bljak" --inventory 16 --credential "awx_key" --project "whatever" --playbook "pull.yml" --job-type "run" --verbosity "default" -v --format=json

returns

"credentials": []

Can this be reported as a bug? Can we expect a fix or a workaround soon?

https://github.com/ansible/tower-cli/issues/719 - does not look like a quick fix is in sight