How do we mask account and access token of github on the src are written in requirements.yml file?

Hi everyone,
Do you know how do we mask account and access token of github on the src are written in requirements.yml file?

---
- name: test
  src: https://user_name:personnal_access_token@github.com/.../ansible-test.git
  version: main  
  scm: git

Hi,
Thi is not required with ansible and awx.

If repo is private and you use command line, will be prompt ed the Username and password/token.

If you use AWX, it use the source credential to download repo.
One limitation in awx is that you have only one source credential, so the same credential it’s used to access on all roles/Collection (if thery require authentication).

1 Like

In addition to @tanganellilore message, you usually don’t manage credentials here; you could use git helper to store credentials (not recommended as creds are stored unencrypted on disk. Also more info here), or better, use ssh to access your private repos, and manage connections in ssh client configuration:

# ~/.ssh/config

Host github.com
  IdentityFile /my/private/keyfile/path
  PreferredAuthentications publickey

Then push the corresponding public key to your Github account.

If you defined a passphrase on your private key, then better use an ssh agent as well to avoid being bothered decrypting your key everytime you use it, but that’s a matter for another time.

Anyways, Ansible will pickup on this underlying config. It goes the same for all ssh config FYI.

Edit: Forgot to say, but you’ll have to use the appropriate URL in your requirements.yml file to reflect this change; something like this: git@github.com:<yourUserName>/<yourRepoPath>.git.

1 Like