- Bug Report
unarchive
ansible 2.1.0.0
config file = /path/to/ansible.cfg
configured module search path = Default w/o overrides
Contents of ansible.cfg:
[defaults]
inventory = contrib/ec2.py
vault_password_file = .vault_password
hash_behaviour = merge
[ssh_connection]
pipelining = True
Gentoo x64 Linux
The error message formatting in unarchive
doesn't seem to handle string file modes properly, leading to a TypeError at runtime.
While executing this task:
- name: install packer
tags: packer
unarchive:
copy: false
src: https://releases.hashicorp.com/packer/0.10.1/packer_0.10.1_linux_amd64.zip
dest: /usr/local/bin
owner: root
group: root
mode: 'u=rwx,g=rx,o=rx'
the following occurs:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: %o format: a number is required, not str
fatal: [jenkins-node]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):
File \"/tmp/ansible_5KjD3R/ansible_module_unarchive.py\", line 751, in <module>
main()
File \"/tmp/ansible_5KjD3R/ansible_module_unarchive.py\", line 711, in main
check_results = handler.is_unarchived()
File \"/tmp/ansible_5KjD3R/ansible_module_unarchive.py\", line 397, in is_unarchived
err += 'Path %s differs in permissions (%o vs %o)\
' % (path, self.file_args['mode'], stat.S_IMODE(st.st_mode))
TypeError: %o format: a number is required, not str
", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
I haven't figured out why exactly the code ended up in that particular case, but the code in question is in unarchive.py, which looks like this:
err += 'Path %s differs in permissions (%o vs %o)\n' % (path, mode, stat.S_IMODE(st.st_mode))
%o
is for signed octal values according to https://docs.python.org/2/library/stdtypes.html#string-formatting, so I'm guessing that mode
is the string from the original task definition, which is causing the TypeError.
It works fine if I use numeric file modes (e.g. 0755 here), so it should do that for string modes too.
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: %o format: a number is required, not str
fatal: [jenkins-node]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):
File \"/tmp/ansible_5KjD3R/ansible_module_unarchive.py\", line 751, in <module>
main()
File \"/tmp/ansible_5KjD3R/ansible_module_unarchive.py\", line 711, in main
check_results = handler.is_unarchived()
File \"/tmp/ansible_5KjD3R/ansible_module_unarchive.py\", line 397, in is_unarchived
err += 'Path %s differs in permissions (%o vs %o)\
' % (path, self.file_args['mode'], stat.S_IMODE(st.st_mode))
TypeError: %o format: a number is required, not str
", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}