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/
This commit is contained in:
A Codeweavers Infrastructure Bod 2019-06-20 17:10:28 +01:00 committed by Sandra McCann
parent bdb089b910
commit 2f70c90efd

View file

@ -137,8 +137,9 @@ requirements:
author: "Matthew Williams (@mgwilliams)" author: "Matthew Williams (@mgwilliams)"
notes: 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. - 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, - In most cases, packages installed with apt will start newly installed services by default. Most distributions have mechanisms to avoid this.
to avoid this you can set the ``RUNLEVEL`` environment variable to 1. 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 - 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. (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) 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 = ''' EXAMPLES = '''
- name: Install apache httpd (state=present is optional)
apt:
name: apache2
state: present
- name: Update repositories cache and install "foo" package - name: Update repositories cache and install "foo" package
apt: apt:
name: foo name: foo
update_cache: yes 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 - name: Remove "foo" package
apt: apt:
name: foo name: foo