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

The archive module executes without errors for non-existent files #9018

Open
1 task done
navisk13 opened this issue Oct 11, 2024 · 3 comments
Open
1 task done

The archive module executes without errors for non-existent files #9018

navisk13 opened this issue Oct 11, 2024 · 3 comments
Labels
bug This issue/PR relates to a bug module module

Comments

@navisk13
Copy link
Contributor

navisk13 commented Oct 11, 2024

Summary

Giving an invalid or non-existent file name or path to the path parameter of the archive module still executes the playbook successfully without throwing an error.

Issue Type

Bug Report

Component Name

archive

Ansible Version

$ ansible --version
ansible [core 2.17.4]
  config file = None
  configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/.local/lib/python3.12/site-packages/ansible
  ansible collection location = /home/ubuntu/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ubuntu/.local/bin/ansible
  python version = 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
# /home/ubuntu/.local/lib/python3.12/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 9.4.0  

# /usr/lib/python3/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.general 8.3.0  

Configuration

$ ansible-config dump --only-changed
ANSIBLE_NOCOWS(env: ANSIBLE_NOCOWS) = True
CONFIG_FILE() = None
DEFAULT_VAULT_PASSWORD_FILE(env: ANSIBLE_VAULT_PASSWORD_FILE) = /home/ubuntu/.vault_pass.txt

OS / Environment

Target OS: Ubuntu 24.04.1 LTS running in Docker

Steps to Reproduce

- name: Test archive
  hosts: ubuntu1
  become: true
  vars_files:
    - vault.yml
  tasks:
    - name: Compress file into an archive
      community.general.archive:
        path: a/random/nonexistent/file
        format: zip

The command used to run the playbook: ansible-playbook -i inventory.ini playbook.yml

Expected Results

I expected Ansible to raise an error indicating that the file I was attempting to compress into a ZIP file could not be found.

Actual Results

The playbook executes successfully without any errors, even when an invalid file path is provided. While no changes are applied, the absence of an error message can lead to confusion, especially in larger playbooks. Users might assume the action was completed successfully, overlooking the fact that the file was not found and the intended operation did not occur.

ok: [ubuntu1] => {
    "archived": [],
    "arcroot": "a/random/nonexistent/",
    "changed": false,
    "dest": "a/random/nonexistent/file.zip",
    "dest_state": "absent",
    "expanded_exclude_paths": [],
    "expanded_paths": [
        "a/random/nonexistent/file"
    ],
    "invocation": {
        "module_args": {
            "attributes": null,
            "dest": null,
            "exclude_path": [],
            "exclusion_patterns": null,
            "force_archive": false,
            "format": "zip",
            "group": null,
            "mode": null,
            "owner": null,
            "path": [
                "a/random/nonexistent/file"
            ],
            "remove": false,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "unsafe_writes": false
        }
    },
    "missing": [
        "a/random/nonexistent/file"
    ]
}

Code of Conduct

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

This comment was marked as outdated.

@ansibullbot ansibullbot added the bug This issue/PR relates to a bug label Oct 11, 2024
@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 the module module label Oct 11, 2024
@felixfontein felixfontein changed the title The community.general.archive module executes without errors for non-existent files The archive module executes without errors for non-existent files Oct 11, 2024
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 module module
Projects
None yet
Development

No branches or pull requests

2 participants