use source control credential in playbook

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

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

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

–John

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.

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

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

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.

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.

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?