# Attaching machine credential using tower-cli

**URL:** <https://forum.ansible.com/t/attaching-machine-credential-using-tower-cli/31070>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [August 19, 2019, 9:32am UTC](https://forum.ansible.com/t/attaching-machine-credential-using-tower-cli/31070 "2019-08-19T09:32:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mihovil\_Subasa](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@Mihovil\_Subasa](https://forum.ansible.com/u/Mihovil_Subasa)\
**Post date:** [August 19, 2019, 9:32am UTC](https://forum.ansible.com/t/attaching-machine-credential-using-tower-cli/31070/1 "2019-08-19T09:32:32Z")

</div>

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.

```auto
AWX 6.0.0.0

```

Ansible 2.8.1

Tower CLI 3.3.4

---

<div class="post-metadata">

**Author:** ![AlanCoding](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alancoding/32/301_2.png) [@AlanCoding](https://forum.ansible.com/u/AlanCoding)\
**Post date:** [August 19, 2019, 12:35pm UTC](https://forum.ansible.com/t/attaching-machine-credential-using-tower-cli/31070/2 "2019-08-19T12:35:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mihovil\_Subasa](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@Mihovil\_Subasa](https://forum.ansible.com/u/Mihovil_Subasa)\
**Post date:** [August 20, 2019, 2:14pm UTC](https://forum.ansible.com/t/attaching-machine-credential-using-tower-cli/31070/3 "2019-08-20T14:14:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![klaasdemter](https://avatars.discourse-cdn.com/v4/letter/k/3bc359/32.png) [@klaasdemter](https://forum.ansible.com/u/klaasdemter)\
**Post date:** [August 20, 2019, 6:26pm UTC](https://forum.ansible.com/t/attaching-machine-credential-using-tower-cli/31070/4 "2019-08-20T18:26:12Z")

</div>

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