Accessing encrypted variables fails

I have a playbook that executes several commands that require variable input.
So far I have done the following.
Created encrypted yml file in /etc/ansible/secrets folder with the format
pass_1: ‘string’
pass_2: ‘string’

in the playbook I reference these variables as

  • name such and such task
    command: util_program -p {{ pass_1 }}

playbook is being run as:

ansible-playbook -i ansible_inventory playbook_name.yml --ask-vault-pass

this asks me for vault password which it takes but turns up an error that pass_1 variable is not defined

I’m not sure if this is because the format of the password file is not correct or if i need to explicitly specify location to ansible-playbook?

/etc/ansible/secrets has no meaning to Ansible, it won’t import it automatically. So, yes, you need to specify it in your playbook.