How to upgrade a single package with ansible?
Is there any specific reason why would you not consider the ansible package module e.g.
- name: Install linux-generic
package:
name: linux-generic
state: present
As far as the ansible error is concerned, you must enclose your command in double quotes since you are using single quotes inside:
- name: upgrade linux-generic
when: pkg_chk.rc == 0
command: "apt-get install -y --only-upgrade -o Dpkg::Options::='force-confdef' -o Dpkg::Options::='force-confold' linux-generic"
register: install_chk
- name: autoremove linux-generic
when: install_chk.rc == 0
command: "apt-get -y autoremove -o Dpkg::Options::='force-confdef' -o Dpkg::Options::='force-confold'"
register: auto_chk