at: PEP8 compliancy and doc fixes (#30881)

This PR includes:
- PEP8 compliancy fixes
- Documentation changes
pull/30886/head^2
Dag Wieers 7 years ago committed by GitHub
parent babc2354a5
commit 11f8d9659d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,22 +1,20 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# (c) 2014, Richard Isaacson <richard.c.isaacson@gmail.com> # Copyright: (c) 2014, Richard Isaacson <richard.c.isaacson@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': ['preview'], 'status': ['preview'],
'supported_by': 'core'} 'supported_by': 'core'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: at module: at
short_description: Schedule the execution of a command or script file via the at command. short_description: Schedule the execution of a command or script file via the at command
description: description:
- Use this module to schedule a command or script file to run once in the future. - Use this module to schedule a command or script file to run once in the future.
- All jobs are executed in the 'a' queue. - All jobs are executed in the 'a' queue.
@ -25,13 +23,9 @@ options:
command: command:
description: description:
- A command to be executed in the future. - A command to be executed in the future.
required: false
default: null
script_file: script_file:
description: description:
- An existing script file to be executed in the future. - An existing script file to be executed in the future.
required: false
default: null
count: count:
description: description:
- The count of units in the future to execute the command or script file. - The count of units in the future to execute the command or script file.
@ -39,42 +33,42 @@ options:
units: units:
description: description:
- The type of units in the future to execute the command or script file. - The type of units in the future to execute the command or script file.
choices: [ minutes, hours, days, weeks ]
required: true required: true
choices: ["minutes", "hours", "days", "weeks"]
state: state:
description: description:
- The state dictates if the command or script file should be evaluated as present(added) or absent(deleted). - The state dictates if the command or script file should be evaluated as present(added) or absent(deleted).
required: false choices: [ absent, present ]
choices: ["present", "absent"] default: present
default: "present"
unique: unique:
description: description:
- If a matching job is present a new job will not be added. - If a matching job is present a new job will not be added.
required: false type: bool
default: false default: 'no'
requirements: requirements:
- at - at
author: "Richard Isaacson (@risaacson)" author:
- Richard Isaacson (@risaacson)
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Schedule a command to execute in 20 minutes as root. - name: Schedule a command to execute in 20 minutes as root.
- at: at:
command: "ls -d / > /dev/null" command: ls -d / >/dev/null
count: 20 count: 20
units: minutes units: minutes
# Match a command to an existing job and delete the job. - name: Match a command to an existing job and delete the job.
- at: at:
command: "ls -d / > /dev/null" command: ls -d / >/dev/null
state: absent state: absent
# Schedule a command to execute in 20 minutes making sure it is unique in the queue. - name: Schedule a command to execute in 20 minutes making sure it is unique in the queue.
- at: at:
command: "ls -d / > /dev/null" command: ls -d / >/dev/null
unique: true
count: 20 count: 20
units: minutes units: minutes
unique: yes
''' '''
import os import os
@ -140,43 +134,35 @@ def create_tempfile(command):
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec = dict( argument_spec=dict(
command=dict(required=False, command=dict(type='str'),
type='str'), script_file=dict(type='str'),
script_file=dict(required=False, count=dict(type='int'),
type='str'), units=dict(type='str', choices=['minutes', 'hours', 'days', 'weeks']),
count=dict(required=False, state=dict(type='str', default='present', choices=['present', 'absent']),
type='int'), unique=dict(type='bool', default=False),
units=dict(required=False,
default=None,
choices=['minutes', 'hours', 'days', 'weeks'],
type='str'),
state=dict(required=False,
default='present',
choices=['present', 'absent'],
type='str'),
unique=dict(required=False,
default=False,
type='bool')
), ),
mutually_exclusive=[['command', 'script_file']], mutually_exclusive=[['command', 'script_file']],
required_one_of=[['command', 'script_file']], required_one_of=[['command', 'script_file']],
supports_check_mode=False supports_check_mode=False,
) )
at_cmd = module.get_bin_path('at', True) at_cmd = module.get_bin_path('at', True)
command = module.params['command'] command = module.params['command']
script_file = module.params['script_file'] script_file = module.params['script_file']
count = module.params['count'] count = module.params['count']
units = module.params['units'] units = module.params['units']
state = module.params['state'] state = module.params['state']
unique = module.params['unique'] unique = module.params['unique']
if (state == 'present') and (not count or not units): if (state == 'present') and (not count or not units):
module.fail_json(msg="present state requires count and units") module.fail_json(msg="present state requires count and units")
result = {'state': state, 'changed': False} result = dict(
changed=False,
state=state,
)
# If command transform it into a script_file # If command transform it into a script_file
if command: if command:

@ -335,7 +335,6 @@ lib/ansible/modules/storage/netapp/sf_volume_access_group_manager.py
lib/ansible/modules/storage/netapp/sf_volume_manager.py lib/ansible/modules/storage/netapp/sf_volume_manager.py
lib/ansible/modules/storage/zfs/zfs.py lib/ansible/modules/storage/zfs/zfs.py
lib/ansible/modules/system/aix_inittab.py lib/ansible/modules/system/aix_inittab.py
lib/ansible/modules/system/at.py
lib/ansible/modules/system/capabilities.py lib/ansible/modules/system/capabilities.py
lib/ansible/modules/system/cronvar.py lib/ansible/modules/system/cronvar.py
lib/ansible/modules/system/crypttab.py lib/ansible/modules/system/crypttab.py

Loading…
Cancel
Save