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

community.general.archive requires lzma module when format != xz when a dest file exists #5391

Closed
1 task done
pstrzelczak opened this issue Oct 19, 2022 · 7 comments · Fixed by #5393
Closed
1 task done
Labels
bug This issue/PR relates to a bug files has_pr module module plugins plugin (any type) traceback

Comments

@pstrzelczak
Copy link

Summary

As in summary. It used to work in ansible 2.10

Issue Type

Bug Report

Component Name

archive

Ansible Version

$ ansible --version
ansible [core 2.13.5]
  config file = None
  configured module search path = ['/home/docker_user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/docker_user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.8.12 (default, May 10 2022, 23:46:40) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]
  jinja version = 3.1.2
  libyaml = False

Community.general Version

$ ansible-galaxy collection list community.general
/usr/local/lib/python3.8/site-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.12) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "

# /usr/local/lib/python3.8/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 5.7.0  

Configuration

$ ansible-config dump --only-changed

OS / Environment

Rocky 8 on controller node
CentOS 7 on target node

Steps to Reproduce

~ docker run -d centos:7 tail -f /dev/null
65f128b924c551a83d1e5a68f604559ab49f3a18bc55800138d05a767aeaf053
~ docker exec -it 65f128b924c5 mkdir /tmp/foo
~ docker exec -it 65f128b924c5 touch /tmp/bar
~ ansible all -i 65f128b924c5, -c docker -m community.general.archive -a 'dest=/tmp/bar path=/tmp/foo'

Expected Results

65f128b924c5 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"archived": [],
"arcroot": "/tmp/",
"changed": true,
"dest": "/tmp/bar",
"expanded_exclude_paths": [],
"expanded_paths": [
"/tmp/foo"
],
"gid": 0,
"group": "root",
"missing": [],
"mode": "0644",
"owner": "root",
"size": 54,
"state": "file",
"uid": 0
}

Actual Results

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: NameError: global name 'lzma' is not defined
65f128b924c5 | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1666185363.709719-328-48756839893166/AnsiballZ_archive.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1666185363.709719-328-48756839893166/AnsiballZ_archive.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1666185363.709719-328-48756839893166/AnsiballZ_archive.py\", line 48, in invoke_module\n    run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\n    fname, loader, pkg_name)\n  File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\n    mod_name, mod_fname, mod_loader, pkg_name)\n  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\n    exec code in run_globals\n  File \"/tmp/ansible_community.general.archive_payload_GXlgjp/ansible_community.general.archive_payload.zip/ansible_collections/community/general/plugins/modules/files/archive.py\", line 662, in <module>\n  File \"/tmp/ansible_community.general.archive_payload_GXlgjp/ansible_community.general.archive_payload.zip/ansible_collections/community/general/plugins/modules/files/archive.py\", line 629, in main\n  File \"/tmp/ansible_community.general.archive_payload_GXlgjp/ansible_community.general.archive_payload.zip/ansible_collections/community/general/plugins/modules/files/archive.py\", line 604, in get_archive\n  File \"/tmp/ansible_community.general.archive_payload_GXlgjp/ansible_community.general.archive_payload.zip/ansible_collections/community/general/plugins/modules/files/archive.py\", line 535, in __init__\n  File \"/tmp/ansible_community.general.archive_payload_GXlgjp/ansible_community.general.archive_payload.zip/ansible_collections/community/general/plugins/modules/files/archive.py\", line 314, in __init__\n  File \"/tmp/ansible_community.general.archive_payload_GXlgjp/ansible_community.general.archive_payload.zip/ansible_collections/community/general/plugins/modules/files/archive.py\", line 387, in destination_checksums\n  File \"/tmp/ansible_community.general.archive_payload_GXlgjp/ansible_community.general.archive_payload.zip/ansible_collections/community/general/plugins/modules/files/archive.py\", line 588, in _get_checksums\nNameError: global name 'lzma' is not defined\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

cc @bendoh
click here for bot help

@ansibullbot ansibullbot added bug This issue/PR relates to a bug files module module plugins plugin (any type) traceback labels Oct 19, 2022
@felixfontein
Copy link
Collaborator

This requirement is mentioned in the documenation (https://docs.ansible.com/ansible/latest/collections/community/general/archive_module.html#notes), although not where it should be (under requirements).

@felixfontein
Copy link
Collaborator

I created #5392 to update the documentation.

@pstrzelczak
Copy link
Author

This requirement is mentioned in the documenation (https://docs.ansible.com/ansible/latest/collections/community/general/archive_module.html#notes), although not where it should be (under requirements).

@felixfontein the requirement says lzma is required if using xz format. In my scenario I don't use xz format.

@felixfontein
Copy link
Collaborator

Oh, sorry, I missed that part apparently. The reason for that is https://github.com/ansible-collections/community.general/blob/main/plugins/modules/files/archive.py#L588.

@felixfontein
Copy link
Collaborator

#5393 will fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug files has_pr module module plugins plugin (any type) traceback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants