# AWX select credential in job template dynamically based on logged in user

**URL:** <https://forum.ansible.com/t/awx-select-credential-in-job-template-dynamically-based-on-logged-in-user/28753>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [October 9, 2018, 3:51pm UTC](https://forum.ansible.com/t/awx-select-credential-in-job-template-dynamically-based-on-logged-in-user/28753 "2018-10-09T15:51:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darkhan](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Darkhan](https://forum.ansible.com/u/Darkhan)\
**Post date:** [October 9, 2018, 3:51pm UTC](https://forum.ansible.com/t/awx-select-credential-in-job-template-dynamically-based-on-logged-in-user/28753/1 "2018-10-09T15:51:41Z")

</div>

Hello,

In our organization each user must use his own credentials for audit purposes so i can’t have one central key for awx. Therefore every user will define his own machine type credential with his ssh key attached to it.  
My question is how do i set the job template that the job will pick the credential for the user that is logged in awx? Prompt on launch would work but i was hoping awx would be smart enough to do this on it’s own.  
Any ideas?

Best regards

---

<div class="post-metadata">

**Author:** ![Bill\_Nottingham1](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@Bill\_Nottingham1](https://forum.ansible.com/u/Bill_Nottingham1)\
**Post date:** [October 9, 2018, 4:42pm UTC](https://forum.ansible.com/t/awx-select-credential-in-job-template-dynamically-based-on-logged-in-user/28753/2 "2018-10-09T16:42:53Z")

</div>

Adrian Sebastian Dutu (dutu.adrian90@gmail.com) said:

> In our organization each user must use his own credentials for audit  
> purposes so i can't have one central key for awx. Therefore every user will  
> define his own machine type credential with his ssh key attached to it.  
> My question is how do i set the job template that the job will pick the  
> credential for the user that is logged in awx? Prompt on launch would work  
> but i was hoping awx would be smart enough to do this on it's own.  
> Any ideas?

A user could have 5/10/100 different 'personal' credentials that they could  
be using for different use cases, so I'm not sure how you would codify  
picking just one.

Bill

---

<div class="post-metadata">

**Author:** ![Darkhan](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Darkhan](https://forum.ansible.com/u/Darkhan)\
**Post date:** [October 9, 2018, 5:28pm UTC](https://forum.ansible.com/t/awx-select-credential-in-job-template-dynamically-based-on-logged-in-user/28753/3 "2018-10-09T17:28:52Z")

</div>

So i guess we can’t do this right now.

It’s not really that hard if they want to do it. Just consider the logged in user as a variable and if you name the credentials the same for each user, it would be pretty easy to do a lookup after that. Or even make a new type of credential. It’s not something that wasn’t done before.

---

<div class="post-metadata">

**Author:** ![digitalsy](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@digitalsy](https://forum.ansible.com/u/digitalsy)\
**Post date:** [March 25, 2019, 5:14pm UTC](https://forum.ansible.com/t/awx-select-credential-in-job-template-dynamically-based-on-logged-in-user/28753/4 "2019-03-25T17:14:30Z")

</div>

Bumping because I also would like to have some sort of way to pass currently logged in user credentials through to a playbook without having to store those credentials or prompt/survey them again. I know you can use the tower\_user\_name variable to pass the currently logged in user’s **username** but there doesn’t seem to be any way to pass the encrypted password or call some kind of logged in user object to a playbook for credential use. This would be highly desirable!

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [March 26, 2019, 1:00pm UTC](https://forum.ansible.com/t/awx-select-credential-in-job-template-dynamically-based-on-logged-in-user/28753/5 "2019-03-26T13:00:48Z")

</div>

We’re about to merge secrets management system support into AWX, this might be a better solution for you though not exactly “automatic”. You could store credentials in something like hashi vault and reference the secrets that way.

---

<div class="post-metadata">

**Author:** ![Darkhan](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Darkhan](https://forum.ansible.com/u/Darkhan)\
**Post date:** [April 4, 2019, 11:26am UTC](https://forum.ansible.com/t/awx-select-credential-in-job-template-dynamically-based-on-logged-in-user/28753/6 "2019-04-04T11:26:14Z")

</div>

Was this released in 4.0? Is there any documentation about it?

---

<div class="post-metadata">

**Author:** ![Uriel](https://avatars.discourse-cdn.com/v4/letter/u/53a042/32.png) [@Uriel](https://forum.ansible.com/u/Uriel)\
**Post date:** [April 4, 2019, 2:30pm UTC](https://forum.ansible.com/t/awx-select-credential-in-job-template-dynamically-based-on-logged-in-user/28753/7 "2019-04-04T14:30:00Z")

</div>

Looks like the PR was merged after the 4.0.0 release. If you’re building off the devel branch you can get the external secrets management bit. Docs look like they’re still being finalized. Here are the bits that I found so far

Original Github issue:  
[https://github.com/ansible/awx/issues/2238](https://github.com/ansible/awx/issues/2238)

PR for the feature:  
[https://github.com/ansible/awx/pull/3098](https://github.com/ansible/awx/pull/3098)

Credential plugin docs:  
[https://github.com/ansible/awx/blob/d987c6e3f75eafdb6a535fa7fa31706254758193/docs/credential\_plugins.md](https://github.com/ansible/awx/blob/d987c6e3f75eafdb6a535fa7fa31706254758193/docs/credential_plugins.md)
