ansible-plabook keeps saying ansible-vault variables are undefined!!

Gittes
Wed, 13 Aug 2025 04:17:31 +0000
Get Help

Hello everyone!

I’m working on a project for a company I am working for.

Whenever I use ansible-playbook with three variable files, two files are encrypted with ansible-vault and each file has one variable. The variables for each file are the_vault_test, the_vault_test2 and the_test.

Here is the file/directory structure and the output of ansible-playbook:

CAPSULE-V-001-MM037:test chris$ tree
.
├── 003_vault_secrets_test.enc
├── ansible.cfg
├── group_vars
│ └── all
│ ├── 002_vault_secrets_test.enc
│ ├── 003_vault_secrets_test.enc
│ └── vars.yml
├── inventory
└── test_vault.yml

3 directories, 7 files

CAPSULE-V-001-MM037:test chris$ ansible-playbook --inventory inventory --private-key ~/.ssh/staging_ansible_id_ed25519 --user staging_ansible test_vault.yml --vault-password ~/.secrets/ansible_vault_password.txt --extra-vars group_vars/all/002_vault_secrets_test.enc --extra-vars 003_vault_secrets_test.enc

PLAY [My First Play] ***************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************************************************************************************************************
ok: [capsule-v-001-mm037]
ok: [capsule-v-001-mm038]

TASK [debug vault_the_test] ********************************************************************************************************************************************************************************************************************
ok: [capsule-v-001-mm037] => {
“vault_the_test”: “VARIABLE IS NOT DEFINED!”
}
ok: [capsule-v-001-mm038] => {
“vault_the_test”: “VARIABLE IS NOT DEFINED!”
}

TASK [debug vault_the_test] ********************************************************************************************************************************************************************************************************************
ok: [capsule-v-001-mm037] => {
“vault_the_test2”: “VARIABLE IS NOT DEFINED!”
}
ok: [capsule-v-001-mm038] => {
“vault_the_test2”: “VARIABLE IS NOT DEFINED!”
}

TASK [debug the_test] **************************************************************************************************************************************************************************************************************************
ok: [capsule-v-001-mm037] => {
“the_test”: “Will this work?”
}
ok: [capsule-v-001-mm038] => {
“the_test”: “Will this work?”
}

PLAY RECAP *************************************************************************************************************************************************************************************************************************************
capsule-v-001-mm037 : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
capsule-v-001-mm038 : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

CAPSULE-V-001-MM037:test chris$ ansible-playbook --version
ansible-playbook [core 2.18.7]
config file = /Users/chris/Projects/checkouts/test/ansible.cfg
configured module search path = [‘/Users/chris/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /opt/homebrew/Cellar/ansible/11.8.0/libexec/lib/python3.13/site-packages/ansible
ansible collection location = /Users/chris/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible-playbook
python version = 3.13.6 (main, Aug 6 2025, 13:05:20) [Clang 17.0.0 (clang-1700.0.13.3)] (/opt/homebrew/Cellar/ansible/11.8.0/libexec/bin/python)
jinja version = 3.1.6
libyaml = True
CAPSULE-V-001-MM037:test chris$ uname
Darwin
CAPSULE-V-001-MM037:test chris$ uname -a
Darwin CAPSULE-V-001-MM037.local 24.4.0 Darwin Kernel Version 24.4.0: Wed Mar 19 21:11:02 PDT 2025; root:xnu-11417.101.15~1/RELEASE_ARM64_T8132 arm64
CAPSULE-V-001-MM037:test chris$ sw
sw_vers swcutil swift swift-inspect swiftc
CAPSULE-V-001-MM037:test chris$ sw_vers
ProductName: macOS
ProductVersion: 15.4
BuildVersion: 24E248
CAPSULE-V-001-MM037:test chris$ brew --version
Homebrew >=4.3.0 (shallow or no git repository)

It use to work and now it doesn’t! I made a simple test outside of git! I even asked a friend that works at Red Hat and works with Ansible everyday!

Please help!

15 posts - 6 participants