# Get Tower login user from/to Job Template playbook

**URL:** <https://forum.ansible.com/t/get-tower-login-user-from-to-job-template-playbook/32108>\
**Category:** AWX Project\
**Tags:** awx-project\
**Created:** [January 31, 2020, 1:07pm UTC](https://forum.ansible.com/t/get-tower-login-user-from-to-job-template-playbook/32108 "2020-01-31T13:07:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Konstantin1](https://avatars.discourse-cdn.com/v4/letter/k/e495f1/32.png) [@Konstantin1](https://forum.ansible.com/u/Konstantin1)\
**Post date:** [January 31, 2020, 1:07pm UTC](https://forum.ansible.com/t/get-tower-login-user-from-to-job-template-playbook/32108/1 "2020-01-31T13:07:48Z")

</div>

It’s not possible. You should use vaults/credentials to store sensitive data.

---

<div class="post-metadata">

**Author:** ![bianca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bianca/32/7233_2.png) [@bianca](https://forum.ansible.com/u/bianca)\
**Post date:** [January 31, 2020, 2:30pm UTC](https://forum.ansible.com/t/get-tower-login-user-from-to-job-template-playbook/32108/2 "2020-01-31T14:30:38Z")

</div>

Hi aki,

It IS possible to have your username/password in a playbook, but it is NOT recommended.

- Bianca

---

<div class="post-metadata">

**Author:** ![bianca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bianca/32/7233_2.png) [@bianca](https://forum.ansible.com/u/bianca)\
**Post date:** [January 31, 2020, 7:09pm UTC](https://forum.ansible.com/t/get-tower-login-user-from-to-job-template-playbook/32108/3 "2020-01-31T19:09:33Z")

</div>

Hey again aki, I wanted to expand on my earlier response a bit more.

The hierarchy which Ansible/Tower modules uses to search for login information is as follows [in order of lowest —\> highest on the hierarchy]:

/etc/tower/tower\_cli.cfg  
\<user\_dir\>/.tower\_cli.cfg  
Any tower\_cli.cfg file from / to cwd  
Any values specified in the config file pointed to in the modules’ tower\_config parameter  
Any values specified in the modules’ tower\_\* parameters (username/password/host/etc)

You can set env vars for the playbook to use via the UI (see link below for where you can do that):  
[https://docs.ansible.com/ansible-tower/latest/html/userguide/credentials.html#ansible-tower](https://docs.ansible.com/ansible-tower/latest/html/userguide/credentials.html#ansible-tower)

… or via API, by POSTing something like this (with appropriate info inserted, and either ‘user’, ‘team’, or ‘organization’ where “user” is listed in the example below) at the api/v2/credentials/ endpoint:

{  
“name”: “XYZ”,  
“description”: “for testing”,  
“organization”: null,  
“credential\_type”: 16,  
“inputs”: {  
“host”: “[desired host address]”,  
“password”: “[password]”,  
“username”: “[username”,  
“verify\_ssl”: false  
}  
}

(Note that “credential\_type”: 16 makes this a Tower credential)

After you do this, the playbook can pull in the env vars via something like the below:
