Obfuscate password in the Ansible Vault

Hi,

My playbook installs Docker on a remote server, and logs in on a docker registry by using user credentials, specified by following task

`

  • name: Log into FIS registry
    docker_login:
    registry: my-company-docker-registry
    username: my-user-account
    password: my-password-in-plain-text

`

Now, what I want to achieve is that my password is stored in the ansible vault and gets decrypted back from the ansible vault.
This to have no plain password anymore in my playbook.
But how do I achieve this?

Hi,

Do encrypt your string with ansible-vault encrypt command and assign a variable to it.

You can use that variable in vars Or defaults dir in any role.

Check below link.

https://docs.ansible.com/ansible/latest/user_guide/vault.html