1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add OpenBSD pkg_add(1) snapshot support (#965) (#1280)

* Add OpenBSD pkg_add(1) snapshot support

* Fix documentation syntax

Co-authored-by: Felix Fontein <felix@fontein.de>

* Bump version_added

Co-authored-by: Felix Fontein <felix@fontein.de>

* zap one trailing whitespace

The first trailing whitespace is necessary otherwise we cal pkg_add(1)
with '-Im-Dsnap' which is invalid.

* Check build flag in package_present()

* zap one trailing whitespace

The first trailing whitespace is necessary otherwise we cal pkg_add(1)
with '-Im-Dsnap' which is invalid.

* check snapshot/build combination a little earlier

* Update "Force" documentation

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* Bump version tgo 1.3.0

Co-authored-by: Felix Fontein <felix@fontein.de>

* Add a changelog fragment.

* Update plugins/modules/packaging/os/openbsd_pkg.py

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* Add: mutually exclusiv hint for "build" and add mutually_exclusive

* Re-add build=%s check

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
(cherry picked from commit ef49950b96)

Co-authored-by: Rafael Sadowski <rafael@sizeofvoid.org>
This commit is contained in:
patchback[bot] 2020-11-13 06:49:59 +00:00 committed by GitHub
parent 726ea65f4f
commit 011e27caf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,3 @@
---
minor_changes:
- openbsd_pkg - added ``snapshot`` option (https://github.com/ansible-collections/community.general/pull/965).

View file

@ -40,8 +40,16 @@ options:
a binary. Requires that the port source tree is already installed.
Automatically builds and installs the 'sqlports' package, if it is
not already installed.
- Mutually exclusive with I(snapshot).
type: bool
default: no
snapshot:
description:
- Force C(%c) and C(%m) to expand to C(snapshots), even on a release kernel.
- Mutually exclusive with I(build).
type: bool
default: no
version_added: 1.3.0
ports_dir:
description:
- When used in combination with the C(build) option, allows overriding
@ -197,6 +205,9 @@ def package_present(names, pkg_spec, module):
else:
install_cmd = 'pkg_add -Im'
if module.params['snapshot'] is True:
install_cmd += ' -Dsnap'
if pkg_spec[name]['installed_state'] is False:
# Attempt to install the package
@ -269,6 +280,9 @@ def package_latest(names, pkg_spec, module):
if module.params['quick']:
upgrade_cmd += 'q'
if module.params['snapshot']:
upgrade_cmd += ' -Dsnap'
for name in names:
if pkg_spec[name]['installed_state'] is True:
@ -489,6 +503,9 @@ def upgrade_packages(pkg_spec, module):
else:
upgrade_cmd = 'pkg_add -Imu'
if module.params['snapshot']:
upgrade_cmd += ' -Dsnap'
# Create a minimal pkg_spec entry for '*' to store return values.
pkg_spec['*'] = {}
@ -520,10 +537,12 @@ def main():
name=dict(type='list', elements='str', required=True),
state=dict(type='str', default='present', choices=['absent', 'installed', 'latest', 'present', 'removed']),
build=dict(type='bool', default=False),
snapshot=dict(type='bool', default=False),
ports_dir=dict(type='path', default='/usr/ports'),
quick=dict(type='bool', default=False),
clean=dict(type='bool', default=False),
),
mutually_exclusive=[['snapshot', 'build']],
supports_check_mode=True
)