mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07: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:
parent
6f69cd4501
commit
1ee08c0f06
47 changed files with 416 additions and 848 deletions
|
@ -1,20 +1,13 @@
|
|||
#!/usr/bin/python
|
||||
# -*- 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',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
@ -193,6 +186,7 @@ import traceback
|
|||
from distutils.version import LooseVersion
|
||||
|
||||
try:
|
||||
# Imported as a dependency for dopy
|
||||
import six
|
||||
HAS_SIX = True
|
||||
except ImportError:
|
||||
|
@ -479,5 +473,6 @@ def main():
|
|||
except (DoError, Exception) as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,20 +1,12 @@
|
|||
#!/usr/bin/python
|
||||
# -*- 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',
|
||||
'status': ['preview'],
|
||||
|
@ -118,9 +110,9 @@ id:
|
|||
import json
|
||||
import os
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
|
||||
|
||||
|
@ -338,12 +330,11 @@ def main():
|
|||
)
|
||||
try:
|
||||
handle_request(module)
|
||||
except DOBlockStorageException:
|
||||
e = get_exception()
|
||||
module.fail_json(msg=e.message)
|
||||
except KeyError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg='Unable to load %s' % e.message)
|
||||
except DOBlockStorageException as e:
|
||||
module.fail_json(msg=e.message, exception=traceback.format_exc())
|
||||
except KeyError as e:
|
||||
module.fail_json(msg='Unable to load %s' % e.message, exception=traceback.format_exc())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
#!/usr/bin/python
|
||||
# -*- 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',
|
||||
'status': ['stableinterface'],
|
||||
'supported_by': 'community'}
|
||||
|
@ -96,6 +89,7 @@ except ImportError as e:
|
|||
HAS_DOPY = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
class JsonfyMixIn(object):
|
||||
|
@ -244,7 +238,8 @@ def main():
|
|||
try:
|
||||
core(module)
|
||||
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__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2015, Patrick F. Marques <patrickfmarques@gmail.com>
|
||||
#
|
||||
# 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/>.
|
||||
# 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
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'status': ['preview'],
|
||||
'supported_by': 'community',
|
||||
'metadata_version': '1.0'}
|
||||
|
@ -124,11 +115,10 @@ data:
|
|||
'''
|
||||
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
|
||||
from ansible.module_utils.basic import env_fallback
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import env_fallback
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
|
||||
|
||||
|
@ -216,28 +206,27 @@ def core(module):
|
|||
state = module.params['state']
|
||||
ip = module.params['ip']
|
||||
droplet_id = module.params['droplet_id']
|
||||
region = module.params['region']
|
||||
|
||||
rest = Rest(module, {'Authorization': 'Bearer {0}'.format(api_token),
|
||||
'Content-type': 'application/json'})
|
||||
|
||||
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
|
||||
result = associate_floating_ips(module, rest)
|
||||
associate_floating_ips(module, rest)
|
||||
else:
|
||||
result = create_floating_ips(module, rest)
|
||||
create_floating_ips(module, rest)
|
||||
|
||||
elif state in ('absent'):
|
||||
response = rest.delete("floating_ips/{0}".format(ip))
|
||||
status_code = response.status_code
|
||||
json = response.json
|
||||
json_data = response.json
|
||||
if status_code == 204:
|
||||
module.exit_json(changed=True)
|
||||
elif status_code == 404:
|
||||
module.exit_json(changed=False)
|
||||
else:
|
||||
module.exit_json(changed=False, data=json)
|
||||
module.exit_json(changed=False, data=json_data)
|
||||
|
||||
|
||||
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))
|
||||
status_code = response.status_code
|
||||
json = response.json
|
||||
json_data = response.json
|
||||
if status_code == 200:
|
||||
return response.json['floating_ip']
|
||||
return json_data['floating_ip']
|
||||
else:
|
||||
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):
|
||||
|
@ -263,14 +252,14 @@ def assign_floating_id_to_droplet(module, rest):
|
|||
|
||||
response = rest.post("floating_ips/{0}/actions".format(ip), data=payload)
|
||||
status_code = response.status_code
|
||||
json = response.json
|
||||
json_data = response.json
|
||||
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:
|
||||
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):
|
||||
|
@ -295,12 +284,12 @@ def create_floating_ips(module, rest):
|
|||
|
||||
response = rest.post("floating_ips", data=payload)
|
||||
status_code = response.status_code
|
||||
json = response.json
|
||||
json_data = response.json
|
||||
if status_code == 202:
|
||||
module.exit_json(changed=True, data=response.json)
|
||||
module.exit_json(changed=True, data=json_data)
|
||||
else:
|
||||
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():
|
||||
|
@ -329,5 +318,6 @@ def main():
|
|||
|
||||
core(module)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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/>.
|
||||
# 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
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
@ -182,5 +175,6 @@ def main():
|
|||
except (DoError, Exception) as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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/>.
|
||||
# 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
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
@ -280,5 +273,6 @@ def main():
|
|||
except Exception as e:
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -4,22 +4,11 @@
|
|||
# (c) 2014, Joshua Conner <joshua.conner@gmail.com>
|
||||
# (c) 2014, Pavel Antonov <antonov@adwz.ru>
|
||||
#
|
||||
# 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/>.
|
||||
# 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
|
||||
|
||||
######################################################################
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['deprecated'],
|
||||
|
@ -524,11 +513,6 @@ EXAMPLES = '''
|
|||
syslog-tag: myservice
|
||||
'''
|
||||
|
||||
HAS_DOCKER_PY = True
|
||||
DEFAULT_DOCKER_API_VERSION = None
|
||||
DEFAULT_TIMEOUT_SECONDS = 60
|
||||
|
||||
import sys
|
||||
import json
|
||||
import os
|
||||
import shlex
|
||||
|
@ -543,9 +527,12 @@ try:
|
|||
import docker.utils
|
||||
import docker.errors
|
||||
from requests.exceptions import RequestException
|
||||
HAS_DOCKER_PY = True
|
||||
except ImportError:
|
||||
HAS_DOCKER_PY = False
|
||||
|
||||
DEFAULT_DOCKER_API_VERSION = None
|
||||
DEFAULT_TIMEOUT_SECONDS = 60
|
||||
if HAS_DOCKER_PY:
|
||||
try:
|
||||
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_TIMEOUT_SECONDS = docker.client.DEFAULT_TIMEOUT_SECONDS
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def _human_to_bytes(number):
|
||||
suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
|
||||
|
@ -1979,8 +1968,6 @@ def main():
|
|||
except RequestException as e:
|
||||
module.fail_json(changed=manager.has_changed(), msg=repr(e))
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright 2016 Red Hat | Ansible
|
||||
#
|
||||
# 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/>.
|
||||
# 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
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright 2016 Red Hat | Ansible
|
||||
#
|
||||
# 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/>.
|
||||
# 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
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
@ -250,11 +240,10 @@ image:
|
|||
type: dict
|
||||
sample: {}
|
||||
'''
|
||||
import re
|
||||
import os
|
||||
import re
|
||||
|
||||
from ansible.module_utils.docker_common import (HAS_DOCKER_PY_2, AnsibleDockerClient,
|
||||
DockerBaseClass)
|
||||
from ansible.module_utils.docker_common import HAS_DOCKER_PY_2, AnsibleDockerClient, DockerBaseClass
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
try:
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright 2016 Red Hat | Ansible
|
||||
#
|
||||
# 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/>.
|
||||
# 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
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
@ -161,15 +151,15 @@ images:
|
|||
]
|
||||
'''
|
||||
|
||||
from ansible.module_utils.docker_common import *
|
||||
|
||||
try:
|
||||
from docker import auth
|
||||
from docker import utils
|
||||
except ImportError:
|
||||
# missing docker-py handled in docker_common
|
||||
pass
|
||||
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass
|
||||
|
||||
|
||||
class ImageManager(DockerBaseClass):
|
||||
|
||||
def __init__(self, client, results):
|
||||
|
@ -242,8 +232,5 @@ def main():
|
|||
client.module.exit_json(**results)
|
||||
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -4,21 +4,10 @@
|
|||
# Chris Houseknecht, <house@redhat.com>
|
||||
# James Tanner, <jtanner@redhat.com>
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
|
@ -142,9 +131,12 @@ login_results:
|
|||
'''
|
||||
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
|
||||
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):
|
||||
|
@ -333,8 +325,6 @@ def main():
|
|||
del results['actions']
|
||||
client.module.exit_json(**results)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright 2016 Red Hat | Ansible
|
||||
#
|
||||
# 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/>.
|
||||
# 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
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
@ -161,14 +151,12 @@ facts:
|
|||
sample: {}
|
||||
'''
|
||||
|
||||
from ansible.module_utils.docker_common import *
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass, HAS_DOCKER_PY_2
|
||||
|
||||
try:
|
||||
from docker import utils
|
||||
if HAS_DOCKER_PY_2:
|
||||
from docker.types import Ulimit, IPAMPool, IPAMConfig
|
||||
else:
|
||||
from docker.utils.types import Ulimit
|
||||
from docker.types import IPAMPool, IPAMConfig
|
||||
except:
|
||||
# missing docker-py handled in ansible.module_utils.docker
|
||||
pass
|
||||
|
@ -390,8 +378,6 @@ def main():
|
|||
cm = DockerNetworkManager(client)
|
||||
client.module.exit_json(**cm.results)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright 2016 Red Hat | Ansible
|
||||
#
|
||||
# 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/>.
|
||||
# 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
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
@ -152,7 +142,6 @@ except ImportError:
|
|||
# missing docker-py handled in ansible.module_utils.docker
|
||||
pass
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass
|
||||
from ansible.module_utils._text import to_native, to_bytes
|
||||
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright 2016 Red Hat | Ansible
|
||||
#
|
||||
# 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/>.
|
||||
# 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
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
@ -449,38 +439,37 @@ actions:
|
|||
type: string
|
||||
'''
|
||||
|
||||
HAS_YAML = True
|
||||
HAS_YAML_EXC = None
|
||||
HAS_COMPOSE = True
|
||||
HAS_COMPOSE_EXC = None
|
||||
MINIMUM_COMPOSE_VERSION = '1.7.0'
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
from contextlib import contextmanager
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
try:
|
||||
import yaml
|
||||
HAS_YAML = True
|
||||
HAS_YAML_EXC = None
|
||||
except ImportError as exc:
|
||||
HAS_YAML = False
|
||||
HAS_YAML_EXC = str(exc)
|
||||
|
||||
from distutils.version import LooseVersion
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
try:
|
||||
from compose import __version__ as compose_version
|
||||
from compose.project import ProjectError
|
||||
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.const import DEFAULT_TIMEOUT
|
||||
HAS_COMPOSE = True
|
||||
HAS_COMPOSE_EXC = None
|
||||
MINIMUM_COMPOSE_VERSION = '1.7.0'
|
||||
|
||||
except ImportError as exc:
|
||||
HAS_COMPOSE = False
|
||||
HAS_COMPOSE_EXC = str(exc)
|
||||
DEFAULT_TIMEOUT = 10
|
||||
|
||||
from ansible.module_utils.docker_common import *
|
||||
from contextlib import contextmanager
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass
|
||||
|
||||
|
||||
AUTH_PARAM_MAPPING = {
|
||||
|
|
|
@ -2,21 +2,12 @@
|
|||
# coding: utf-8
|
||||
#
|
||||
# Copyright 2017 Red Hat | Ansible, Alex Grönholm <alex.gronholm@nextday.fi>
|
||||
#
|
||||
# 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/>.
|
||||
# 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
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
@ -112,8 +103,8 @@ except ImportError:
|
|||
# missing docker-py handled in ansible.module_utils.docker
|
||||
pass
|
||||
|
||||
from ansible.module_utils.six import iteritems, text_type
|
||||
from ansible.module_utils.docker_common import DockerBaseClass, AnsibleDockerClient
|
||||
from ansible.module_utils.six import iteritems, text_type
|
||||
|
||||
|
||||
class TaskParameters(DockerBaseClass):
|
||||
|
@ -258,5 +249,6 @@ def main():
|
|||
cm = DockerVolumeManager(client)
|
||||
client.module.exit_json(**cm.results)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,31 +1,19 @@
|
|||
#!/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:
|
||||
# * Andy Baker
|
||||
# * 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 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
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
@ -113,8 +101,12 @@ EXAMPLES = '''
|
|||
|
||||
import xmlrpclib
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
module = AnsibleModule(
|
||||
|
@ -202,7 +194,6 @@ def main():
|
|||
result = result
|
||||
)
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,28 +1,16 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Create a webfaction database using Ansible and the Webfaction API
|
||||
#
|
||||
# ------------------------------------------
|
||||
#
|
||||
# (c) Quentin Stafford-Fraser 2015, with contributions gratefully acknowledged from:
|
||||
# * Andy Baker
|
||||
# * Federico Tarantini
|
||||
#
|
||||
# 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/>.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
#
|
||||
# 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',
|
||||
'status': ['preview'],
|
||||
|
@ -103,11 +91,14 @@ EXAMPLES = '''
|
|||
|
||||
'''
|
||||
|
||||
import socket
|
||||
import xmlrpclib
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
module = AnsibleModule(
|
||||
|
@ -203,7 +194,6 @@ def main():
|
|||
result = result
|
||||
)
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,26 +1,13 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Create Webfaction domains and subdomains using Ansible and the Webfaction API
|
||||
#
|
||||
# ------------------------------------------
|
||||
#
|
||||
# (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
|
||||
#
|
||||
# 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 Webfaction domains and subdomains using Ansible and the Webfaction API
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
@ -95,11 +82,14 @@ EXAMPLES = '''
|
|||
|
||||
'''
|
||||
|
||||
import socket
|
||||
import xmlrpclib
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
module = AnsibleModule(
|
||||
|
@ -175,7 +165,6 @@ def main():
|
|||
result = result
|
||||
)
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,25 +1,13 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Create webfaction mailbox using Ansible and the Webfaction API
|
||||
#
|
||||
# ------------------------------------------
|
||||
# (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
|
||||
#
|
||||
# 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 webfaction mailbox using Ansible and the Webfaction API
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
@ -81,11 +69,14 @@ EXAMPLES = '''
|
|||
login_password={{webfaction_passwd}}
|
||||
'''
|
||||
|
||||
import socket
|
||||
import xmlrpclib
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
module = AnsibleModule(
|
||||
|
@ -142,7 +133,5 @@ def main():
|
|||
module.exit_json(changed=True, result=result)
|
||||
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,26 +1,12 @@
|
|||
#!/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
|
||||
#
|
||||
# ------------------------------------------
|
||||
#
|
||||
# (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/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
@ -113,8 +99,12 @@ EXAMPLES = '''
|
|||
import socket
|
||||
import xmlrpclib
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
module = AnsibleModule(
|
||||
|
@ -213,8 +203,5 @@ def main():
|
|||
)
|
||||
|
||||
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue