For creating encrypted files, the ‘ansible-vault create’ command is used. For example:
$ ansible-vault create filename.yaml
After that, a prompt will pop up for you to create a password and then input it again for confirmation. You’ll then be able to access the file and add and edit the data.