Ansible Vault
Ansible Vault is a feature of ansible that allows you to keep sensitive data such as passwords or keys in encrypted files, rather than as plaintext in playbooks or roles. These vault files can then be distributed or placed in source control.
CREATE A PLAYBOOK(PROTECTED) VIA ANSIBLE-VAULT
ansible-vault create playbookprotected1.yaml
it will promp new password and confirmation of the password
TRY ACCESS THE PROTECTED PLAYBOOK USING ANSIBLE-PLAYBOOK
ansible-playbook
playbookprotected1.yaml
it will show you an error. Attempting to decrypt but no vault
secrets found as per image below:
ACCESS USING ANSIBLE-PLAYBOOK with --ask-vault
ansible-playbook playbookprotected1.yaml –ask-vault
it will ask you for a password and execute the playbook! as per image below:

DECRYPT THE PROTECTED PLAYBOOK VIA ANSIBLE-VAULT DECRYPT
ansible-vault decrypt playbookprotected1.yaml
it will ask you for a password and decrypt the playbook. now you
can access the playbook (as it is decrypted already), as per image below:
ENCRYPT A NON-PROTECTED PLAYBOOK VIA ANSIBLE-VAULT ENCRYPT
ansible-vault encrypt playbookprotected2.yaml
it will prompt a password and it will encrypt it. thus you
cannot access it anymore: