mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
PEP8 fixes: Ansible system module and playbook base.py (#32322)
* Ansible files module sanity pep8 fixes * Ansible system module and playbook base.py * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Various changes * Various changes * Various changes * Various changes * Undo blank lines not required by sanity checks * Various changes * Various changes * Various changes * Various changes * Various changes * Undo blank line changes not required by sanity checks * Various changes * Various changes * Various changes * Various changes * Various changes * Missing piece after merge * Blank lines * Blank line * Line too long * Fix typo * Unnecessary quotes * Fix example error
This commit is contained in:
committed by
Dag Wieers
parent
a5da2e44a1
commit
a2d34e914e
@@ -1,17 +1,15 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# (c) 2014, Dan Keder <dan.keder@gmail.com>
|
||||
# Copyright: (c) 2014, Dan Keder <dan.keder@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
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: seport
|
||||
@@ -22,55 +20,55 @@ version_added: "2.0"
|
||||
options:
|
||||
ports:
|
||||
description:
|
||||
- Ports or port ranges, separated by a comma
|
||||
- Ports or port ranges, separated by a comma.
|
||||
required: true
|
||||
default: null
|
||||
proto:
|
||||
description:
|
||||
- Protocol for the specified port.
|
||||
required: true
|
||||
default: null
|
||||
choices: [ 'tcp', 'udp' ]
|
||||
choices: [ tcp, udp ]
|
||||
setype:
|
||||
description:
|
||||
- SELinux type for the specified port.
|
||||
required: true
|
||||
default: null
|
||||
state:
|
||||
description:
|
||||
- Desired boolean value.
|
||||
required: true
|
||||
choices: [ absent, present ]
|
||||
default: present
|
||||
choices: [ 'present', 'absent' ]
|
||||
reload:
|
||||
description:
|
||||
- Reload SELinux policy after commit.
|
||||
required: false
|
||||
default: yes
|
||||
type: bool
|
||||
default: 'yes'
|
||||
notes:
|
||||
- The changes are persistent across reboots
|
||||
- Not tested on any debian based system
|
||||
requirements: [ 'libselinux-python', 'policycoreutils-python' ]
|
||||
author: Dan Keder
|
||||
- The changes are persistent across reboots.
|
||||
- Not tested on any debian based system.
|
||||
requirements:
|
||||
- libselinux-python
|
||||
- policycoreutils-python
|
||||
author:
|
||||
- Dan Keder
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Allow Apache to listen on tcp port 8888
|
||||
- seport:
|
||||
- name: Allow Apache to listen on tcp port 8888
|
||||
seport:
|
||||
ports: 8888
|
||||
proto: tcp
|
||||
setype: http_port_t
|
||||
state: present
|
||||
|
||||
# Allow sshd to listen on tcp port 8991
|
||||
- seport:
|
||||
- name: Allow sshd to listen on tcp port 8991
|
||||
seport:
|
||||
ports: 8991
|
||||
proto: tcp
|
||||
setype: ssh_port_t
|
||||
state: present
|
||||
|
||||
# Allow memcached to listen on tcp ports 10000-10100 and 10112
|
||||
- seport:
|
||||
- name: Allow memcached to listen on tcp ports 10000-10100 and 10112
|
||||
seport:
|
||||
ports: 10000-10100,10112
|
||||
proto: tcp
|
||||
setype: memcache_port_t
|
||||
@@ -81,15 +79,15 @@ import traceback
|
||||
|
||||
try:
|
||||
import selinux
|
||||
HAVE_SELINUX=True
|
||||
HAVE_SELINUX = True
|
||||
except ImportError:
|
||||
HAVE_SELINUX=False
|
||||
HAVE_SELINUX = False
|
||||
|
||||
try:
|
||||
import seobject
|
||||
HAVE_SEOBJECT=True
|
||||
HAVE_SEOBJECT = True
|
||||
except ImportError:
|
||||
HAVE_SEOBJECT=False
|
||||
HAVE_SEOBJECT = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, HAVE_SELINUX
|
||||
from ansible.module_utils._text import to_native
|
||||
@@ -232,29 +230,16 @@ def semanage_port_del(module, ports, proto, setype, do_reload, sestore=''):
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec={
|
||||
'ports': {
|
||||
'required': True,
|
||||
},
|
||||
'proto': {
|
||||
'required': True,
|
||||
'choices': ['tcp', 'udp'],
|
||||
},
|
||||
'setype': {
|
||||
'required': True,
|
||||
},
|
||||
'state': {
|
||||
'required': True,
|
||||
'choices': ['present', 'absent'],
|
||||
},
|
||||
'reload': {
|
||||
'required': False,
|
||||
'type': 'bool',
|
||||
'default': 'yes',
|
||||
},
|
||||
},
|
||||
supports_check_mode=True
|
||||
argument_spec=dict(
|
||||
ports=dict(type='str', required=True),
|
||||
proto=dict(type='str', required=True, choices=['tcp', 'udp']),
|
||||
setype=dict(type='str', required=True),
|
||||
state=dict(type='str', required=True, choices=['absent', 'present']),
|
||||
reload=dict(type='bool', default=True),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
if not HAVE_SELINUX:
|
||||
module.fail_json(msg="This module requires libselinux-python")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user