Trellis: Problem running vault password script . v a u l t _ p a s s ([Errno 8] Exec format error)

Created on 13 Dec 2016  路  7Comments  路  Source: roots/trellis

Submit a feature request or bug report

Bug report

The command ansible-vault view group_vars/development/vault.yml returns ERROR! Problem running vault password script / v a g r a n t / v a u l t / . v a u l t _ p a s s ([Errno 8] Exec format error). If this is not a script, remove the executable bit from the file.

With Windows, with ansible-vault started from vagrant box.

I think it's because .vault_pass has full rights instead of 600 (but cannot chmod within vagrant folder in box):

-rwxrwxrwx 1 vagrant vagrant 20 Oct 21 21:32 .vault_pass

Please describe your local environment:

Ansible version: X=2.2.0.0

OS: Windows 10

Vagrant version: 1.9.1

Most helpful comment

Building on Windows, running ansible from inside a docker container.
My password script is just a bash script that echoes an environment variable.
When the script was multiline the script failed to execute because of the windows CRLF
I removed all the line endings and made the script a single line command.
Now I'm getting the error exec format error as above. The script is definitely executable as my command executes the file before running ansible vault decrypt (for debugging purposes).
expect the script to be a python script or any executable file?


Aagh, just got it all working by changing my file from a bash based
echo $ANSIBLE_VAULT_PASSWORD
to

!/usr/bin/env python

import os
print os.environ['ANSIBLE_VAULT_PASSWORD']

Please can someone update the docs so it's clear the password script needs to be a python script

All 7 comments

Got the same Problem.

Mounted my vagrantroot/ansible with

vm_config.vm.synced_folder "./ansible", "/opt/it-infra", id: "it-infra", owner: "vagrant", group: "vagrant", mount_options: ["dmode=775,fmode=664"]

To workaround this issue.

Maybe someone will help this

@daBONDi could you see if these steps resolve it?

  • update your Trellis to include #705
  • vagrant reload to refresh the vagrant sync dirs
  • vagrant ssh
  • cd ~/trellis and run your various Ansible commands from there

@fullyint i don't use the Trellis Runbooks. Was thinking i comment on a vagrant issue, sorry for my dumbness :-)

You can close it agan :-)

Building on Windows, running ansible from inside a docker container.
My password script is just a bash script that echoes an environment variable.
When the script was multiline the script failed to execute because of the windows CRLF
I removed all the line endings and made the script a single line command.
Now I'm getting the error exec format error as above. The script is definitely executable as my command executes the file before running ansible vault decrypt (for debugging purposes).
expect the script to be a python script or any executable file?


Aagh, just got it all working by changing my file from a bash based
echo $ANSIBLE_VAULT_PASSWORD
to

!/usr/bin/env python

import os
print os.environ['ANSIBLE_VAULT_PASSWORD']

Please can someone update the docs so it's clear the password script needs to be a python script

Thanks @stephenconnolly1.

Just to add to this, if you are using WSL then store the file in a subdirectory /c/

Building on Windows, running ansible from inside a docker container.

My password script is just a bash script that echoes an environment variable.
When the script was multiline the script failed to execute because of the windows CRLF
I removed all the line endings and made the script a single line command.
Now I'm getting the error exec format error as above. The script is definitely executable as my command executes the file before running ansible vault decrypt (for debugging purposes).
expect the script to be a python script or any executable file?
Aagh, just got it all working by changing my file from a bash based
echo $ANSIBLE_VAULT_PASSWORD
to

!/usr/bin/env python

import os
print os.environ['ANSIBLE_VAULT_PASSWORD']

Please can someone update the docs so it's clear the password script needs to be a python script

I am new to Trellis etc having same issue but did not get your solution. Please tell me exactly what to do in steps?

Two years ago and not sure I even remember. The vault password script option is used if you store the password in another system outside ansible and need to retrieve it programmatically. I was assuming the script could be a bash script but it looks like it needs to be written in python because that's what ansible is written in as well. The script just needs to echo the desired password out to stdout and ansible reads it from there.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pajtai picture pajtai  路  3Comments

baradhili picture baradhili  路  8Comments

amelotrgr picture amelotrgr  路  6Comments

swalkinshaw picture swalkinshaw  路  4Comments

louim picture louim  路  5Comments