1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Get rid of more wildcard imports and add boilerplate to more modules

This commit cleans up the following module categories:
* messaging
* inventory
* crypto
* commands
* clustering
* cloud/webfaction
* cloud/docker
* cloud/digital_ocean
This commit is contained in:
Toshio Kuratomi 2017-07-29 00:20:36 -07:00
parent 6f69cd4501
commit 1ee08c0f06
47 changed files with 416 additions and 848 deletions

View file

@ -1,20 +1,13 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# Copyright: Ansible Project
# 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
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
@ -193,6 +186,7 @@ import traceback
from distutils.version import LooseVersion from distutils.version import LooseVersion
try: try:
# Imported as a dependency for dopy
import six import six
HAS_SIX = True HAS_SIX = True
except ImportError: except ImportError:
@ -479,5 +473,6 @@ def main():
except (DoError, Exception) as e: except (DoError, Exception) as e:
module.fail_json(msg=str(e), exception=traceback.format_exc()) module.fail_json(msg=str(e), exception=traceback.format_exc())
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,20 +1,12 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# Copyright: Ansible Project
# 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
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -118,9 +110,9 @@ id:
import json import json
import os import os
import time import time
import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.urls import fetch_url from ansible.module_utils.urls import fetch_url
@ -338,12 +330,11 @@ def main():
) )
try: try:
handle_request(module) handle_request(module)
except DOBlockStorageException: except DOBlockStorageException as e:
e = get_exception() module.fail_json(msg=e.message, exception=traceback.format_exc())
module.fail_json(msg=e.message) except KeyError as e:
except KeyError: module.fail_json(msg='Unable to load %s' % e.message, exception=traceback.format_exc())
e = get_exception()
module.fail_json(msg='Unable to load %s' % e.message)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,20 +1,13 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# Copyright: Ansible Project
# 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
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['stableinterface'], 'status': ['stableinterface'],
'supported_by': 'community'} 'supported_by': 'community'}
@ -96,6 +89,7 @@ except ImportError as e:
HAS_DOPY = False HAS_DOPY = False
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_native
class JsonfyMixIn(object): class JsonfyMixIn(object):
@ -244,7 +238,8 @@ def main():
try: try:
core(module) core(module)
except (DoError, Exception) as e: except (DoError, Exception) as e:
module.fail_json(msg=str(e), exception=traceback.format_exc()) module.fail_json(msg=to_native(e), exception=traceback.format_exc())
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -2,21 +2,12 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# (c) 2015, Patrick F. Marques <patrickfmarques@gmail.com> # (c) 2015, Patrick F. Marques <patrickfmarques@gmail.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'status': ['preview'], ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community', 'supported_by': 'community',
'metadata_version': '1.0'} 'metadata_version': '1.0'}
@ -124,11 +115,10 @@ data:
''' '''
import json import json
import os
import time import time
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.urls import fetch_url from ansible.module_utils.urls import fetch_url
@ -216,28 +206,27 @@ def core(module):
state = module.params['state'] state = module.params['state']
ip = module.params['ip'] ip = module.params['ip']
droplet_id = module.params['droplet_id'] droplet_id = module.params['droplet_id']
region = module.params['region']
rest = Rest(module, {'Authorization': 'Bearer {0}'.format(api_token), rest = Rest(module, {'Authorization': 'Bearer {0}'.format(api_token),
'Content-type': 'application/json'}) 'Content-type': 'application/json'})
if state in ('present'): if state in ('present'):
if module.params['droplet_id'] is not None and module.params['ip'] is not None: if droplet_id is not None and module.params['ip'] is not None:
# Lets try to associate the ip to the specified droplet # Lets try to associate the ip to the specified droplet
result = associate_floating_ips(module, rest) associate_floating_ips(module, rest)
else: else:
result = create_floating_ips(module, rest) create_floating_ips(module, rest)
elif state in ('absent'): elif state in ('absent'):
response = rest.delete("floating_ips/{0}".format(ip)) response = rest.delete("floating_ips/{0}".format(ip))
status_code = response.status_code status_code = response.status_code
json = response.json json_data = response.json
if status_code == 204: if status_code == 204:
module.exit_json(changed=True) module.exit_json(changed=True)
elif status_code == 404: elif status_code == 404:
module.exit_json(changed=False) module.exit_json(changed=False)
else: else:
module.exit_json(changed=False, data=json) module.exit_json(changed=False, data=json_data)
def get_floating_ip_details(module, rest): def get_floating_ip_details(module, rest):
@ -245,12 +234,12 @@ def get_floating_ip_details(module, rest):
response = rest.get("floating_ips/{0}".format(ip)) response = rest.get("floating_ips/{0}".format(ip))
status_code = response.status_code status_code = response.status_code
json = response.json json_data = response.json
if status_code == 200: if status_code == 200:
return response.json['floating_ip'] return json_data['floating_ip']
else: else:
module.fail_json(msg="Error assigning floating ip [{0}: {1}]".format( module.fail_json(msg="Error assigning floating ip [{0}: {1}]".format(
status_code, response.json["message"]), region=module.params['region']) status_code, json_data["message"]), region=module.params['region'])
def assign_floating_id_to_droplet(module, rest): def assign_floating_id_to_droplet(module, rest):
@ -263,14 +252,14 @@ def assign_floating_id_to_droplet(module, rest):
response = rest.post("floating_ips/{0}/actions".format(ip), data=payload) response = rest.post("floating_ips/{0}/actions".format(ip), data=payload)
status_code = response.status_code status_code = response.status_code
json = response.json json_data = response.json
if status_code == 201: if status_code == 201:
wait_action(module, rest, ip, json['action']['id']) wait_action(module, rest, ip, json_data['action']['id'])
module.exit_json(changed=True, data=response.json) module.exit_json(changed=True, data=json_data)
else: else:
module.fail_json(msg="Error creating floating ip [{0}: {1}]".format( module.fail_json(msg="Error creating floating ip [{0}: {1}]".format(
status_code, response.json["message"]), region=module.params['region']) status_code, json_data["message"]), region=module.params['region'])
def associate_floating_ips(module, rest): def associate_floating_ips(module, rest):
@ -295,12 +284,12 @@ def create_floating_ips(module, rest):
response = rest.post("floating_ips", data=payload) response = rest.post("floating_ips", data=payload)
status_code = response.status_code status_code = response.status_code
json = response.json json_data = response.json
if status_code == 202: if status_code == 202:
module.exit_json(changed=True, data=response.json) module.exit_json(changed=True, data=json_data)
else: else:
module.fail_json(msg="Error creating floating ip [{0}: {1}]".format( module.fail_json(msg="Error creating floating ip [{0}: {1}]".format(
status_code, response.json["message"]), region=module.params['region']) status_code, json_data["message"]), region=module.params['region'])
def main(): def main():
@ -329,5 +318,6 @@ def main():
core(module) core(module)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,20 +1,13 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# This file is part of Ansible # Copyright: Ansible Project
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by from __future__ import absolute_import, division, print_function
# the Free Software Foundation, either version 3 of the License, or __metaclass__ = type
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
@ -182,5 +175,6 @@ def main():
except (DoError, Exception) as e: except (DoError, Exception) as e:
module.fail_json(msg=str(e), exception=traceback.format_exc()) module.fail_json(msg=str(e), exception=traceback.format_exc())
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,20 +1,13 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# This file is part of Ansible # Copyright: Ansible Project
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by from __future__ import absolute_import, division, print_function
# the Free Software Foundation, either version 3 of the License, or __metaclass__ = type
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
@ -280,5 +273,6 @@ def main():
except Exception as e: except Exception as e:
module.fail_json(msg=str(e)) module.fail_json(msg=str(e))
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -4,22 +4,11 @@
# (c) 2014, Joshua Conner <joshua.conner@gmail.com> # (c) 2014, Joshua Conner <joshua.conner@gmail.com>
# (c) 2014, Pavel Antonov <antonov@adwz.ru> # (c) 2014, Pavel Antonov <antonov@adwz.ru>
# #
# This file is part of Ansible, # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#
# Ansible is free software: you can redistribute it and/or modify from __future__ import absolute_import, division, print_function
# it under the terms of the GNU General Public License as published by __metaclass__ = type
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
######################################################################
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['deprecated'], 'status': ['deprecated'],
@ -524,11 +513,6 @@ EXAMPLES = '''
syslog-tag: myservice syslog-tag: myservice
''' '''
HAS_DOCKER_PY = True
DEFAULT_DOCKER_API_VERSION = None
DEFAULT_TIMEOUT_SECONDS = 60
import sys
import json import json
import os import os
import shlex import shlex
@ -543,9 +527,12 @@ try:
import docker.utils import docker.utils
import docker.errors import docker.errors
from requests.exceptions import RequestException from requests.exceptions import RequestException
HAS_DOCKER_PY = True
except ImportError: except ImportError:
HAS_DOCKER_PY = False HAS_DOCKER_PY = False
DEFAULT_DOCKER_API_VERSION = None
DEFAULT_TIMEOUT_SECONDS = 60
if HAS_DOCKER_PY: if HAS_DOCKER_PY:
try: try:
from docker.errors import APIError as DockerAPIError from docker.errors import APIError as DockerAPIError
@ -561,6 +548,8 @@ if HAS_DOCKER_PY:
DEFAULT_DOCKER_API_VERSION = docker.client.DEFAULT_DOCKER_API_VERSION DEFAULT_DOCKER_API_VERSION = docker.client.DEFAULT_DOCKER_API_VERSION
DEFAULT_TIMEOUT_SECONDS = docker.client.DEFAULT_TIMEOUT_SECONDS DEFAULT_TIMEOUT_SECONDS = docker.client.DEFAULT_TIMEOUT_SECONDS
from ansible.module_utils.basic import AnsibleModule
def _human_to_bytes(number): def _human_to_bytes(number):
suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'] suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
@ -1979,8 +1968,6 @@ def main():
except RequestException as e: except RequestException as e:
module.fail_json(changed=manager.has_changed(), msg=repr(e)) module.fail_json(changed=manager.has_changed(), msg=repr(e))
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,21 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
# #
# Copyright 2016 Red Hat | Ansible # Copyright 2016 Red Hat | Ansible
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],

View file

@ -1,21 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
# #
# Copyright 2016 Red Hat | Ansible # Copyright 2016 Red Hat | Ansible
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -250,11 +240,10 @@ image:
type: dict type: dict
sample: {} sample: {}
''' '''
import re
import os import os
import re
from ansible.module_utils.docker_common import (HAS_DOCKER_PY_2, AnsibleDockerClient, from ansible.module_utils.docker_common import HAS_DOCKER_PY_2, AnsibleDockerClient, DockerBaseClass
DockerBaseClass)
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
try: try:

View file

@ -1,21 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
# #
# Copyright 2016 Red Hat | Ansible # Copyright 2016 Red Hat | Ansible
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -161,15 +151,15 @@ images:
] ]
''' '''
from ansible.module_utils.docker_common import *
try: try:
from docker import auth
from docker import utils from docker import utils
except ImportError: except ImportError:
# missing docker-py handled in docker_common # missing docker-py handled in docker_common
pass pass
from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass
class ImageManager(DockerBaseClass): class ImageManager(DockerBaseClass):
def __init__(self, client, results): def __init__(self, client, results):
@ -242,8 +232,5 @@ def main():
client.module.exit_json(**results) client.module.exit_json(**results)
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -4,21 +4,10 @@
# Chris Houseknecht, <house@redhat.com> # Chris Houseknecht, <house@redhat.com>
# James Tanner, <jtanner@redhat.com> # James Tanner, <jtanner@redhat.com>
# #
# This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#
# Ansible is free software: you can redistribute it and/or modify from __future__ import absolute_import, division, print_function
# it under the terms of the GNU General Public License as published by __metaclass__ = type
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
@ -142,9 +131,12 @@ login_results:
''' '''
import base64 import base64
import json
import os
import re
from ansible.module_utils._text import to_bytes, to_text from ansible.module_utils._text import to_bytes, to_text
from ansible.module_utils.docker_common import * from ansible.module_utils.docker_common import AnsibleDockerClient, DEFAULT_DOCKER_REGISTRY, DockerBaseClass, EMAIL_REGEX
class LoginManager(DockerBaseClass): class LoginManager(DockerBaseClass):
@ -333,8 +325,6 @@ def main():
del results['actions'] del results['actions']
client.module.exit_json(**results) client.module.exit_json(**results)
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,21 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
# #
# Copyright 2016 Red Hat | Ansible # Copyright 2016 Red Hat | Ansible
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -161,14 +151,12 @@ facts:
sample: {} sample: {}
''' '''
from ansible.module_utils.docker_common import * from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass, HAS_DOCKER_PY_2
try: try:
from docker import utils from docker import utils
if HAS_DOCKER_PY_2: if HAS_DOCKER_PY_2:
from docker.types import Ulimit, IPAMPool, IPAMConfig from docker.types import IPAMPool, IPAMConfig
else:
from docker.utils.types import Ulimit
except: except:
# missing docker-py handled in ansible.module_utils.docker # missing docker-py handled in ansible.module_utils.docker
pass pass
@ -390,8 +378,6 @@ def main():
cm = DockerNetworkManager(client) cm = DockerNetworkManager(client)
client.module.exit_json(**cm.results) client.module.exit_json(**cm.results)
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,21 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
# #
# Copyright 2016 Red Hat | Ansible # Copyright 2016 Red Hat | Ansible
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -152,7 +142,6 @@ except ImportError:
# missing docker-py handled in ansible.module_utils.docker # missing docker-py handled in ansible.module_utils.docker
pass pass
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass
from ansible.module_utils._text import to_native, to_bytes from ansible.module_utils._text import to_native, to_bytes

View file

@ -1,21 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
# #
# Copyright 2016 Red Hat | Ansible # Copyright 2016 Red Hat | Ansible
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -449,38 +439,37 @@ actions:
type: string type: string
''' '''
HAS_YAML = True import os
HAS_YAML_EXC = None
HAS_COMPOSE = True
HAS_COMPOSE_EXC = None
MINIMUM_COMPOSE_VERSION = '1.7.0'
import sys
import re import re
import sys
import tempfile
from contextlib import contextmanager
from distutils.version import LooseVersion
try: try:
import yaml import yaml
HAS_YAML = True
HAS_YAML_EXC = None
except ImportError as exc: except ImportError as exc:
HAS_YAML = False HAS_YAML = False
HAS_YAML_EXC = str(exc) HAS_YAML_EXC = str(exc)
from distutils.version import LooseVersion
from ansible.module_utils.basic import *
try: try:
from compose import __version__ as compose_version from compose import __version__ as compose_version
from compose.project import ProjectError
from compose.cli.command import project_from_options from compose.cli.command import project_from_options
from compose.service import ConvergenceStrategy, NoSuchImageError from compose.service import NoSuchImageError
from compose.cli.main import convergence_strategy_from_opts, build_action_from_opts, image_type_from_opt from compose.cli.main import convergence_strategy_from_opts, build_action_from_opts, image_type_from_opt
from compose.const import DEFAULT_TIMEOUT from compose.const import DEFAULT_TIMEOUT
HAS_COMPOSE = True
HAS_COMPOSE_EXC = None
MINIMUM_COMPOSE_VERSION = '1.7.0'
except ImportError as exc: except ImportError as exc:
HAS_COMPOSE = False HAS_COMPOSE = False
HAS_COMPOSE_EXC = str(exc) HAS_COMPOSE_EXC = str(exc)
DEFAULT_TIMEOUT = 10 DEFAULT_TIMEOUT = 10
from ansible.module_utils.docker_common import * from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass
from contextlib import contextmanager
AUTH_PARAM_MAPPING = { AUTH_PARAM_MAPPING = {

View file

@ -2,21 +2,12 @@
# coding: utf-8 # coding: utf-8
# #
# Copyright 2017 Red Hat | Ansible, Alex Grönholm <alex.gronholm@nextday.fi> # Copyright 2017 Red Hat | Ansible, Alex Grönholm <alex.gronholm@nextday.fi>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
@ -112,8 +103,8 @@ except ImportError:
# missing docker-py handled in ansible.module_utils.docker # missing docker-py handled in ansible.module_utils.docker
pass pass
from ansible.module_utils.six import iteritems, text_type
from ansible.module_utils.docker_common import DockerBaseClass, AnsibleDockerClient from ansible.module_utils.docker_common import DockerBaseClass, AnsibleDockerClient
from ansible.module_utils.six import iteritems, text_type
class TaskParameters(DockerBaseClass): class TaskParameters(DockerBaseClass):
@ -258,5 +249,6 @@ def main():
cm = DockerVolumeManager(client) cm = DockerVolumeManager(client)
client.module.exit_json(**cm.results) client.module.exit_json(**cm.results)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,31 +1,19 @@
#!/usr/bin/python #!/usr/bin/python
# #
# Create a Webfaction application using Ansible and the Webfaction API
#
# Valid application types can be found by looking here:
# http://docs.webfaction.com/xmlrpc-api/apps.html#application-types
#
# ------------------------------------------
#
# (c) Quentin Stafford-Fraser 2015, with contributions gratefully acknowledged from: # (c) Quentin Stafford-Fraser 2015, with contributions gratefully acknowledged from:
# * Andy Baker # * Andy Baker
# * Federico Tarantini # * Federico Tarantini
# #
# This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# #
# Ansible is free software: you can redistribute it and/or modify # Create a Webfaction application using Ansible and the Webfaction API
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# #
# Valid application types can be found by looking here:
# http://docs.webfaction.com/xmlrpc-api/apps.html#application-types
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -113,8 +101,12 @@ EXAMPLES = '''
import xmlrpclib import xmlrpclib
from ansible.module_utils.basic import AnsibleModule
webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/') webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
@ -202,7 +194,6 @@ def main():
result = result result = result
) )
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,28 +1,16 @@
#!/usr/bin/python #!/usr/bin/python
# #
# Create a webfaction database using Ansible and the Webfaction API
#
# ------------------------------------------
#
# (c) Quentin Stafford-Fraser 2015, with contributions gratefully acknowledged from: # (c) Quentin Stafford-Fraser 2015, with contributions gratefully acknowledged from:
# * Andy Baker # * Andy Baker
# * Federico Tarantini # * Federico Tarantini
# #
# This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# #
# Create a webfaction database using Ansible and the Webfaction API
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -103,11 +91,14 @@ EXAMPLES = '''
''' '''
import socket
import xmlrpclib import xmlrpclib
from ansible.module_utils.basic import AnsibleModule
webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/') webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
@ -203,7 +194,6 @@ def main():
result = result result = result
) )
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,26 +1,13 @@
#!/usr/bin/python #!/usr/bin/python
# #
# Create Webfaction domains and subdomains using Ansible and the Webfaction API
#
# ------------------------------------------
#
# (c) Quentin Stafford-Fraser 2015 # (c) Quentin Stafford-Fraser 2015
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# #
# This file is part of Ansible # Create Webfaction domains and subdomains using Ansible and the Webfaction API
#
# Ansible is free software: you can redistribute it and/or modify from __future__ import absolute_import, division, print_function
# it under the terms of the GNU General Public License as published by __metaclass__ = type
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -95,11 +82,14 @@ EXAMPLES = '''
''' '''
import socket
import xmlrpclib import xmlrpclib
from ansible.module_utils.basic import AnsibleModule
webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/') webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
@ -175,7 +165,6 @@ def main():
result = result result = result
) )
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,25 +1,13 @@
#!/usr/bin/python #!/usr/bin/python
# #
# Create webfaction mailbox using Ansible and the Webfaction API
#
# ------------------------------------------
# (c) Quentin Stafford-Fraser and Andy Baker 2015 # (c) Quentin Stafford-Fraser and Andy Baker 2015
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# #
# This file is part of Ansible # Create webfaction mailbox using Ansible and the Webfaction API
#
# Ansible is free software: you can redistribute it and/or modify from __future__ import absolute_import, division, print_function
# it under the terms of the GNU General Public License as published by __metaclass__ = type
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -81,11 +69,14 @@ EXAMPLES = '''
login_password={{webfaction_passwd}} login_password={{webfaction_passwd}}
''' '''
import socket
import xmlrpclib import xmlrpclib
from ansible.module_utils.basic import AnsibleModule
webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/') webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
@ -142,7 +133,5 @@ def main():
module.exit_json(changed=True, result=result) module.exit_json(changed=True, result=result)
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,26 +1,12 @@
#!/usr/bin/python #!/usr/bin/python
# (c) Quentin Stafford-Fraser 2015
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# #
# Create Webfaction website using Ansible and the Webfaction API # Create Webfaction website using Ansible and the Webfaction API
#
# ------------------------------------------ from __future__ import absolute_import, division, print_function
# __metaclass__ = type
# (c) Quentin Stafford-Fraser 2015
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -113,8 +99,12 @@ EXAMPLES = '''
import socket import socket
import xmlrpclib import xmlrpclib
from ansible.module_utils.basic import AnsibleModule
webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/') webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
@ -213,8 +203,5 @@ def main():
) )
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,21 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
# #
# (c) 2015, Steve Gargan <steve.gargan@gmail.com> # (c) 2015, Steve Gargan <steve.gargan@gmail.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],

View file

@ -1,21 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
# #
# (c) 2015, Steve Gargan <steve.gargan@gmail.com> # (c) 2015, Steve Gargan <steve.gargan@gmail.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -123,8 +113,6 @@ EXAMPLES = '''
state: absent state: absent
''' '''
import sys
try: try:
import consul import consul
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
@ -138,8 +126,6 @@ try:
except ImportError: except ImportError:
pyhcl_installed = False pyhcl_installed = False
from requests.exceptions import ConnectionError
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_bytes from ansible.module_utils._text import to_bytes
@ -157,7 +143,6 @@ def execute(module):
def update_acl(module): def update_acl(module):
rules = module.params.get('rules') rules = module.params.get('rules')
state = module.params.get('state')
token = module.params.get('token') token = module.params.get('token')
token_type = module.params.get('token_type') token_type = module.params.get('token_type')
mgmt = module.params.get('mgmt_token') mgmt = module.params.get('mgmt_token')
@ -204,7 +189,6 @@ def update_acl(module):
def remove_acl(module): def remove_acl(module):
state = module.params.get('state')
token = module.params.get('token') token = module.params.get('token')
mgmt = module.params.get('mgmt_token') mgmt = module.params.get('mgmt_token')

View file

@ -1,21 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
# #
# (c) 2015, Steve Gargan <steve.gargan@gmail.com> # (c) 2015, Steve Gargan <steve.gargan@gmail.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -144,8 +134,6 @@ EXAMPLES = '''
state: acquire state: acquire
''' '''
import sys
try: try:
import consul import consul
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
@ -153,7 +141,8 @@ try:
except ImportError: except ImportError:
python_consul_installed = False python_consul_installed = False
from requests.exceptions import ConnectionError from ansible.module_utils.basic import AnsibleModule
def execute(module): def execute(module):
@ -230,7 +219,6 @@ def remove_value(module):
consul_api = get_consul_api(module) consul_api = get_consul_api(module)
key = module.params.get('key') key = module.params.get('key')
value = module.params.get('value')
index, existing = consul_api.kv.get( index, existing = consul_api.kv.get(
key, recurse=module.params.get('recurse')) key, recurse=module.params.get('recurse'))
@ -288,7 +276,5 @@ def main():
module.fail_json(msg=str(e)) module.fail_json(msg=str(e))
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -2,21 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# (c) 2015, Steve Gargan <steve.gargan@gmail.com> # (c) 2015, Steve Gargan <steve.gargan@gmail.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -145,6 +135,9 @@ try:
except ImportError: except ImportError:
python_consul_installed = False python_consul_installed = False
from ansible.module_utils.basic import AnsibleModule
def execute(module): def execute(module):
state = module.params.get('state') state = module.params.get('state')
@ -281,7 +274,6 @@ def main():
except Exception as e: except Exception as e:
module.fail_json(msg=str(e)) module.fail_json(msg=str(e))
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,20 +1,10 @@
#!/usr/bin/python #!/usr/bin/python
# Copyright 2015 Google Inc. All Rights Reserved. # Copyright 2015 Google Inc. All Rights Reserved.
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -156,6 +146,7 @@ api_response:
''' '''
import base64 import base64
import json
try: try:
import yaml import yaml
@ -163,6 +154,10 @@ try:
except ImportError: except ImportError:
has_lib_yaml = False has_lib_yaml = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import fetch_url
############################################################################ ############################################################################
############################################################################ ############################################################################
# For API coverage, this Anislbe module provides capability to operate on # For API coverage, this Anislbe module provides capability to operate on
@ -192,9 +187,9 @@ except ImportError:
# for a in apis.keys(): # for a in apis.keys():
# results.append('"%s": "%s"' % (a[3:].lower(), apis[a])) # results.append('"%s": "%s"' % (a[3:].lower(), apis[a]))
# results.sort() # results.sort()
# print "KIND_URL = {" # print("KIND_URL = {")
# print ",\n".join(results) # print(",\n".join(results))
# print "}" # print("}")
# #
# if __name__ == '__main__': # if __name__ == '__main__':
# print_kind_url_map() # print_kind_url_map()
@ -403,10 +398,5 @@ def main():
module.exit_json(changed=changed, api_response=body) module.exit_json(changed=changed, api_response=body)
# import module snippets
from ansible.module_utils.basic import * # NOQA
from ansible.module_utils.urls import * # NOQA
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -2,19 +2,11 @@
#coding: utf-8 -*- #coding: utf-8 -*-
# (c) 2016, Mathieu Bultel <mbultel@redhat.com> # (c) 2016, Mathieu Bultel <mbultel@redhat.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This module is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by from __future__ import absolute_import, division, print_function
# the Free Software Foundation, either version 3 of the License, or __metaclass__ = type
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -83,7 +75,9 @@ rc:
''' '''
import time import time
from distutils.version import StrictVersion
from ansible.module_utils.basic import AnsibleModule
_PCS_CLUSTER_DOWN="Error: cluster is not currently running on this node" _PCS_CLUSTER_DOWN="Error: cluster is not currently running on this node"
@ -229,6 +223,6 @@ def main():
module.exit_json(changed=True, module.exit_json(changed=True,
out=cluster_state) out=cluster_state)
from ansible.module_utils.basic import AnsibleModule
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,20 +1,10 @@
#!/usr/bin/python #!/usr/bin/python
# Copyright 2015 WP Engine, Inc. All rights reserved. # Copyright 2015 WP Engine, Inc. All rights reserved.
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -111,14 +101,17 @@ EXAMPLES = """
delegate_to: 127.0.0.1 delegate_to: 127.0.0.1
""" """
import time
try: try:
from kazoo.client import KazooClient from kazoo.client import KazooClient
from kazoo.exceptions import NoNodeError, ZookeeperError
from kazoo.handlers.threading import KazooTimeoutError from kazoo.handlers.threading import KazooTimeoutError
KAZOO_INSTALLED = True KAZOO_INSTALLED = True
except ImportError: except ImportError:
KAZOO_INSTALLED = False KAZOO_INSTALLED = False
from ansible.module_utils.basic import AnsibleModule
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
@ -261,7 +254,6 @@ class KazooCommandProxy():
return False, {'msg': 'The node did not appear before the operation timed out.', 'timeout': timeout, return False, {'msg': 'The node did not appear before the operation timed out.', 'timeout': timeout,
'znode': path} 'znode': path}
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -4,20 +4,11 @@
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>, and others # (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>, and others
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com> # (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
# #
# This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#
# Ansible is free software: you can redistribute it and/or modify from __future__ import absolute_import, division, print_function
# it under the terms of the GNU General Public License as published by __metaclass__ = type
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['stableinterface'], 'status': ['stableinterface'],
@ -92,11 +83,10 @@ EXAMPLES = '''
import datetime import datetime
import glob import glob
import shlex
import os import os
import shlex
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import b
def check_command(module, commandline): def check_command(module, commandline):
@ -190,14 +180,14 @@ def main():
delta = endd - startd delta = endd - startd
if out is None: if out is None:
out = b('') out = b''
if err is None: if err is None:
err = b('') err = b''
result = dict( result = dict(
cmd = args, cmd = args,
stdout = out.rstrip(b("\r\n")), stdout = out.rstrip(b"\r\n"),
stderr = err.rstrip(b("\r\n")), stderr = err.rstrip(b"\r\n"),
rc = rc, rc = rc,
start = str(startd), start = str(startd),
end = str(endd), end = str(endd),

View file

@ -2,21 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2015, Matt Martz <matt@sivel.net> # (c) 2015, Matt Martz <matt@sivel.net>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -99,6 +89,7 @@ EXAMPLES = r'''
import datetime import datetime
import os import os
import traceback
try: try:
import pexpect import pexpect
@ -106,9 +97,8 @@ try:
except ImportError: except ImportError:
HAS_PEXPECT = False HAS_PEXPECT = False
from ansible.module_utils._text import to_text
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils._text import to_native, to_text
def response_closure(module, question, responses): def response_closure(module, question, responses):
@ -202,18 +192,16 @@ def main():
# Use pexpect.runu in pexpect>=3.3,<4 # Use pexpect.runu in pexpect>=3.3,<4
out, rc = pexpect.runu(args, timeout=timeout, withexitstatus=True, out, rc = pexpect.runu(args, timeout=timeout, withexitstatus=True,
events=events, cwd=chdir, echo=echo) events=events, cwd=chdir, echo=echo)
except (TypeError, AttributeError): except (TypeError, AttributeError) as e:
e = get_exception()
# This should catch all insufficient versions of pexpect # This should catch all insufficient versions of pexpect
# We deem them insufficient for their lack of ability to specify # We deem them insufficient for their lack of ability to specify
# to not echo responses via the run/runu functions, which would # to not echo responses via the run/runu functions, which would
# potentially leak sensentive information # potentially leak sensentive information
module.fail_json(msg='Insufficient version of pexpect installed ' module.fail_json(msg='Insufficient version of pexpect installed '
'(%s), this module requires pexpect>=3.3. ' '(%s), this module requires pexpect>=3.3. '
'Error was %s' % (pexpect.__version__, e)) 'Error was %s' % (pexpect.__version__, to_native(e)))
except pexpect.ExceptionPexpect: except pexpect.ExceptionPexpect as e:
e = get_exception() module.fail_json(msg='%s' % to_native(e), exception=traceback.format_exc())
module.fail_json(msg='%s' % e)
endd = datetime.datetime.now() endd = datetime.datetime.now()
delta = endd - startd delta = endd - startd

View file

@ -1,19 +1,10 @@
# this is a virtual module that is entirely implemented server side # this is a virtual module that is entirely implemented server side
# Copyright: Ansible Project
# 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
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['stableinterface'], 'status': ['stableinterface'],

View file

@ -1,17 +1,9 @@
# This file is part of Ansible # Copyright: Ansible Project
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by from __future__ import absolute_import, division, print_function
# the Free Software Foundation, either version 3 of the License, or __metaclass__ = type
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['stableinterface'], 'status': ['stableinterface'],

View file

@ -1,21 +1,13 @@
# There is no actual shell module source, when you use 'shell' in ansible, # Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# # There is no actual shell module source, when you use 'shell' in ansible,
# it runs the 'command' module with special arguments and it behaves differently. # it runs the 'command' module with special arguments and it behaves differently.
# See the command source and the comment "#USE_SHELL". # See the command source and the comment "#USE_SHELL".
# This file is part of Ansible from __future__ import absolute_import, division, print_function
# __metaclass__ = type
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['stableinterface'], 'status': ['stableinterface'],

View file

@ -2,19 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# (c) 2017, Yanis Guenane <yanis+ansible@guenane.org> # (c) 2017, Yanis Guenane <yanis+ansible@guenane.org>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by from __future__ import absolute_import, division, print_function
# the Free Software Foundation, either version 3 of the License, or __metaclass__ = type
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],

View file

@ -2,19 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2016, Yanis Guenane <yanis+ansible@guenane.org> # (c) 2016, Yanis Guenane <yanis+ansible@guenane.org>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by from __future__ import absolute_import, division, print_function
# the Free Software Foundation, either version 3 of the License, or __metaclass__ = type
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -134,11 +126,6 @@ fingerprint:
import os import os
from ansible.module_utils import crypto as crypto_utils
from ansible.module_utils._text import to_native
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
try: try:
from OpenSSL import crypto from OpenSSL import crypto
except ImportError: except ImportError:
@ -146,6 +133,10 @@ except ImportError:
else: else:
pyopenssl_found = True pyopenssl_found = True
from ansible.module_utils import crypto as crypto_utils
from ansible.module_utils._text import to_native
from ansible.module_utils.basic import AnsibleModule
class PrivateKeyError(crypto_utils.OpenSSLObjectError): class PrivateKeyError(crypto_utils.OpenSSLObjectError):
pass pass

View file

@ -2,19 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2016, Yanis Guenane <yanis+ansible@guenane.org> # (c) 2016, Yanis Guenane <yanis+ansible@guenane.org>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by from __future__ import absolute_import, division, print_function
# the Free Software Foundation, either version 3 of the License, or __metaclass__ = type
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -134,10 +126,6 @@ fingerprint:
import hashlib import hashlib
import os import os
from ansible.module_utils import crypto as crypto_utils
from ansible.module_utils._text import to_native
from ansible.module_utils.basic import AnsibleModule
try: try:
from OpenSSL import crypto from OpenSSL import crypto
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
@ -147,6 +135,10 @@ except ImportError:
else: else:
pyopenssl_found = True pyopenssl_found = True
from ansible.module_utils import crypto as crypto_utils
from ansible.module_utils._text import to_native
from ansible.module_utils.basic import AnsibleModule
class PublicKeyError(crypto_utils.OpenSSLObjectError): class PublicKeyError(crypto_utils.OpenSSLObjectError):
pass pass

View file

@ -1,19 +1,11 @@
# -*- mode: python -*- # -*- mode: python -*-
#
# Copyright: Ansible Team
# 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
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['stableinterface'], 'status': ['stableinterface'],

View file

@ -1,19 +1,11 @@
# -*- mode: python -*- # -*- mode: python -*-
#
# Copyright: Ansible Team
# 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
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['stableinterface'], 'status': ['stableinterface'],

View file

@ -2,22 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2015, Manuel Sousa <manuel.sousa@gmail.com> # (c) 2015, Manuel Sousa <manuel.sousa@gmail.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -113,9 +102,12 @@ EXAMPLES = '''
routing_key: '*.info' routing_key: '*.info'
''' '''
import json
import requests import requests
import urllib import urllib
import json
from ansible.module_utils.basic import AnsibleModule
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
@ -227,8 +219,6 @@ def main():
name = module.params['name'] name = module.params['name']
) )
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -2,22 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2015, Manuel Sousa <manuel.sousa@gmail.com> # (c) 2015, Manuel Sousa <manuel.sousa@gmail.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -115,9 +104,12 @@ EXAMPLES = '''
vhost: myVhost vhost: myVhost
''' '''
import json
import requests import requests
import urllib import urllib
import json
from ansible.module_utils.basic import AnsibleModule
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
@ -223,8 +215,6 @@ def main():
name = module.params['name'] name = module.params['name']
) )
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -2,21 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2013, Chatham Financial <oss@chathamfinancial.com> # (c) 2013, Chatham Financial <oss@chathamfinancial.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -74,6 +64,10 @@ EXAMPLES = """
value: '"guest"' value: '"guest"'
state: present state: present
""" """
import json
from ansible.module_utils.basic import AnsibleModule
class RabbitMqParameter(object): class RabbitMqParameter(object):
def __init__(self, module, component, name, value, vhost, node): def __init__(self, module, component, name, value, vhost, node):
@ -160,8 +154,6 @@ def main():
module.exit_json(changed=changed, component=component, name=name, vhost=vhost, state=state) module.exit_json(changed=changed, component=component, name=name, vhost=vhost, state=state)
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -2,21 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2013, Chatham Financial <oss@chathamfinancial.com> # (c) 2013, Chatham Financial <oss@chathamfinancial.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -68,6 +58,9 @@ EXAMPLES = '''
import os import os
from ansible.module_utils.basic import AnsibleModule
class RabbitMqPlugins(object): class RabbitMqPlugins(object):
def __init__(self, module): def __init__(self, module):
self.module = module self.module = module
@ -152,8 +145,6 @@ def main():
changed = len(enabled) > 0 or len(disabled) > 0 changed = len(enabled) > 0 or len(disabled) > 0
module.exit_json(changed=changed, enabled=enabled, disabled=disabled) module.exit_json(changed=changed, enabled=enabled, disabled=disabled)
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -2,22 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2013, John Dewey <john@dewey.ws> # (c) 2013, John Dewey <john@dewey.ws>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -93,6 +82,9 @@ EXAMPLES = '''
tags: tags:
ha-mode: all ha-mode: all
''' '''
from ansible.module_utils.basic import AnsibleModule
class RabbitMqPolicy(object): class RabbitMqPolicy(object):
def __init__(self, module, name): def __init__(self, module, name):
self._module = module self._module = module
@ -174,8 +166,6 @@ def main():
module.exit_json(changed=changed, name=name, state=state) module.exit_json(changed=changed, name=name, state=state)
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -2,22 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2015, Manuel Sousa <manuel.sousa@gmail.com> # (c) 2015, Manuel Sousa <manuel.sousa@gmail.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -130,9 +119,12 @@ EXAMPLES = '''
login_host: remote.example.org login_host: remote.example.org
''' '''
import json
import requests import requests
import urllib import urllib
import json
from ansible.module_utils.basic import AnsibleModule
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
@ -271,8 +263,6 @@ def main():
name = module.params['name'] name = module.params['name']
) )
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -2,21 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2013, Chatham Financial <oss@chathamfinancial.com> # (c) 2013, Chatham Financial <oss@chathamfinancial.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -134,6 +124,9 @@ EXAMPLES = '''
state: present state: present
''' '''
from ansible.module_utils.basic import AnsibleModule
class RabbitMqUser(object): class RabbitMqUser(object):
def __init__(self, module, username, password, tags, permissions, def __init__(self, module, username, password, tags, permissions,
node, bulk_permissions=False): node, bulk_permissions=False):
@ -308,8 +301,6 @@ def main():
module.exit_json(changed=changed, user=username, state=state) module.exit_json(changed=changed, user=username, state=state)
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -2,22 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2013, Chatham Financial <oss@chathamfinancial.com> # (c) 2013, Chatham Financial <oss@chathamfinancial.com>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify __metaclass__ = type
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -65,6 +54,9 @@ EXAMPLES = '''
state: present state: present
''' '''
from ansible.module_utils.basic import AnsibleModule
class RabbitMqVhost(object): class RabbitMqVhost(object):
def __init__(self, module, name, tracing, node): def __init__(self, module, name, tracing, node):
self.module = module self.module = module
@ -149,8 +141,6 @@ def main():
module.exit_json(changed=changed, name=name, state=state) module.exit_json(changed=changed, name=name, state=state)
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -25,23 +25,15 @@ metaclass3=$(find ./lib/ansible/modules -path ./lib/ansible/modules/windows -pru
-o -path ./lib/ansible/modules/network -prune \ -o -path ./lib/ansible/modules/network -prune \
-o -path ./lib/ansible/modules/net_tools -prune \ -o -path ./lib/ansible/modules/net_tools -prune \
-o -path ./lib/ansible/modules/monitoring -prune \ -o -path ./lib/ansible/modules/monitoring -prune \
-o -path ./lib/ansible/modules/messaging -prune \
-o -path ./lib/ansible/modules/inventory -prune \
-o -path ./lib/ansible/modules/identity -prune \ -o -path ./lib/ansible/modules/identity -prune \
-o -path ./lib/ansible/modules/files -prune \ -o -path ./lib/ansible/modules/files -prune \
-o -path ./lib/ansible/modules/database -prune \ -o -path ./lib/ansible/modules/database -prune \
-o -path ./lib/ansible/modules/crypto -prune \
-o -path ./lib/ansible/modules/commands -prune \
-o -path ./lib/ansible/modules/clustering -prune \
-o -path ./lib/ansible/modules/cloud/webfaction -prune \
-o -path ./lib/ansible/modules/cloud/vmware -prune \ -o -path ./lib/ansible/modules/cloud/vmware -prune \
-o -path ./lib/ansible/modules/cloud/rackspace -prune \ -o -path ./lib/ansible/modules/cloud/rackspace -prune \
-o -path ./lib/ansible/modules/cloud/ovirt -prune \ -o -path ./lib/ansible/modules/cloud/ovirt -prune \
-o -path ./lib/ansible/modules/cloud/openstack -prune \ -o -path ./lib/ansible/modules/cloud/openstack -prune \
-o -path ./lib/ansible/modules/cloud/misc -prune \ -o -path ./lib/ansible/modules/cloud/misc -prune \
-o -path ./lib/ansible/modules/cloud/google -prune \ -o -path ./lib/ansible/modules/cloud/google -prune \
-o -path ./lib/ansible/modules/cloud/docker -prune \
-o -path ./lib/ansible/modules/cloud/digital_ocean -prune \
-o -path ./lib/ansible/modules/cloud/cloudstack -prune \ -o -path ./lib/ansible/modules/cloud/cloudstack -prune \
-o -path ./lib/ansible/modules/cloud/centurylink -prune \ -o -path ./lib/ansible/modules/cloud/centurylink -prune \
-o -path ./lib/ansible/modules/cloud/amazon -prune \ -o -path ./lib/ansible/modules/cloud/amazon -prune \
@ -54,31 +46,42 @@ future3=$(find ./lib/ansible/modules -path ./lib/ansible/modules/windows -prune
-o -path ./lib/ansible/modules/network -prune \ -o -path ./lib/ansible/modules/network -prune \
-o -path ./lib/ansible/modules/net_tools -prune \ -o -path ./lib/ansible/modules/net_tools -prune \
-o -path ./lib/ansible/modules/monitoring -prune \ -o -path ./lib/ansible/modules/monitoring -prune \
-o -path ./lib/ansible/modules/messaging -prune \
-o -path ./lib/ansible/modules/inventory -prune \
-o -path ./lib/ansible/modules/identity -prune \ -o -path ./lib/ansible/modules/identity -prune \
-o -path ./lib/ansible/modules/files -prune \ -o -path ./lib/ansible/modules/files -prune \
-o -path ./lib/ansible/modules/database -prune \ -o -path ./lib/ansible/modules/database -prune \
-o -path ./lib/ansible/modules/crypto -prune \
-o -path ./lib/ansible/modules/commands -prune \
-o -path ./lib/ansible/modules/clustering -prune \
-o -path ./lib/ansible/modules/cloud/webfaction -prune \
-o -path ./lib/ansible/modules/cloud/vmware -prune \ -o -path ./lib/ansible/modules/cloud/vmware -prune \
-o -path ./lib/ansible/modules/cloud/rackspace -prune \ -o -path ./lib/ansible/modules/cloud/rackspace -prune \
-o -path ./lib/ansible/modules/cloud/ovirt -prune \ -o -path ./lib/ansible/modules/cloud/ovirt -prune \
-o -path ./lib/ansible/modules/cloud/openstack -prune \ -o -path ./lib/ansible/modules/cloud/openstack -prune \
-o -path ./lib/ansible/modules/cloud/misc -prune \ -o -path ./lib/ansible/modules/cloud/misc -prune \
-o -path ./lib/ansible/modules/cloud/google -prune \ -o -path ./lib/ansible/modules/cloud/google -prune \
-o -path ./lib/ansible/modules/cloud/docker -prune \
-o -path ./lib/ansible/modules/cloud/digital_ocean -prune \
-o -path ./lib/ansible/modules/cloud/cloudstack -prune \ -o -path ./lib/ansible/modules/cloud/cloudstack -prune \
-o -path ./lib/ansible/modules/cloud/centurylink -prune \ -o -path ./lib/ansible/modules/cloud/centurylink -prune \
-o -path ./lib/ansible/modules/cloud/amazon -prune \ -o -path ./lib/ansible/modules/cloud/amazon -prune \
-o -name '*.py' -type f -size +0c -exec egrep -HL 'from __future__ import (?absolute_import, division, print_function)?' '{}' '+') -o -name '*.py' -type f -size +0c -exec egrep -HL 'from __future__ import (?absolute_import, division, print_function)?' '{}' '+')
# Ordered by approximate work, lowest to highest
# cloud/misc
# cloud/google
# identity
# cloud/source_control
# cloud/centurylink
# database ;; break up
# net-tools
# cloud/rackspace
# cloud/vmware
# files
# cloud/openstack
# monitoring
# cloud/notification
# cloud/cloudstack
# cloud/ovirt
# cloud/packaging ;; breakup
# cloud/amazon
# network ;; break up
### TODO: ### TODO:
### - contrib/
### - module_utils ### - module_utils
### - contrib/
if test -n "$metaclass1" -o -n "$metaclass2" -o -n "$metaclass3" ; then if test -n "$metaclass1" -o -n "$metaclass2" -o -n "$metaclass3" ; then

View file

@ -194,7 +194,6 @@ lib/ansible/modules/cloud/vmware/vsphere_guest.py
lib/ansible/modules/cloud/webfaction/webfaction_app.py lib/ansible/modules/cloud/webfaction/webfaction_app.py
lib/ansible/modules/cloud/webfaction/webfaction_db.py lib/ansible/modules/cloud/webfaction/webfaction_db.py
lib/ansible/modules/cloud/webfaction/webfaction_domain.py lib/ansible/modules/cloud/webfaction/webfaction_domain.py
lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py
lib/ansible/modules/cloud/webfaction/webfaction_site.py lib/ansible/modules/cloud/webfaction/webfaction_site.py
lib/ansible/modules/clustering/consul_acl.py lib/ansible/modules/clustering/consul_acl.py
lib/ansible/modules/clustering/consul_kv.py lib/ansible/modules/clustering/consul_kv.py
@ -233,10 +232,8 @@ lib/ansible/modules/messaging/rabbitmq_binding.py
lib/ansible/modules/messaging/rabbitmq_exchange.py lib/ansible/modules/messaging/rabbitmq_exchange.py
lib/ansible/modules/messaging/rabbitmq_parameter.py lib/ansible/modules/messaging/rabbitmq_parameter.py
lib/ansible/modules/messaging/rabbitmq_plugin.py lib/ansible/modules/messaging/rabbitmq_plugin.py
lib/ansible/modules/messaging/rabbitmq_policy.py
lib/ansible/modules/messaging/rabbitmq_queue.py lib/ansible/modules/messaging/rabbitmq_queue.py
lib/ansible/modules/messaging/rabbitmq_user.py lib/ansible/modules/messaging/rabbitmq_user.py
lib/ansible/modules/messaging/rabbitmq_vhost.py
lib/ansible/modules/monitoring/airbrake_deployment.py lib/ansible/modules/monitoring/airbrake_deployment.py
lib/ansible/modules/monitoring/bigpanda.py lib/ansible/modules/monitoring/bigpanda.py
lib/ansible/modules/monitoring/boundary_meter.py lib/ansible/modules/monitoring/boundary_meter.py