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

cargo shows changed status for installed package #8949

Open
1 task done
chdalski opened this issue Sep 30, 2024 · 2 comments
Open
1 task done

cargo shows changed status for installed package #8949

chdalski opened this issue Sep 30, 2024 · 2 comments
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type)

Comments

@chdalski
Copy link

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

  • 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

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) labels Sep 30, 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 plugins plugin (any type)
Projects
None yet
Development

No branches or pull requests

2 participants