Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unarchive task fails second time it's ran #24781

Closed
sebastiaopf opened this issue May 18, 2017 · 8 comments
Closed

Unarchive task fails second time it's ran #24781

sebastiaopf opened this issue May 18, 2017 · 8 comments
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. m:unarchive This issue/PR relates to the unarchive module. module This issue/PR relates to a module. python3

Comments

@sebastiaopf
Copy link

sebastiaopf commented May 18, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

unarchive

ANSIBLE VERSION
ansible 2.3.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
OS / ENVIRONMENT

Controller site: 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Host: 4.4.0-1013-aws #22-Ubuntu SMP Fri Mar 31 15:41:31 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

SUMMARY

Unarchive module fails with "Error: a bytes-like object is required, not 'str'\r\n" error message, but only if the task would not be executed, because the files are already extracted on the remote host.

STEPS TO REPRODUCE
  • Create a task that uses unarchive to extract some files to the remote host
  • Run the task for the first time, when the files don't exist on the remote host
  • Task should complete without errors
  • Run the task again, without changing anything
  • Task should fail with "Error: a bytes-like object is required, not 'str'\r\n"" error message

Python version on remote host is Python 3.5.2.

Full error message:

fatal: [***]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to *** closed.\r\n", "module_stdout": "\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_i9aq7ts5/ansible_module_unarchive.py\", line 885, in <module>\r\n    main()\r\n  File \"/tmp/ansible_i9aq7ts5/ansible_module_unarchive.py\", line 839, in main\r\n    check_results = handler.is_unarchived()\r\n  File \"/tmp/ansible_i9aq7ts5/ansible_module_unarchive.py\", line 475, in is_unarchived\r\n    crc = crc32(dest)\r\n  File \"/tmp/ansible_i9aq7ts5/ansible_module_unarchive.py\", line 172, in crc32\r\n    return binascii.crc32(open(path).read()) & 0xffffffff\r\nTypeError: a bytes-like object is required, not 'str'\r\n", "msg": "MODULE FAILURE", "rc": 0}
	to retry, use: --limit @...
- name: Extract application files to server
  unarchive:
    src: roles/myapp/files/app.zip
    dest: /opt/myapp
    creates: README.md
EXPECTED RESULTS

Task should execute without errors both times.

ACTUAL RESULTS

Task fails the second time it's executed (when files already exist on the server)

Removed host name but it's ec2 instance.

fatal: [***]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to *** closed.\r\n", "module_stdout": "\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_i9aq7ts5/ansible_module_unarchive.py\", line 885, in <module>\r\n    main()\r\n  File \"/tmp/ansible_i9aq7ts5/ansible_module_unarchive.py\", line 839, in main\r\n    check_results = handler.is_unarchived()\r\n  File \"/tmp/ansible_i9aq7ts5/ansible_module_unarchive.py\", line 475, in is_unarchived\r\n    crc = crc32(dest)\r\n  File \"/tmp/ansible_i9aq7ts5/ansible_module_unarchive.py\", line 172, in crc32\r\n    return binascii.crc32(open(path).read()) & 0xffffffff\r\nTypeError: a bytes-like object is required, not 'str'\r\n", "msg": "MODULE FAILURE", "rc": 0}
	to retry, use: --limit @...
@ansibot
Copy link
Contributor

ansibot commented May 18, 2017

@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. python3 labels May 18, 2017
@sebastiaopf
Copy link
Author

Complementing, this could be somewhat related to #17038 and as per @abadger comment (#17038 (comment)) i'm opening a new issue.

@nitzmahone nitzmahone removed the needs_triage Needs a first human triage before being processed. label May 19, 2017
@nitzmahone
Copy link
Member

Does it fail the same way under Python2?

@sebastiaopf
Copy link
Author

Didn't try with python 2, since this remote host only has python 3 installed. Will spin up a Vagrant vm and test with that.

@sebastiaopf
Copy link
Author

@nitzmahone didn't happen for me with python2 on the remote host.
Do you need any other test performed?

@ghost
Copy link

ghost commented May 25, 2017

Hi. Today I had a similar issue. After second run of unarchive task with "list_files=True" I can't ssh into servers anymore with my deploy user. The ownership for /home/$USER is changed to the user with UID 1000. In my case from ansible:users into ubuntu:users and centos:users for centos machines.

@abadger
Copy link
Contributor

abadger commented May 25, 2017

Fixed for devel in: c7860d4 and cherry-picked to the stable-2.3 branch here: 561d424

This should be fixed when 2.3.1.is released.

@abadger abadger closed this as completed May 25, 2017
@abadger abadger moved this from TODO to Done in Python 3 compatibility May 25, 2017
@sebastiaopf
Copy link
Author

@abadger Thank you very much for the quick fix.

@dagwieers dagwieers added the m:unarchive This issue/PR relates to the unarchive module. label Sep 27, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. m:unarchive This issue/PR relates to the unarchive module. module This issue/PR relates to a module. python3
Projects
No open projects
Development

No branches or pull requests

5 participants