The following ansible block:
name: Block update APT hosts
block:
name: main - Update APT repo and cache
ansible.builtin.apt:
update_cache: true
force_apt_get: true
cache_valid_time: 3600 # 1 Hour
name: main - Update APT hosts
ansible.builtin.apt:
upgrade: dist
force_apt_get: true
register: apt_return
name: main - Display APT log
ansible.builtin.debug:
var: apt_return.stdout_lines
when: apt_return.stdout_lines is defined
name: main - Check if reboot is needed
ansible.builtin.stat:
path: /var/run/reboot-required
get_md5: false
register: reboot_required_file
name: main - Reboot APT host
ansible.builtin.reboot:
msg: “Reboot initiated by Ansible due to kernel updates”
connect_timeout: 5
reboot_timeout: 300
pre_reboot_delay: 0
post_reboot_delay: 30
test_command: uptime
when: reboot_required_file.stat.exists
when: ansible_pkg_mgr == “apt”
become: true
Yields:
TASK [update_software : main - update APT hosts] *******************************
fatal: [testRadicale.jlhimpel.net ]: FAILED! => {“changed”: false, “msg”: “parameters are mutually exclusive: deb|package|upgrade”}
Ansible version: 2.2.12
Python version: 3.10.3
Ansible Controller: Fedora 36 (same issue occurs on Fedora 35)
Ansible target: Ubuntu 18.04.5 (Bionic Beaver)
Ansible target: python 3…6.9
racke
(Stefan Hornburg)
March 21, 2022, 6:44am
2
The following ansible block:
- name: Block update APT hosts
block:
- name: main - Update APT repo and cache
ansible.builtin.apt:
update_cache: true
force_apt_get: true
cache_valid_time: 3600 # 1 Hour
\- name: main \- Update APT hosts
ansible\.builtin\.apt:
upgrade: dist
force\_apt\_get: true
register: apt\_return
\- name: main \- Display APT log
ansible\.builtin\.debug:
var: apt\_return\.stdout\_lines
when: apt\_return\.stdout\_lines is defined
\- name: main \- Check if reboot is needed
ansible\.builtin\.stat:
path: /var/run/reboot\-required
get\_md5: false
register: reboot\_required\_file
\- name: main \- Reboot APT host
ansible\.builtin\.reboot:
msg: "Reboot initiated by Ansible due to kernel updates"
connect\_timeout: 5
reboot\_timeout: 300
pre\_reboot\_delay: 0
post\_reboot\_delay: 30
test\_command: uptime
when: reboot\_required\_file\.stat\.exists
when: ansible_pkg_mgr == "apt"
become: true
Yields:
TASK [update_software : main - update APT hosts] *******************************
fatal: [testRadicale.jlhimpel.net]: FAILED! => {"changed": false, "msg": "parameters are mutually exclusive: deb|package|upgrade"}
Ansible version: 2.2.12
Python version: 3.10.3
Ansible Controller: Fedora 36 (same issue occurs on Fedora 35)
Ansible target: Ubuntu 18.04.5 (Bionic Beaver)
Ansible target: python 3..6.9
Try with a recent version of Ansible.
Regards
Racke
I found the issue.
I inadvertently pointed my IDE to a version of the source not located on the ansible controller node. Thus a mismatch between what I was viewing/editing and what was editing.
Operator error.
Sorry for the noise.