kenc 2 weeks ago committed by GitHub
commit a5c1e2328b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,3 @@
---
bugfixes:
- apt - add parameter for install_suggests (https://github.com/ansible/ansible/issues/81173).

@ -68,10 +68,22 @@ options:
type: str
install_recommends:
description:
- Corresponds to the C(--no-install-recommends) option for I(apt). V(true) installs recommended packages. V(false) does not install
recommended packages. By default, Ansible will use the same defaults as the operating system. Suggested packages are never installed.
- Corresponds to the C(--no-install-recommends) option for I(apt).
- V(true) installs recommended packages.
- V(false) does not install recommended packages.
- By default, Ansible will use the same defaults as the operating system.
- Suggested packages are never installed unless O(install_suggests=true).
aliases: [ install-recommends ]
type: bool
install_suggests:
description:
- Corresponds to the C(--install-suggests) option for I(apt).
- V(true) installs suggested packages.
- V(false) does not install suggested packages.
- By default, Ansible will use the same defaults as the operating system.
aliases: [ install-suggests ]
type: bool
version_added: "2.18"
force:
description:
- 'Corresponds to the C(--force-yes) to I(apt-get) and implies O(allow_unauthenticated=yes) and O(allow_downgrade=yes)'
@ -708,7 +720,7 @@ def mark_installed_manually(m, packages):
def install(m, pkgspec, cache, upgrade=False, default_release=None,
install_recommends=None, force=False,
install_recommends=None, install_suggests=None, force=False,
dpkg_options=expand_dpkg_options(DPKG_OPTIONS),
build_dep=False, fixed=False, autoremove=False, fail_on_autoremove=False, only_upgrade=False,
allow_unauthenticated=False, allow_downgrade=False, allow_change_held_packages=False):
@ -799,6 +811,12 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
cmd += " -o APT::Install-Recommends=yes"
# install_recommends is None uses the OS default
if install_suggests is False:
cmd += " -o APT::Install-Suggests=no"
elif install_suggests is True:
cmd += " -o APT::Install-Suggests=yes"
# install_suggests is None uses the OS default
if allow_unauthenticated:
cmd += " --allow-unauthenticated"
@ -846,6 +864,7 @@ def get_field_of_deb(m, deb_file, field="Version"):
def install_deb(
m, debs, cache, force, fail_on_autoremove, install_recommends,
install_suggests,
allow_unauthenticated,
allow_downgrade,
allow_change_held_packages,
@ -900,6 +919,7 @@ def install_deb(
if deps_to_install:
(success, retvals) = install(m=m, pkgspec=deps_to_install, cache=cache,
install_recommends=install_recommends,
install_suggests=install_suggests,
fail_on_autoremove=fail_on_autoremove,
allow_unauthenticated=allow_unauthenticated,
allow_downgrade=allow_downgrade,
@ -1219,6 +1239,7 @@ def main():
deb=dict(type='path'),
default_release=dict(type='str', aliases=['default-release']),
install_recommends=dict(type='bool', aliases=['install-recommends']),
install_suggests=dict(type='bool', aliases=['install-suggests']),
force=dict(type='bool', default=False),
upgrade=dict(type='str', choices=['dist', 'full', 'no', 'safe', 'yes'], default='no'),
dpkg_options=dict(type='str', default=DPKG_OPTIONS),
@ -1350,6 +1371,7 @@ def main():
updated_cache = False
updated_cache_time = 0
install_suggests = p['install_suggests']
allow_unauthenticated = p['allow_unauthenticated']
allow_downgrade = p['allow_downgrade']
allow_change_held_packages = p['allow_change_held_packages']
@ -1443,6 +1465,7 @@ def main():
p['deb'] = fetch_file(module, p['deb'])
install_deb(module, p['deb'], cache,
install_recommends=install_recommends,
install_suggests=install_suggests,
allow_unauthenticated=allow_unauthenticated,
allow_change_held_packages=allow_change_held_packages,
allow_downgrade=allow_downgrade,
@ -1498,6 +1521,7 @@ def main():
upgrade=state_upgrade,
default_release=p['default_release'],
install_recommends=install_recommends,
install_suggests=install_suggests,
force=force_yes,
dpkg_options=dpkg_options,
build_dep=state_builddep,

@ -64,7 +64,7 @@
failed_when: False
register: rolldice_dpkg_result
- name: verify real installation of bar
- name: verify real installation of baz
assert:
that:
- apt_url_deps is changed
@ -73,6 +73,31 @@
- rolldice_dpkg_result is successful
- rolldice_dpkg_result.rc == 0
- name: Install package from local repo for install_suggests
apt:
deb: "{{ repodir }}/dists/stable/main/binary-all/taz_1.0.0_all.deb"
install_suggests: yes
register: install_suggests_test
- name: check to make sure we installed the package
shell: dpkg -l | grep taz
failed_when: False
register: taz_dpkg_result
- name: check to make sure we installed the package's recommends
shell: dpkg -l | grep ed
failed_when: False
register: ed_dpkg_result
- name: verify real installation of taz
assert:
that:
- install_suggests_test is changed
- taz_dpkg_result is successful
- taz_dpkg_result.rc == 0
- ed_dpkg_result is successful
- ed_dpkg_result.rc == 0
always:
- name: uninstall packages with apt
apt:
@ -80,5 +105,7 @@
- echo-hello
- rolldice
- baz
- taz
- ed
state: absent
purge: yes

@ -0,0 +1,9 @@
Priority: optional
Standards-Version: 2.3.3
Package: taz
Version: 1.0.0
Section: system
Maintainer: John Doe <john@doe.com>
Architecture: all
Description: Dummy package
suggests: ed
Loading…
Cancel
Save