atomic: PEP8 compliancy and doc fixes (#30918)

This PR includes:
- PEP8 compliancy fixes
- Documentation fixes
pull/31092/head
Dag Wieers 7 years ago committed by René Moser
parent 3ffc62b43b
commit bedfd0a5a4

@ -7,43 +7,40 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: atomic_host
short_description: Manage the atomic host platform
description:
- Manage the atomic host platform
- Rebooting of Atomic host platform should be done outside this module
- Manage the atomic host platform.
- Rebooting of Atomic host platform should be done outside this module.
version_added: "2.2"
author: "Saravanan KR @krsacme"
author:
- Saravanan KR (@krsacme)
notes:
- Host should be an atomic platform (verified by existence of '/run/ostree-booted' file)
- Host should be an atomic platform (verified by existence of '/run/ostree-booted' file).
requirements:
- atomic
- "python >= 2.6"
- python >= 2.6
options:
revision:
description:
- The version number of the atomic host to be deployed. Providing C(latest) will upgrade to the latest available version.
required: false
default: latest
aliases: ["version"]
aliases: [ version ]
'''
EXAMPLES = '''
# Upgrade the atomic host platform to the latest version (atomic host upgrade)
- atomic_host:
- name: Upgrade the atomic host platform to the latest version (atomic host upgrade)
atomic_host:
revision: latest
# Deploy a specific revision as the atomic host (atomic host deploy 23.130)
- atomic_host:
- name: Deploy a specific revision as the atomic host (atomic host deploy 23.130)
atomic_host:
revision: 23.130
'''
@ -89,9 +86,9 @@ def core(module):
def main():
module = AnsibleModule(
argument_spec=dict(
revision=dict(default='latest', required=False, aliases=["version"]),
),
)
revision=dict(type='str', default='latest', aliases=["version"]),
),
)
# Verify that the platform is atomic host
if not os.path.exists("/run/ostree-booted"):

@ -7,63 +7,56 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: atomic_image
short_description: Manage the container images on the atomic host platform
description:
- Manage the container images on the atomic host platform
- Allows to execute the commands specified by the RUN label in the container image when present
- Manage the container images on the atomic host platform.
- Allows to execute the commands specified by the RUN label in the container image when present.
version_added: "2.2"
author: "Saravanan KR @krsacme"
author:
- Saravanan KR (@krsacme)
notes:
- Host should support C(atomic) command
- Host should support C(atomic) command.
requirements:
- atomic
- "python >= 2.6"
- python >= 2.6
options:
backend:
description:
- Define the backend where the image is pulled.
required: False
choices: ["docker", "ostree"]
default: None
choices: [ docker, ostree ]
version_added: "2.4"
name:
description:
- Name of the container image
- Name of the container image.
required: True
default: null
state:
description:
- The state of the container image.
- The state C(latest) will ensure container image is upgraded to the latest version and forcefully restart container, if running.
required: False
choices: ["present", "absent", "latest"]
choices: [ absent, latest, present ]
default: latest
started:
description:
- Start or Stop the container
required: False
choices: ["yes", "no"]
default: yes
- Start or Stop the container.
type: bool
default: 'yes'
'''
EXAMPLES = '''
# Execute the run command on rsyslog container image (atomic run rhel7/rsyslog)
- atomic_image:
- name: Execute the run command on rsyslog container image (atomic run rhel7/rsyslog)
atomic_image:
name: rhel7/rsyslog
state: latest
# Pull busybox to the OSTree backend
- atomic_image:
- name: Pull busybox to the OSTree backend
atomic_image:
name: busybox
state: latest
backend: ostree
@ -85,7 +78,7 @@ from ansible.module_utils._text import to_native
def do_upgrade(module, image):
args = ['atomic', 'update', '--force', image]
rc, out, err = module.run_command(args, check_rc=False)
if rc != 0: # something went wrong emit the msg
if rc != 0: # something went wrong emit the msg
module.fail_json(rc=rc, msg=err)
elif 'Image is up to date' in out:
return False
@ -122,7 +115,7 @@ def core(module):
changed = "Extracting" in out or "Copying blob" in out
module.exit_json(msg=(out + out_run), changed=changed)
elif state == 'absent':
args = ['atomic', 'images', 'delete', "--storage=%s" % backend, image]
args = ['atomic', 'images', 'delete', "--storage=%s" % backend, image]
if rc < 0:
module.fail_json(rc=rc, msg=err)
else:
@ -156,12 +149,12 @@ def core(module):
def main():
module = AnsibleModule(
argument_spec=dict(
backend=dict(default=None, choices=['docker', 'ostree']),
name=dict(default=None, required=True),
state=dict(default='latest', choices=['present', 'absent', 'latest']),
started=dict(default='yes', type='bool'),
),
)
backend=dict(type='str', choices=['docker', 'ostree']),
name=dict(type='str', required=True),
state=dict(type='str', default='latest', choices=['absent', 'latest', 'present']),
started=dict(type='bool', default=True),
),
)
# Verify that the platform supports atomic command
rc, out, err = module.run_command('atomic -v', check_rc=False)

@ -57,8 +57,6 @@ lib/ansible/modules/cloud/amazon/s3_website.py
lib/ansible/modules/cloud/amazon/sns_topic.py
lib/ansible/modules/cloud/amazon/sts_assume_role.py
lib/ansible/modules/cloud/amazon/sts_session_token.py
lib/ansible/modules/cloud/atomic/atomic_host.py
lib/ansible/modules/cloud/atomic/atomic_image.py
lib/ansible/modules/cloud/azure/azure_rm_deployment.py
lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py
lib/ansible/modules/cloud/azure/azure_rm_publicipaddress.py

Loading…
Cancel
Save