I would like to do something like
ansible-playbook myPlaybook.yml -i myHostFile
instead of
ansible-playbook myPlaybook.yml -i myHostFile --ask-vault-pass
Your requirement is not clear. Following my comments, this answer is a specific example of how to secure your vault passwords inside your gnome linux session keyring using the vault-keyring-client.py
script provided by ansible community contribs (hoping it will give you some ideas of how to fix the problem in your specific case).
pip install keyring
cd $HOME/bin
curl -o vault-keyring-client https://raw.githubusercontent.com/ansible-community/contrib-scripts/main/vault/vault-keyring-client.py
chmod 0700 vault-keyring-client
login
keyring after launching seahorse
(i.e. "Passwords and keys").
vault-keyring-client --set --vault-id yourid1
vault-keyring-client --set --vault-id yourid2
.bashrc
(or whatever shell you use...)
export ANSIBLE_VAULT_IDENTITY_LIST=yourid1@$HOME/bin/vault-keyring-client,yourid2@$HOME/bin/vault-keyring-client
export ANSIBLE_VAULT_ENCRYPT_IDENTITY=yourid1
# using the default encrypt vault-id
ansible-vault encrypt somefile
ansible-vault encrypt_string "somestring"
# using an other vault-id than default
ansible-vault encrypt --encrypt-vault-id yourid2 somefile
ansible-vault encrypt_string --encrypt-vault-id yourid2 "somestring"
ansible-playbook -i your_inventory your_playbook
ansible-playbook -i your inventory somehost -m debug -a "msg={{ some_encrypted_var }}"