ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
815 stars 1.49k forks source link

cargo shows changed status for installed package #8949

Open chdalski opened 3 hours ago

chdalski commented 3 hours ago

Summary

When I try to install cargo-audit with community.general.cargo and cargo-audit is already installed (as latest version) it shows as changed even though nothing has changed. This does not happen for other packages.

Note: There is a closed issue (#4052) that reported the same behavior when package names contains hyphens. However, the underline issue doesn't seem to be fixed for all package names.

Issue Type

Bug Report

Component Name

cargo

Ansible Version

$ ansible --version

ansible [core 2.16.11]
  config file = /home/chris/.ansible.cfg
  configured module search path = ['/home/chris/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /home/chris/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.6 (main, Sep  9 2024, 00:00:00) [GCC 14.2.1 20240801 (Red Hat 14.2.1-1)] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /home/chris/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 9.3.0  

# /usr/lib/python3.12/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 8.6.5  

Configuration

$ ansible-config dump --only-changed

CONFIG_FILE() = /home/chris/.ansible.cfg
DEFAULT_LOCAL_TMP(/home/chris/.ansible.cfg) = /tmp/ansible-chris/ansible-local-192699vd3k54e5
EDITOR(env: EDITOR) = /usr/bin/hx

OS / Environment

Fedora 40

Steps to Reproduce

- name: Install Cargo binary crates
  # results in changed true if latest version is present
  community.general.cargo:
    name: cargo-audit
    state: latest
    locked: true
  register: cargo_audit_result
  environment:
    PATH: "/home/{{ ansible_user_id }}/.cargo/bin/:{{ lookup('env', 'PATH') }}"

- name: Print return information from the previous task
  ansible.builtin.debug:
    var: cargo_audit_result

- name: Install Cargo binary crates
  # results in changed false if latest version is present
  community.general.cargo:
    name: cargo-nextest
    state: latest
    locked: true
  register: cargo_nextest_result
  environment:
    PATH: "/home/{{ ansible_user_id }}/.cargo/bin/:{{ lookup('env', 'PATH') }}"

- name: Print return information from the previous task
  ansible.builtin.debug:
    var: cargo_nextest_result

Expected Results

I expected both packages to report no changes when they're already available in the latest version.

Actual Results

TASK [Install Cargo binary crates]
changed: [localhost]

TASK [Print return information from the previous task]
ok: [localhost] => {
    "cargo_audit_result": {
        "changed": true,
        "failed": false,
        "stderr": "    Updating crates.io index\n     Ignored package `cargo-audit v0.20.1` is already installed, use --force to override\n",
        "stderr_lines": [
            "    Updating crates.io index",
            "     Ignored package `cargo-audit v0.20.1` is already installed, use --force to override"
        ],
        "stdout": "",
        "stdout_lines": []
    }
}

TASK [Install Cargo binary crates]
ok: [localhost]

TASK [Print return information from the previous task]
ok: [localhost] => {
    "cargo_nextest_result": {
        "changed": false,
        "failed": false,
        "stderr": null,
        "stderr_lines": [],
        "stdout": null,
        "stdout_lines": []
    }
}

PLAY RECAP
localhost                  : ok=5    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 

Code of Conduct

ansibullbot commented 3 hours ago

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 commented 3 hours ago

cc @radek-sprta click here for bot help