From 2f70c90efd047a4a74affec826b0cd9da6d28a26 Mon Sep 17 00:00:00 2001 From: A Codeweavers Infrastructure Bod <36475663+infraweavers@users.noreply.github.com> Date: Thu, 20 Jun 2019 17:10:28 +0100 Subject: [PATCH] Update apt.py (#56479) * Update apt.py Tested under Debian 9 with installation of Apache2 and PostgreSQL In both cases the daemons are started immediately upon installation https://www.alextomkins.com/2018/03/runlevel-apt-get-install-package-alternative/ https://major.io/2014/06/26/install-debian-packages-without-starting-daemons/ --- lib/ansible/modules/packaging/os/apt.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/ansible/modules/packaging/os/apt.py b/lib/ansible/modules/packaging/os/apt.py index 41c3bc5b678..cc43e1c1427 100644 --- a/lib/ansible/modules/packaging/os/apt.py +++ b/lib/ansible/modules/packaging/os/apt.py @@ -137,8 +137,9 @@ requirements: author: "Matthew Williams (@mgwilliams)" notes: - Three of the upgrade modes (C(full), C(safe) and its alias C(yes)) required C(aptitude) up to 2.3, since 2.4 C(apt-get) is used as a fall-back. - - apt starts newly installed services by default, this is what the underlying tooling does, - to avoid this you can set the ``RUNLEVEL`` environment variable to 1. + - In most cases, packages installed with apt will start newly installed services by default. Most distributions have mechanisms to avoid this. + For example when installing Postgresql-9.5 in Debian 9, creating an excutable shell script (/usr/sbin/policy-rc.d) that throws + a return code of 101 will stop Postgresql 9.5 starting up after install. Remove the file or remove its execute permission afterwards. - The apt-get commandline supports implicit regex matches here but we do not because it can let typos through easier (If you typo C(foo) as C(fo) apt-get would install packages that have "fo" in their name with a warning and a prompt for the user. Since we don't have warnings and prompts before installing we disallow this.Use an explicit fnmatch pattern if you want wildcarding) @@ -146,18 +147,16 @@ notes: ''' EXAMPLES = ''' +- name: Install apache httpd (state=present is optional) + apt: + name: apache2 + state: present + - name: Update repositories cache and install "foo" package apt: name: foo update_cache: yes -- name: Install apache httpd but avoid starting it immediately (state=present is optional) - apt: - name: apache2 - state: present - environment: - RUNLEVEL: 1 - - name: Remove "foo" package apt: name: foo