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

rpm_ostree_pkg will install a full system update when one is available #9229

Open
1 task done
gadgethm opened this issue Dec 8, 2024 · 2 comments
Open
1 task done
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type)

Comments

@gadgethm
Copy link

gadgethm commented Dec 8, 2024

Summary

I'm trying to run an ansible role which does three things:

  • Install a list of packages
  • Update the system
  • Handle rebooting to switch to the new deployment

However, in a typical deployment, I have been finding that the first step of installing a list of packages will always do the full system update when one is available. The second step, updating the system, then completes as 'ok'.

I've traced this down to the difference in behavior between these two commands:

$ sudo rpm-ostree install python3-requests
error: Package/capability 'python3-requests' is already requested
$ sudo rpm-ostree install python3-requests --idempotent
Checking out tree 870e2c8... done
<system update continues>

Ideally, I would expect the rpm_ostree_pkg module to simply check if the package is already requested, and if so do nothing. However, because of the --idempotent flag included on line 166, I always end up with a system upgrade happening when I only want to check for (and potentially install) a single package.

Perhaps a simple way to address this would be to add an idempotent parameter to the module, which defaults to true and controls the addition or removal of this flag? Not sure what would make the most sense in this case; happy to make a pull request with that change.

Issue Type

Bug Report

Component Name

rpm_ostree_pkg, https://github.com/ansible-collections/community.general/blob/e5761bd7c745c3b03d083d1d685badc0ea4ba577/plugins/modules/rpm_ostree_pkg.py

Ansible Version

$ ansible --version

ansible [core 2.18.1]
  config file = /var/home/gadgethm/ansible/ansible.cfg
  configured module search path = ['/var/home/gadgethm/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /var/home/gadgethm/.local/lib/python3.12/site-packages/ansible
  ansible collection location = /var/home/gadgethm/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.12.7 (main, Oct  1 2024, 00:00:00) [GCC 14.2.1 20240912 (Red Hat 14.2.1-3)] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

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

# /var/home/gadgethm/.local/lib/python3.12/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 10.1.0 

Configuration

$ ansible-config dump --only-changed
NSIBLE_NOCOWS(/var/home/gadgethm/ansible/ansible.cfg) = True
CONFIG_FILE() = /var/home/gadgethm/ansible/ansible.cfg
DEFAULT_HOST_LIST(/var/home/gadgethm/ansible/ansible.cfg) = ['/var/home/gadgethm/ansible/inventory']
DEFAULT_ROLES_PATH(/var/home/gadgethm/ansible/ansible.cfg) = ['/var/home/gadgethm/ansible/galaxy_roles', '/var/home/gadgethm/ansible/roles']
DEFAULT_VAULT_PASSWORD_FILE(/var/home/gadgethm/ansible/ansible.cfg) = /var/home/gadgethm/ansible/.vault-secret
EDITOR(env: EDITOR) = /usr/bin/nano
INTERPRETER_PYTHON(/var/home/gadgethm/ansible/ansible.cfg) = auto_silent
PLAYBOOK_DIR(/var/home/gadgethm/ansible/ansible.cfg) = /var/home/gadgethm/ansible/playbooks

OS / Environment

Fedora Silverblue as deployment machine, running Ansible inside a podman container. Fedora CoreOS as the target machine.

Steps to Reproduce

---
- name: Ensure required packages are installed
  become: true
  community.general.rpm_ostree_pkg:
    name: "python3-requests"
    state: present
  notify: Reboot system

- name: Perform system update
  become: true
  tags: update-system
  block:
    - name: Stop automatic update service
      ansible.builtin.service:
        name: zincati
        state: stopped
      notify: Start coreos automatic update service
  
    - name: Upgrade all packages
      ansible.posix.rpm_ostree_upgrade:
      notify: Reboot system

Expected Results

Expect the first task to pass unchanged (status 'ok') since python3-requests is already installed. Expected the third task to upgrade the whole system and then reboot.

Actual behavior was the first task passed with status 'changed', and the third task passed unchanged (status 'ok'). First task fully upgraded the system and triggered the reboot handler.

Actual Results:


PLAY [Configure the following targets: atlas] *******************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************************************
ok: [atlas]

TASK [system : Tasks for Fedora systems] ************************************************************************************************************************************************
included: /var/home/gadgethm/ansible/roles/system/tasks/fedora/main.yaml for atlas

TASK [system : Tasks for rpm-ostree package manager] ************************************************************************************************************************************
included: /var/home/gadgethm/ansible/roles/system/tasks/fedora/rpm-ostree.yaml for atlas

TASK [system : Ensure required packages are installed] **********************************************************************************************************************************
changed: [atlas]

TASK [system : Stop automatic update service] *******************************************************************************************************************************************
changed: [atlas]

TASK [system : Upgrade all packages] ****************************************************************************************************************************************************
ok: [atlas]

TASK [system : Tasks for dnf package manager] *******************************************************************************************************************************************
skipping: [atlas]

TASK [system : Tasks for Debian systems] ************************************************************************************************************************************************
skipping: [atlas]

RUNNING HANDLER [system : Start coreos automatic update service] ************************************************************************************************************************
changed: [atlas]

RUNNING HANDLER [system : Reboot system] ************************************************************************************************************************************************
changed: [atlas]

PLAY RECAP ******************************************************************************************************************************************************************************
atlas                      : ok=8    changed=4    unreachable=0    failed=0    skipped=2    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 Dec 8, 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