Open
Description
Summary
When new kernel version is not available (when kernel version already latest), apt_rpm module return error
Issue Type
Bug Report
Component Name
apt_rpm
Ansible Version
$ ansible --version
ansible [core 2.16.3]
config file = /home/vodka/.ansible.cfg
configured module search path = ['/home/vodka/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/vodka/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.12.7 (main, Feb 4 2025, 14:46:03) [GCC 14.2.0] (/usr/bin/python3)
jinja version = 3.1.3
libyaml = True
Community.general Version
$ ansible-galaxy collection list community.general
# /home/vodka/.ansible/collections/ansible_collections
Collection Version
----------------- -------
community.general 10.0.1
# /usr/lib/python3/dist-packages/ansible_collections
Collection Version
----------------- -------
community.general 8.3.0
Configuration
$ ansible-config dump --only-changed
CONFIG_FILE() = /home/vodka/.ansible.cfg
DEFAULT_FORKS(/home/vodka/.ansible.cfg) = 4
DEFAULT_TIMEOUT(/home/vodka/.ansible.cfg) = 60
EDITOR(env: EDITOR) = nano
HOST_KEY_CHECKING(/home/vodka/.ansible.cfg) = False
INTERPRETER_PYTHON(/home/vodka/.ansible.cfg) = auto_silent
OS / Environment
Distributor ID: Ubuntu
Description: Ubuntu 24.10
Release: 24.10
Codename: oracular
Steps to Reproduce
---
- name: "Upgrade OS"
hosts: all
become: yes
tasks:
- name: "Update cache, upgrade all packages, update kernel via apt-get"
apt_rpm:
update_cache: yes
dist_upgrade: yes
update_kernel: yes
become: yes
Expected Results
All packages and kernel will be successfully updated
Actual Results
fatal: [s1]: FAILED! => {"changed": false, "cmd": "/usr/sbin/update-kernel -y", "msg": "ATTENTION: Your APT database is 7 days old, please run 'apt-get update'!\nupdate-kernel: There are no available kernels with kernel flavour un-def", "rc": 1, "stderr": "ATTENTION: Your APT database is 7 days old, please run 'apt-get update'!\nupdate-kernel: There are no available kernels with kernel flavour un-def\n", "stderr_lines": ["ATTENTION: Your APT database is 7 days old, please run 'apt-get update'!", "update-kernel: There are no available kernels with kernel flavour un-def"], "stdout": "Running kernel: kernel-image-un-def-6.1.131-alt0.c10f.2\nChecking for available un-def kernel packages...\n", "stdout_lines": ["Running kernel: kernel-image-un-def-6.1.131-alt0.c10f.2", "Checking for available un-def kernel packages..."]}
Some points:
- Return code 1 is OK when new kernel is not available:
[root@s1 ~]# /usr/sbin/update-kernel -y
ATTENTION: Your APT database is 7 days old, please run 'apt-get update'!
Running kernel: kernel-image-un-def-6.1.131-alt0.c10f.2
Checking for available un-def kernel packages...
update-kernel: There are no available kernels with kernel flavour un-def
[root@s1 ~]# echo $?
1
- Message "Try to install new kernel" is not shown when there is no new kernel:
[root@s1 ~]# /usr/sbin/update-kernel -y
ATTENTION: Your APT database is 7 days old, please run 'apt-get update'!
Running kernel: kernel-image-un-def-6.1.131-alt0.c10f.2
Checking for available un-def kernel packages...
update-kernel: There are no available kernels with kernel flavour un-def
Code of Conduct
- I agree to follow the Ansible Code of Conduct