I have my GitHub Personal Access Token (PAT) stored as a credential in Ansible Tower.
How can I reference this value in my playbook?
I've searched for examples for other Credential Types like "How to use Ansible Tower login credentials in playbook?", but I haven't found one for my use case.
The official documentation also doesn't seem to have examples of how to use this type in a playbook.
Below is an example on how to use "AWS Credential" in a playbook.
vars:
aws:
access_key: '{{ lookup("env", "AWS_ACCESS_KEY_ID") }}'
secret_key: '{{ lookup("env", "AWS_SECRET_ACCESS_KEY") }}'
security_token: '{{ lookup("env", "AWS_SECURITY_TOKEN") }}'
Similarly there should be a syntax for "Github Personal Access Token" credential too but I'm unable to find that info. Ideally it should look something like below
vars:
git:
token: '{{ lookup("env", "GITHUB_PAT") }}'
In understand your question as "How to find out the name from a Credential of type
Github Personal Access Tokenwithin the Ansible Tower Environment (env) as that (name) is not referenced in documentation?"After reading the Ansible Tower documentation about Credentials - Github Personal Access Token (PAT)
and setting up a short test according Credentials - Getting Started with Credentials by using
and Create a Job Template,
I found this
KINDof Credential not referenceable for a Job Template and as the documentation states. This will prevent from Debugging Credential Types.This will most likely be the reason why it is not mentioned within the documentation, as well not under Multi-Credential Assignment and will lead you to the option of using a Credential of type Custom Credential Types.
To summarize
You can't.