mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-27 04:41:26 -07:00
pkg5: PEP8 compliancy and documentation changes (#33559)
This PR includes: - PEP8 compliancy changes - Documentation changes
This commit is contained in:
parent
aaf22965db
commit
af59817850
2 changed files with 25 additions and 55 deletions
|
@ -1,23 +1,21 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- 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)
|
# 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
|
from __future__ import absolute_import, division, print_function
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
'status': ['preview'],
|
'status': ['preview'],
|
||||||
'supported_by': 'community'}
|
'supported_by': 'community'}
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
module: pkg5
|
module: pkg5
|
||||||
author: "Peter Oliver (@mavit)"
|
author:
|
||||||
|
- Peter Oliver (@mavit)
|
||||||
short_description: Manages packages with the Solaris 11 Image Packaging System
|
short_description: Manages packages with the Solaris 11 Image Packaging System
|
||||||
version_added: 1.9
|
version_added: 1.9
|
||||||
description:
|
description:
|
||||||
|
@ -32,57 +30,44 @@ options:
|
||||||
required: true
|
required: true
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Whether to install (I(present), I(latest)), or remove (I(absent)) a
|
- Whether to install (I(present), I(latest)), or remove (I(absent)) a package.
|
||||||
package.
|
choices: [ absent, latest, present ]
|
||||||
required: false
|
|
||||||
default: present
|
default: present
|
||||||
choices: [ present, latest, absent ]
|
|
||||||
accept_licenses:
|
accept_licenses:
|
||||||
description:
|
description:
|
||||||
- Accept any licences.
|
- Accept any licences.
|
||||||
required: false
|
type: bool
|
||||||
default: false
|
default: 'no'
|
||||||
choices: [ true, false ]
|
aliases: [ accept, accept_licences ]
|
||||||
aliases: [ accept_licences, accept ]
|
|
||||||
'''
|
'''
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
# Install Vim:
|
- name: Install Vim
|
||||||
- pkg5:
|
pkg5:
|
||||||
name: editor/vim
|
name: editor/vim
|
||||||
|
|
||||||
# Remove finger daemon:
|
- name: Remove finger daemon
|
||||||
- pkg5:
|
pkg5:
|
||||||
name: service/network/finger
|
name: service/network/finger
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
# Install several packages at once:
|
- name: Install several packages at once
|
||||||
- pkg5:
|
pkg5:
|
||||||
name:
|
name:
|
||||||
- /file/gnu-findutils
|
- /file/gnu-findutils
|
||||||
- /text/gnu-grep
|
- /text/gnu-grep
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
name=dict(required=True, type='list'),
|
name=dict(type='list', required=True),
|
||||||
state=dict(
|
state=dict(type='str', default='present', choices=['absent', 'installed', 'latest', 'present', 'removed', 'uninstalled']),
|
||||||
default='present',
|
accept_licenses=dict(type='bool', default=False, aliases=['accept', 'accept_licences']),
|
||||||
choices=[
|
|
||||||
'present',
|
|
||||||
'installed',
|
|
||||||
'latest',
|
|
||||||
'absent',
|
|
||||||
'uninstalled',
|
|
||||||
'removed',
|
|
||||||
]
|
|
||||||
),
|
|
||||||
accept_licenses=dict(
|
|
||||||
type='bool',
|
|
||||||
default=False,
|
|
||||||
aliases=['accept_licences', 'accept'],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
@ -94,10 +79,7 @@ def main():
|
||||||
# AnsibleModule will have split this into multiple items for us.
|
# AnsibleModule will have split this into multiple items for us.
|
||||||
# Try to spot where this has happened and fix it.
|
# Try to spot where this has happened and fix it.
|
||||||
for fragment in params['name']:
|
for fragment in params['name']:
|
||||||
if (
|
if re.search(r'^\d+(?:\.\d+)*', fragment) and packages and re.search(r'@[^,]*$', packages[-1]):
|
||||||
re.search(r'^\d+(?:\.\d+)*', fragment)
|
|
||||||
and packages and re.search(r'@[^,]*$', packages[-1])
|
|
||||||
):
|
|
||||||
packages[-1] += ',' + fragment
|
packages[-1] += ',' + fragment
|
||||||
else:
|
else:
|
||||||
packages.append(fragment)
|
packages.append(fragment)
|
||||||
|
@ -144,16 +126,7 @@ def ensure(module, state, packages, params):
|
||||||
|
|
||||||
to_modify = filter(behaviour[state]['filter'], packages)
|
to_modify = filter(behaviour[state]['filter'], packages)
|
||||||
if to_modify:
|
if to_modify:
|
||||||
rc, out, err = module.run_command(
|
rc, out, err = module.run_command(['pkg', behaviour[state]['subcommand']] + dry_run + accept_licenses + ['-q', '--'] + to_modify)
|
||||||
[
|
|
||||||
'pkg', behaviour[state]['subcommand']
|
|
||||||
]
|
|
||||||
+ dry_run
|
|
||||||
+ accept_licenses
|
|
||||||
+ [
|
|
||||||
'-q', '--'
|
|
||||||
] + to_modify
|
|
||||||
)
|
|
||||||
response['rc'] = rc
|
response['rc'] = rc
|
||||||
response['results'].append(out)
|
response['results'].append(out)
|
||||||
response['msg'] += err
|
response['msg'] += err
|
||||||
|
@ -174,7 +147,5 @@ def is_latest(module, package):
|
||||||
return bool(int(rc))
|
return bool(int(rc))
|
||||||
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
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/layman.py
|
||||||
lib/ansible/modules/packaging/os/macports.py
|
lib/ansible/modules/packaging/os/macports.py
|
||||||
lib/ansible/modules/packaging/os/opkg.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/pkgin.py
|
||||||
lib/ansible/modules/packaging/os/pkgng.py
|
lib/ansible/modules/packaging/os/pkgng.py
|
||||||
lib/ansible/modules/packaging/os/pkgutil.py
|
lib/ansible/modules/packaging/os/pkgutil.py
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue