pkg5: PEP8 compliancy and documentation changes (#33559)

This PR includes:
- PEP8 compliancy changes
- Documentation changes
pull/33582/head
Dag Wieers 7 years ago committed by ansibot
parent aaf22965db
commit af59817850

@ -1,23 +1,21 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2014 Peter Oliver <ansible@mavit.org.uk>
#
# Copyright: (c) 2014, Peter Oliver <ansible@mavit.org.uk>
# 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
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: pkg5
author: "Peter Oliver (@mavit)"
author:
- Peter Oliver (@mavit)
short_description: Manages packages with the Solaris 11 Image Packaging System
version_added: 1.9
description:
@ -32,57 +30,44 @@ options:
required: true
state:
description:
- Whether to install (I(present), I(latest)), or remove (I(absent)) a
package.
required: false
- Whether to install (I(present), I(latest)), or remove (I(absent)) a package.
choices: [ absent, latest, present ]
default: present
choices: [ present, latest, absent ]
accept_licenses:
description:
- Accept any licences.
required: false
default: false
choices: [ true, false ]
aliases: [ accept_licences, accept ]
type: bool
default: 'no'
aliases: [ accept, accept_licences ]
'''
EXAMPLES = '''
# Install Vim:
- pkg5:
- name: Install Vim
pkg5:
name: editor/vim
# Remove finger daemon:
- pkg5:
- name: Remove finger daemon
pkg5:
name: service/network/finger
state: absent
# Install several packages at once:
- pkg5:
- name: Install several packages at once
pkg5:
name:
- /file/gnu-findutils
- /text/gnu-grep
- /file/gnu-findutils
- /text/gnu-grep
'''
import re
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
name=dict(required=True, type='list'),
state=dict(
default='present',
choices=[
'present',
'installed',
'latest',
'absent',
'uninstalled',
'removed',
]
),
accept_licenses=dict(
type='bool',
default=False,
aliases=['accept_licences', 'accept'],
),
name=dict(type='list', required=True),
state=dict(type='str', default='present', choices=['absent', 'installed', 'latest', 'present', 'removed', 'uninstalled']),
accept_licenses=dict(type='bool', default=False, aliases=['accept', 'accept_licences']),
),
supports_check_mode=True,
)
@ -94,10 +79,7 @@ def main():
# AnsibleModule will have split this into multiple items for us.
# Try to spot where this has happened and fix it.
for fragment in params['name']:
if (
re.search(r'^\d+(?:\.\d+)*', fragment)
and packages and re.search(r'@[^,]*$', packages[-1])
):
if re.search(r'^\d+(?:\.\d+)*', fragment) and packages and re.search(r'@[^,]*$', packages[-1]):
packages[-1] += ',' + fragment
else:
packages.append(fragment)
@ -144,16 +126,7 @@ def ensure(module, state, packages, params):
to_modify = filter(behaviour[state]['filter'], packages)
if to_modify:
rc, out, err = module.run_command(
[
'pkg', behaviour[state]['subcommand']
]
+ dry_run
+ accept_licenses
+ [
'-q', '--'
] + to_modify
)
rc, out, err = module.run_command(['pkg', behaviour[state]['subcommand']] + dry_run + accept_licenses + ['-q', '--'] + to_modify)
response['rc'] = rc
response['results'].append(out)
response['msg'] += err
@ -174,7 +147,5 @@ def is_latest(module, package):
return bool(int(rc))
from ansible.module_utils.basic import *
if __name__ == '__main__':
main()

@ -264,7 +264,6 @@ lib/ansible/modules/packaging/os/homebrew_cask.py
lib/ansible/modules/packaging/os/layman.py
lib/ansible/modules/packaging/os/macports.py
lib/ansible/modules/packaging/os/opkg.py
lib/ansible/modules/packaging/os/pkg5.py
lib/ansible/modules/packaging/os/pkgin.py
lib/ansible/modules/packaging/os/pkgng.py
lib/ansible/modules/packaging/os/pkgutil.py

Loading…
Cancel
Save