# use source control credential in playbook

**URL:** <https://forum.ansible.com/t/use-source-control-credential-in-playbook/33827>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [September 16, 2020, 1:16pm UTC](https://forum.ansible.com/t/use-source-control-credential-in-playbook/33827 "2020-09-16T13:16:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Ratliff](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/john_ratliff/32/3007_2.png) [@John\_Ratliff](https://forum.ansible.com/u/John_Ratliff)\
**Post date:** [September 16, 2020, 1:16pm UTC](https://forum.ansible.com/t/use-source-control-credential-in-playbook/33827/1 "2020-09-16T13:16:40Z")

</div>

Is it possible to use a source control credential within a playbook in awx?

I need to clone a repo during the play and I want to use the existing source control credential in the playbook. {{ scm\_username }} or something like that.

Can this be done?

Thanks.

–John Ratliff

---

<div class="post-metadata">

**Author:** ![Mike\_Charchuk](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@Mike\_Charchuk](https://forum.ansible.com/u/Mike_Charchuk)\
**Post date:** [September 16, 2020, 1:28pm UTC](https://forum.ansible.com/t/use-source-control-credential-in-playbook/33827/2 "2020-09-16T13:28:27Z")

</div>

I created a custom credential to do this. Works fine. I could not figure out how to use the built in source control credentials within a playbook.

Mike

---

<div class="post-metadata">

**Author:** ![John\_Ratliff](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/john_ratliff/32/3007_2.png) [@John\_Ratliff](https://forum.ansible.com/u/John_Ratliff)\
**Post date:** [September 16, 2020, 3:03pm UTC](https://forum.ansible.com/t/use-source-control-credential-in-playbook/33827/3 "2020-09-16T15:03:14Z")

</div>

Yeah, that’s what I’m doing right now, but I was hoping not to have to duplicate it.

–John

---

<div class="post-metadata">

**Author:** ![Mike\_Charchuk](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@Mike\_Charchuk](https://forum.ansible.com/u/Mike_Charchuk)\
**Post date:** [September 16, 2020, 3:38pm UTC](https://forum.ansible.com/t/use-source-control-credential-in-playbook/33827/4 "2020-09-16T15:38:32Z")

</div>

Last year I opened a support ticket with redhat for my production Tower install specifically on this and at the time they said it was not possible.

---

<div class="post-metadata">

**Author:** ![hashim\_vayalar](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hashim_vayalar/32/10641_2.png) [@hashim\_vayalar](https://forum.ansible.com/u/hashim_vayalar)\
**Post date:** [September 16, 2020, 4:57pm UTC](https://forum.ansible.com/t/use-source-control-credential-in-playbook/33827/5 "2020-09-16T16:57:57Z")

</div>

Correct me if I’m wrong. Using requirement.yml will resolve this issue right?

---

<div class="post-metadata">

**Author:** ![Mike\_Charchuk](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@Mike\_Charchuk](https://forum.ansible.com/u/Mike_Charchuk)\
**Post date:** [September 16, 2020, 5:24pm UTC](https://forum.ansible.com/t/use-source-control-credential-in-playbook/33827/6 "2020-09-16T17:24:56Z")

</div>

Myself, I have no idea how that can be done but requirements.yml is not something I have used in the past.

---

<div class="post-metadata">

**Author:** ![Philip\_Douglass](https://avatars.discourse-cdn.com/v4/letter/p/3be4f8/32.png) [@Philip\_Douglass](https://forum.ansible.com/u/Philip_Douglass)\
**Post date:** [September 26, 2020, 4:18pm UTC](https://forum.ansible.com/t/use-source-control-credential-in-playbook/33827/7 "2020-09-26T16:18:03Z")

</div>

It seems to me that we could have what we want if only we could add the same SCM credential to a Job Template that we add to the Project. All our roles are downloaded from an internal Git server, and many of our playbooks also need to interact with that same Git server. A requirements.yml file is only for Ansible roles/collections, so that doesn’t cover this use case. We created a Custom Credential Type for this, but it seems redundant.

---

<div class="post-metadata">

**Author:** ![Robert\_Sossomon](https://avatars.discourse-cdn.com/v4/letter/r/97f17d/32.png) [@Robert\_Sossomon](https://forum.ansible.com/u/Robert_Sossomon)\
**Post date:** [September 26, 2020, 4:43pm UTC](https://forum.ansible.com/t/use-source-control-credential-in-playbook/33827/8 "2020-09-26T16:43:08Z")

</div>

Sounds crazy, but if you add a survey on the playbook, you can use those in the jobs. We are doing that for AWS credentials.

---

<div class="post-metadata">

**Author:** ![Philip\_Douglass](https://avatars.discourse-cdn.com/v4/letter/p/3be4f8/32.png) [@Philip\_Douglass](https://forum.ansible.com/u/Philip_Douglass)\
**Post date:** [September 26, 2020, 4:58pm UTC](https://forum.ansible.com/t/use-source-control-credential-in-playbook/33827/9 "2020-09-26T16:58:45Z")

</div>

No, I don’t think so… my Job Template already _has_ a Survey, and still you cannot add an SCM Credential to the credentials list. (I can’t see how adding a Survey would change that!)

Additionally, my Job Template tries to clone a repo in the same form (ssh://git@git.intranet.site/project/repo-name.git) as roles are downloaded from the requirements.yml file. This causes an authentication error, so clearly the SCM credential does not pass through to the job execution, with or without a Survey.

Perhaps you can explain what you’ve done in more detail?
