mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
seboolean: PEP8 compliancy and doc fixes (#30888)
This PR includes: - PEP8 compliancy fixes - Documentation fixes
This commit is contained in:
parent
32775b0caa
commit
edc0ff481c
2 changed files with 29 additions and 27 deletions
|
@ -1,46 +1,44 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
# (c) 2012, Stephen Fromm <sfromm@gmail.com>
|
# Copyright: (c) 2012, Stephen Fromm <sfromm@gmail.com>
|
||||||
# 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': ['stableinterface'],
|
'status': ['stableinterface'],
|
||||||
'supported_by': 'core'}
|
'supported_by': 'core'}
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
module: seboolean
|
module: seboolean
|
||||||
short_description: Toggles SELinux booleans.
|
short_description: Toggles SELinux booleans
|
||||||
description:
|
description:
|
||||||
- Toggles SELinux booleans.
|
- Toggles SELinux booleans.
|
||||||
version_added: "0.7"
|
version_added: "0.7"
|
||||||
options:
|
options:
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- Name of the boolean to configure
|
- Name of the boolean to configure.
|
||||||
required: true
|
required: true
|
||||||
default: null
|
|
||||||
persistent:
|
persistent:
|
||||||
description:
|
description:
|
||||||
- Set to C(yes) if the boolean setting should survive a reboot
|
- Set to C(yes) if the boolean setting should survive a reboot.
|
||||||
required: false
|
type: bool
|
||||||
default: no
|
default: 'no'
|
||||||
choices: [ "yes", "no" ]
|
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Desired boolean value
|
- Desired boolean value
|
||||||
|
type: bool
|
||||||
required: true
|
required: true
|
||||||
default: null
|
|
||||||
choices: [ 'yes', 'no' ]
|
|
||||||
notes:
|
notes:
|
||||||
- Not tested on any debian based system
|
- Not tested on any Debian based system.
|
||||||
requirements: [ libselinux-python, libsemanage-python ]
|
requirements:
|
||||||
author: "Stephen Fromm (@sfromm)"
|
- libselinux-python
|
||||||
|
- libsemanage-python
|
||||||
|
author:
|
||||||
|
- Stephen Fromm (@sfromm)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
|
@ -55,15 +53,15 @@ import os
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import selinux
|
import selinux
|
||||||
HAVE_SELINUX=True
|
HAVE_SELINUX = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAVE_SELINUX=False
|
HAVE_SELINUX = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import semanage
|
import semanage
|
||||||
HAVE_SEMANAGE=True
|
HAVE_SEMANAGE = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAVE_SEMANAGE=False
|
HAVE_SEMANAGE = False
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six import binary_type
|
from ansible.module_utils.six import binary_type
|
||||||
|
@ -86,6 +84,7 @@ def has_boolean_value(module, name):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_boolean_value(module, name):
|
def get_boolean_value(module, name):
|
||||||
state = 0
|
state = 0
|
||||||
try:
|
try:
|
||||||
|
@ -97,6 +96,7 @@ def get_boolean_value(module, name):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
# The following method implements what setsebool.c does to change
|
# The following method implements what setsebool.c does to change
|
||||||
# a boolean and make it persist after reboot..
|
# a boolean and make it persist after reboot..
|
||||||
def semanage_boolean_value(module, name, state):
|
def semanage_boolean_value(module, name, state):
|
||||||
|
@ -152,6 +152,7 @@ def semanage_boolean_value(module, name, state):
|
||||||
module.fail_json(msg="Failed to manage policy for boolean %s: %s" % (name, str(e)))
|
module.fail_json(msg="Failed to manage policy for boolean %s: %s" % (name, str(e)))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def set_boolean_value(module, name, state):
|
def set_boolean_value(module, name, state):
|
||||||
rc = 0
|
rc = 0
|
||||||
value = 0
|
value = 0
|
||||||
|
@ -166,14 +167,15 @@ def set_boolean_value(module, name, state):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec=dict(
|
||||||
name=dict(required=True),
|
name=dict(type='str', required=True),
|
||||||
persistent=dict(default='no', type='bool'),
|
persistent=dict(type='bool', default=False),
|
||||||
state=dict(required=True, type='bool')
|
state=dict(type='bool', required=True)
|
||||||
),
|
),
|
||||||
supports_check_mode=True
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not HAVE_SELINUX:
|
if not HAVE_SELINUX:
|
||||||
|
@ -188,8 +190,9 @@ def main():
|
||||||
name = module.params['name']
|
name = module.params['name']
|
||||||
persistent = module.params['persistent']
|
persistent = module.params['persistent']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
result = {}
|
result = dict(
|
||||||
result['name'] = name
|
name=name,
|
||||||
|
)
|
||||||
|
|
||||||
if hasattr(selinux, 'selinux_boolean_sub'):
|
if hasattr(selinux, 'selinux_boolean_sub'):
|
||||||
# selinux_boolean_sub allows sites to rename a boolean and alias the old name
|
# selinux_boolean_sub allows sites to rename a boolean and alias the old name
|
||||||
|
|
|
@ -357,7 +357,6 @@ lib/ansible/modules/system/osx_defaults.py
|
||||||
lib/ansible/modules/system/pam_limits.py
|
lib/ansible/modules/system/pam_limits.py
|
||||||
lib/ansible/modules/system/puppet.py
|
lib/ansible/modules/system/puppet.py
|
||||||
lib/ansible/modules/system/runit.py
|
lib/ansible/modules/system/runit.py
|
||||||
lib/ansible/modules/system/seboolean.py
|
|
||||||
lib/ansible/modules/system/seport.py
|
lib/ansible/modules/system/seport.py
|
||||||
lib/ansible/modules/system/service.py
|
lib/ansible/modules/system/service.py
|
||||||
lib/ansible/modules/system/solaris_zone.py
|
lib/ansible/modules/system/solaris_zone.py
|
||||||
|
|
Loading…
Reference in a new issue