mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-12 19:34:02 -07: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:
parent
a5da2e44a1
commit
a2d34e914e
31 changed files with 878 additions and 1004 deletions
|
@ -4,14 +4,13 @@
|
|||
# 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
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
module: openwrt_init
|
||||
author:
|
||||
|
@ -85,6 +84,7 @@ from ansible.module_utils._text import to_bytes, to_native
|
|||
module = None
|
||||
init_script = None
|
||||
|
||||
|
||||
# ===============================
|
||||
# Check if service is enabled
|
||||
def is_enabled():
|
||||
|
@ -93,6 +93,7 @@ def is_enabled():
|
|||
return True
|
||||
return False
|
||||
|
||||
|
||||
# ===========================================
|
||||
# Main control flow
|
||||
|
||||
|
@ -100,15 +101,15 @@ def main():
|
|||
global module, init_script
|
||||
# init
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
name = dict(required=True, type='str', aliases=['service']),
|
||||
state = dict(choices=['started', 'stopped', 'restarted', 'reloaded'], type='str'),
|
||||
enabled = dict(type='bool'),
|
||||
pattern = dict(required=False, default=None),
|
||||
argument_spec=dict(
|
||||
name=dict(required=True, type='str', aliases=['service']),
|
||||
state=dict(choices=['started', 'stopped', 'restarted', 'reloaded'], type='str'),
|
||||
enabled=dict(type='bool'),
|
||||
pattern=dict(required=False, default=None),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
required_one_of=[['state', 'enabled']],
|
||||
)
|
||||
)
|
||||
|
||||
# initialize
|
||||
service = module.params['name']
|
||||
|
@ -116,7 +117,7 @@ def main():
|
|||
rc = 0
|
||||
out = err = ''
|
||||
result = {
|
||||
'name': service,
|
||||
'name': service,
|
||||
'changed': False,
|
||||
}
|
||||
|
||||
|
@ -164,7 +165,7 @@ def main():
|
|||
if rc == 0:
|
||||
lines = psout.split("\n")
|
||||
for line in lines:
|
||||
if module.params['pattern'] in line and not "pattern=" in line:
|
||||
if module.params['pattern'] in line and "pattern=" not in line:
|
||||
# so as to not confuse ./hacking/test-module
|
||||
running = True
|
||||
break
|
||||
|
@ -187,7 +188,7 @@ def main():
|
|||
action = 'stop'
|
||||
result['changed'] = True
|
||||
else:
|
||||
action = module.params['state'][:-2] # remove 'ed' from restarted/reloaded
|
||||
action = module.params['state'][:-2] # remove 'ed' from restarted/reloaded
|
||||
result['state'] = 'started'
|
||||
result['changed'] = True
|
||||
|
||||
|
@ -197,8 +198,8 @@ def main():
|
|||
if rc != 0:
|
||||
module.fail_json(msg="Unable to %s service %s: %s" % (action, service, err))
|
||||
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue