Ansible-Vault Error: Unexpected Exception: integer division or modulo by zero

460 views
Skip to first unread message

Victor Keenan

unread,
Jan 21, 2016, 10:05:38 AM1/21/16
to Ansible Project
When creating an Ansible vault with:
 
ansible-vault create test.yml

I receive the following error:
  
Unexpected Exception: integer division or modulo by zero

Does anyone have any tips on resolving this? Thanks for the help in advance!

Brian Coca

unread,
Jan 21, 2016, 10:06:40 AM1/21/16
to Ansible Project
what version are you using? there was a bug that caused this but it
has been fixed. Also output with -vvvv would be helfpul




--
Brian Coca

Victor Keenan

unread,
Jan 21, 2016, 10:28:23 AM1/21/16
to Ansible Project
Thanks Brian for the help! I'm using ansible 2.1.0 (devel 5e18bc5955). My -vvvv output is...

Unexpected Exception: integer division or modulo by
zero
the full traceback was
:


Traceback (most recent call last):
 
File "/Users/VictorSK/ansible/bin/ansible-vault", line 85, in <module>
    sys
.exit(cli.run())
 
File "/Users/VictorSK/ansible/lib/ansible/cli/vault.py", line 119, in run
   
self.execute()
 
File "/Users/VictorSK/ansible/lib/ansible/cli/__init__.py", line 99, in execute
    fn
()
 
File "/Users/VictorSK/ansible/lib/ansible/cli/vault.py", line 151, in execute_create
   
self.editor.create_file(self.args[0])
 
File "/Users/VictorSK/ansible/lib/ansible/parsing/vault/__init__.py", line 341, in create_file
   
self._edit_file_helper(filename)
 
File "/Users/VictorSK/ansible/lib/ansible/parsing/vault/__init__.py", line 298, in _edit_file_helper
   
self._shred_file(tmp_path)
 
File "/Users/VictorSK/ansible/lib/ansible/parsing/vault/__init__.py", line 281, in _shred_file
   
self._shred_file_custom(tmp_path)
 
File "/Users/VictorSK/ansible/lib/ansible/parsing/vault/__init__.py", line 248, in _shred_file_custom
   
for _ in range(0, file_len // chunk_len):
ZeroDivisionError: integer division or modulo by zero

Victor Keenan

unread,
Jan 21, 2016, 10:51:14 AM1/21/16
to Ansible Project
Also, I'm on Mac OS 10.11.3 running Python 2.7.10.

Brian Coca

unread,
Jan 21, 2016, 10:51:57 AM1/21/16
to Ansible Project
fixed via http://github.com/ansible/ansible/commit/f26adcc7da7f8e6605167203249648f7b0e74fb7
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/d48e57ba-1415-413e-93a1-f4b8b348d3e3%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

Victor Keenan

unread,
Jan 21, 2016, 11:01:50 AM1/21/16
to Ansible Project
Thanks Brain! Progress, but now a different error...

ERROR! Unexpected Exception: [Errno 2] No such file or directory
the full traceback was
:



Traceback (most recent call last):
 
File "/Users/VictorSK/ansible/bin/ansible-vault", line 85, in <module>
    sys
.exit(cli.run())
 
File "/Users/VictorSK/ansible/lib/ansible/cli/vault.py", line 119, in run
   
self.execute()
 
File "/Users/VictorSK/ansible/lib/ansible/cli/__init__.py", line 99, in execute
    fn
()
 
File "/Users/VictorSK/ansible/lib/ansible/cli/vault.py", line 151, in execute_create
   
self.editor.create_file(self.args[0])

 
File "/Users/VictorSK/ansible/lib/ansible/parsing/vault/__init__.py", line 344, in create_file
   
self._edit_file_helper(filename)

 
File "/Users/VictorSK/ansible/lib/ansible/parsing/vault/__init__.py", line 298, in
_edit_file_helper
    call
(self._editor_shell_command(tmp_path))
 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
   
return Popen(*popenargs, **kwargs).wait()
 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
    errread
, errwrite)
 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
   
raise child_exception
OSError: [Errno 2] No such file or directory

Brian Coca

unread,
Jan 21, 2016, 11:05:26 AM1/21/16
to Ansible Project

Victor Keenan

unread,
Jan 21, 2016, 11:09:17 AM1/21/16
to Ansible Project
No, I'm trying to create a new file/vault. Here is what I'm entering and the output...

local ...pment/Ansible_Playbooks/server_lepr/vars(master) $ ls -an
total
0
drwxr
-xr-x  2 501  20   68 Jan 21 11:07 .
drwxr
-xr-x  9 501  20  306 Jan 21 10:56 ..
local ...pment/Ansible_Playbooks/server_lepr/vars(master) $ ansible-vault create victor.yml -vvvv
No config file found; using defaults
New Vault password:
Confirm New Vault password:
ERROR
! Unexpected Exception: [Errno 2] No such file or directory
the full traceback was
:



Traceback (most recent call last):
 
File "/Users/VictorSK/ansible/bin/ansible-vault", line 85, in <module>
    sys
.exit(cli.run())
 
File "/Users/VictorSK/ansible/lib/ansible/cli/vault.py", line 119, in run
   
self.execute()
 
File "/Users/VictorSK/ansible/lib/ansible/cli/__init__.py", line 99, in execute
    fn
()
 
File "/Users/VictorSK/ansible/lib/ansible/cli/vault.py", line 151, in execute_create
   
self.editor.create_file(self.args[0])
 
File "/Users/VictorSK/ansible/lib/ansible/parsing/vault/__init__.py", line 344, in create_file
   
self._edit_file_helper(filename)
 
File "/Users/VictorSK/ansible/lib/ansible/parsing/vault/__init__.py", line 298, in _edit_file_helper
    call
(self._editor_shell_command(tmp_path))
 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
   
return Popen(*popenargs, **kwargs).wait()
 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
    errread
, errwrite)
 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
   
raise child_exception
OSError: [Errno 2] No such file or directory
local ...pment/Ansible_Playbooks/server_lepr/vars(master) $

Brian Coca

unread,
Jan 21, 2016, 11:40:49 AM1/21/16
to Ansible Project

Victor Keenan

unread,
Jan 21, 2016, 11:48:39 AM1/21/16
to Ansible Project
It works on Ubuntu for me too. Just not on Mac OS X.

Matt Martz

unread,
Jan 21, 2016, 12:26:36 PM1/21/16
to ansible...@googlegroups.com
What contents are you putting in the vault file?  I can get this to happen if I put nothing in the file.  In which case the following is the cause:

  File "/Users/matt/python_venvs/ansibledev/ansible/lib/ansible/parsing/vault/__init__.py", line 249, in _shred_file_custom
    for _ in range(0, file_len // chunk_len):
ZeroDivisionError: integer division or modulo by zero

But is this happening if you put content into the file?

We should probably solve the above error regardless.

Also, what EDITOR is being used on Ubuntu and Mac?  Are they both vim? What versions?


For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Victor Keenan

unread,
Jan 21, 2016, 12:34:50 PM1/21/16
to Ansible Project
Hi Matt, thanks for the help!

I'm creating a blank file to add content. I thought the process was use

ansible-vault create filename.yml

and then it opens in your default editor to add content. Mine is Vim 7.3. I'm getting the error on create.

If I have an existing file with content already and use

ansible-vault encrypt filename.yml

it works fine. So does the decrypt command.

Matt Martz

unread,
Jan 21, 2016, 12:41:20 PM1/21/16
to ansible...@googlegroups.com
I think I understand the issue, and based on my experimentation I have created an issue which you can find at https://github.com/ansible/ansible/issues/14055


For more options, visit https://groups.google.com/d/optout.

Victor Keenan

unread,
Jan 21, 2016, 12:45:56 PM1/21/16
to Ansible Project
Thanks for the help Matt. I'll follow the issue on Github.
Reply all
Reply to author
Forward
0 new messages