Skip to content

Commit

Permalink
OpenBSD Syspatch: Apply patches by default. Minor module cleanup (#360)
Browse files Browse the repository at this point in the history
* Apply patches by default. Other minor cleanup

* syspatch: Adding changelog and deprecating redundant apply argument

* Update changelogs/fragments/360_syspatch_apply_patches_by_default.yml

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

* Apply suggestions from code review

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

Co-authored-by: Felix Fontein <felix@fontein.de>
  • Loading branch information
precurse and felixfontein authored Oct 28, 2020
1 parent 4c379bd commit b771383
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bugfixes:
- syspatch - fix bug where not setting ``apply=true`` would result in error (https://github.com/ansible-collections/community.general/pull/360).
deprecated_features:
- syspatch - deprecate the redundant ``apply`` argument (https://github.com/ansible-collections/community.general/pull/360).
28 changes: 14 additions & 14 deletions plugins/modules/system/syspatch.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
#!/usr/bin/python

# Copyright: (c) 2019, Andrew Klaus <andrewklaus@gmail.com>
# Copyright: (c) 2019-2020, Andrew Klaus <andrewklaus@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: syspatch
short_description: Manage OpenBSD system patches
description:
- "Manage OpenBSD system patches using syspatch"
- "Manage OpenBSD system patches using syspatch."
options:
apply:
description:
- Apply all available system patches
default: False
required: false
- Apply all available system patches.
- By default, apply all patches.
- Deprecated. Will be removed in community.general 3.0.0.
default: yes
revert:
description:
- Revert system patches
required: false
- Revert system patches.
type: str
choices: [ all, one ]
Expand Down Expand Up @@ -63,17 +63,17 @@
returned: always
type: int
stdout:
description: syspatch standard output
description: syspatch standard output.
returned: always
type: str
sample: "001_rip6cksum"
stderr:
description: syspatch standard error
description: syspatch standard error.
returned: always
type: str
sample: "syspatch: need root privileges"
reboot_needed:
description: Whether or not a reboot is required after an update
description: Whether or not a reboot is required after an update.
returned: always
type: bool
sample: True
Expand All @@ -85,7 +85,7 @@
def run_module():
# define available arguments/parameters a user can pass to the module
module_args = dict(
apply=dict(type='bool'),
apply=dict(type='bool', default=True, removed_in_version='3.0.0', removed_from_collection='community.general'),
revert=dict(type='str', choices=['all', 'one'])
)

Expand Down Expand Up @@ -142,10 +142,10 @@ def syspatch_run(module):
# http://openbsd-archive.7691.n7.nabble.com/Warning-applying-latest-syspatch-td354250.html
if rc != 0 and err != 'ln: /usr/X11R6/bin/X: No such file or directory\n':
module.fail_json(msg="Command %s failed rc=%d, out=%s, err=%s" % (cmd, rc, out, err))
elif out.lower().find('create unique kernel') > 0:
elif out.lower().find('create unique kernel') >= 0:
# Kernel update applied
reboot_needed = True
elif out.lower().find('syspatch updated itself') > 0:
elif out.lower().find('syspatch updated itself') >= 0:
warnings.append('Syspatch was updated. Please run syspatch again.')

# If no stdout, then warn user
Expand Down

0 comments on commit b771383

Please sign in to comment.