summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2017-02-02 13:45:22 -0600
committerMatt Clay <matt@mystile.com>2017-02-02 11:45:22 -0800
commit829c0b8f6284ec37e36f1454d7d3640415239cb2 (patch)
tree16e03a45026881df4c30c0a8a18e1451dbfd601e
parent1718719d779038751b96ffc7300efe6e5c9cee37 (diff)
downloadansible-829c0b8f6284ec37e36f1454d7d3640415239cb2.tar.gz
Update validate-modules (#20932)
* Update validate-modules * Validates ANSIBLE_METADATA * Ensures imports happen after documentation vars * Some pep8 cleanup * Clean up some left over unneeded code * Update modules for new module guidelines and validate-modules checks * Update imports for ec2_vpc_route_table and ec2_vpc_nat_gateway
-rw-r--r--lib/ansible/modules/cloud/amazon/cloudfront_facts.py1
-rw-r--r--lib/ansible/modules/cloud/amazon/ec2_vpc_igw_facts.py15
-rw-r--r--lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py23
-rw-r--r--lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway_facts.py15
-rw-r--r--lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py11
-rw-r--r--lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py14
-rwxr-xr-xlib/ansible/modules/cloud/amazon/ecs_ecr.py32
-rwxr-xr-xlib/ansible/modules/cloud/amazon/iam_role.py4
-rw-r--r--lib/ansible/modules/cloud/amazon/lambda_alias.py15
-rw-r--r--lib/ansible/modules/cloud/amazon/lambda_event.py20
-rw-r--r--lib/ansible/modules/cloud/amazon/lambda_facts.py21
-rw-r--r--lib/ansible/modules/cloud/dimensiondata/dimensiondata_network.py4
-rw-r--r--lib/ansible/modules/cloud/google/gce_snapshot.py8
-rw-r--r--lib/ansible/modules/cloud/google/gcpubsub.py4
-rw-r--r--lib/ansible/modules/cloud/google/gcpubsub_facts.py4
-rw-r--r--lib/ansible/modules/cloud/misc/xenserver_facts.py19
-rw-r--r--lib/ansible/modules/cloud/openstack/_nova_compute.py25
-rw-r--r--lib/ansible/modules/cloud/openstack/_nova_keypair.py17
-rw-r--r--lib/ansible/modules/cloud/openstack/_quantum_floating_ip.py27
-rw-r--r--lib/ansible/modules/cloud/openstack/_quantum_floating_ip_associate.py25
-rw-r--r--lib/ansible/modules/cloud/openstack/_quantum_network.py21
-rw-r--r--lib/ansible/modules/cloud/openstack/_quantum_router.py21
-rw-r--r--lib/ansible/modules/cloud/openstack/_quantum_router_gateway.py22
-rw-r--r--lib/ansible/modules/cloud/openstack/_quantum_router_interface.py20
-rw-r--r--lib/ansible/modules/cloud/openstack/_quantum_subnet.py21
-rw-r--r--lib/ansible/modules/cloud/openstack/os_auth.py15
-rw-r--r--lib/ansible/modules/cloud/openstack/os_client_config.py6
-rw-r--r--lib/ansible/modules/cloud/openstack/os_flavor_facts.py21
-rw-r--r--lib/ansible/modules/cloud/openstack/os_floating_ip.py21
-rw-r--r--lib/ansible/modules/cloud/openstack/os_group.py13
-rw-r--r--lib/ansible/modules/cloud/openstack/os_image.py12
-rw-r--r--lib/ansible/modules/cloud/openstack/os_image_facts.py12
-rw-r--r--lib/ansible/modules/cloud/openstack/os_ironic.py15
-rw-r--r--lib/ansible/modules/cloud/openstack/os_ironic_inspect.py16
-rw-r--r--lib/ansible/modules/cloud/openstack/os_ironic_node.py16
-rw-r--r--lib/ansible/modules/cloud/openstack/os_keypair.py14
-rw-r--r--lib/ansible/modules/cloud/openstack/os_keystone_domain.py14
-rw-r--r--lib/ansible/modules/cloud/openstack/os_keystone_domain_facts.py14
-rw-r--r--lib/ansible/modules/cloud/openstack/os_keystone_role.py13
-rw-r--r--lib/ansible/modules/cloud/openstack/os_keystone_service.py16
-rw-r--r--lib/ansible/modules/cloud/openstack/os_network.py17
-rw-r--r--lib/ansible/modules/cloud/openstack/os_networks_facts.py13
-rw-r--r--lib/ansible/modules/cloud/openstack/os_nova_flavor.py12
-rw-r--r--lib/ansible/modules/cloud/openstack/os_nova_host_aggregate.py19
-rw-r--r--lib/ansible/modules/cloud/openstack/os_object.py13
-rw-r--r--lib/ansible/modules/cloud/openstack/os_port.py13
-rw-r--r--lib/ansible/modules/cloud/openstack/os_port_facts.py12
-rw-r--r--lib/ansible/modules/cloud/openstack/os_project.py18
-rw-r--r--lib/ansible/modules/cloud/openstack/os_project_facts.py14
-rw-r--r--lib/ansible/modules/cloud/openstack/os_quota.py19
-rw-r--r--lib/ansible/modules/cloud/openstack/os_recordset.py17
-rw-r--r--lib/ansible/modules/cloud/openstack/os_router.py17
-rw-r--r--lib/ansible/modules/cloud/openstack/os_security_group.py13
-rw-r--r--lib/ansible/modules/cloud/openstack/os_security_group_rule.py13
-rw-r--r--lib/ansible/modules/cloud/openstack/os_server.py16
-rw-r--r--lib/ansible/modules/cloud/openstack/os_server_actions.py17
-rw-r--r--lib/ansible/modules/cloud/openstack/os_server_facts.py18
-rw-r--r--lib/ansible/modules/cloud/openstack/os_server_group.py13
-rw-r--r--lib/ansible/modules/cloud/openstack/os_server_volume.py16
-rw-r--r--lib/ansible/modules/cloud/openstack/os_stack.py17
-rw-r--r--lib/ansible/modules/cloud/openstack/os_subnet.py14
-rw-r--r--lib/ansible/modules/cloud/openstack/os_subnets_facts.py13
-rw-r--r--lib/ansible/modules/cloud/openstack/os_user.py14
-rw-r--r--lib/ansible/modules/cloud/openstack/os_user_facts.py14
-rw-r--r--lib/ansible/modules/cloud/openstack/os_user_group.py13
-rw-r--r--lib/ansible/modules/cloud/openstack/os_user_role.py19
-rw-r--r--lib/ansible/modules/cloud/openstack/os_volume.py14
-rw-r--r--lib/ansible/modules/cloud/openstack/os_zone.py17
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_affinity_groups.py37
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_affinity_labels.py33
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_affinity_labels_facts.py23
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_auth.py21
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_clusters.py35
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_clusters_facts.py21
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_datacenters.py37
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_datacenters_facts.py21
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_disks.py64
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_external_providers.py35
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_external_providers_facts.py23
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_groups.py35
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_groups_facts.py21
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_host_networks.py41
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_host_pm.py35
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_hosts.py41
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_hosts_facts.py21
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_mac_pools.py33
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_networks.py37
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_networks_facts.py21
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_nics.py37
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_nics_facts.py25
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_permissions.py41
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_permissions_facts.py33
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_quotas.py37
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_quotas_facts.py25
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py43
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_storage_domains_facts.py21
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_tags.py35
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_tags_facts.py25
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_templates.py43
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_templates_facts.py21
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_users.py33
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_users_facts.py21
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_vmpools.py39
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_vmpools_facts.py21
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_vms.py47
-rw-r--r--lib/ansible/modules/cloud/ovirt/ovirt_vms_facts.py21
-rw-r--r--lib/ansible/modules/cloud/packet/packet_device.py4
-rw-r--r--lib/ansible/modules/cloud/packet/packet_sshkey.py4
-rw-r--r--lib/ansible/modules/cloud/univention/udm_dns_record.py42
-rw-r--r--lib/ansible/modules/cloud/univention/udm_dns_zone.py18
-rw-r--r--lib/ansible/modules/cloud/univention/udm_group.py18
-rw-r--r--lib/ansible/modules/cloud/univention/udm_share.py18
-rw-r--r--lib/ansible/modules/cloud/univention/udm_user.py24
-rw-r--r--lib/ansible/modules/cloud/vmware/vsphere_guest.py36
-rw-r--r--lib/ansible/modules/clustering/pacemaker_cluster.py9
-rw-r--r--lib/ansible/modules/crypto/openssl_privatekey.py26
-rw-r--r--lib/ansible/modules/crypto/openssl_publickey.py26
-rw-r--r--lib/ansible/modules/database/misc/elasticsearch_plugin.py38
-rw-r--r--lib/ansible/modules/database/misc/kibana_plugin.py40
-rw-r--r--lib/ansible/modules/files/archive.py43
-rw-r--r--lib/ansible/modules/files/find.py14
-rw-r--r--lib/ansible/modules/files/replace.py10
-rw-r--r--lib/ansible/modules/monitoring/datadog_event.py14
-rw-r--r--lib/ansible/modules/monitoring/logicmonitor.py99
-rw-r--r--lib/ansible/modules/monitoring/logicmonitor_facts.py92
-rw-r--r--lib/ansible/modules/monitoring/monit.py4
-rw-r--r--lib/ansible/modules/network/basics/get_url.py9
-rw-r--r--lib/ansible/modules/network/eos/eos_banner.py4
-rw-r--r--lib/ansible/modules/network/eos/eos_user.py4
-rw-r--r--lib/ansible/modules/network/ldap_attr.py24
-rw-r--r--lib/ansible/modules/network/ldap_entry.py28
-rw-r--r--lib/ansible/modules/network/lldp.py5
-rw-r--r--lib/ansible/modules/network/netvisor/pn_cluster.py5
-rw-r--r--lib/ansible/modules/network/netvisor/pn_ospf.py3
-rw-r--r--lib/ansible/modules/network/netvisor/pn_ospfarea.py5
-rw-r--r--lib/ansible/modules/network/netvisor/pn_show.py5
-rw-r--r--lib/ansible/modules/network/netvisor/pn_trunk.py6
-rw-r--r--lib/ansible/modules/network/netvisor/pn_vlag.py5
-rw-r--r--lib/ansible/modules/network/netvisor/pn_vlan.py5
-rw-r--r--lib/ansible/modules/network/netvisor/pn_vrouter.py5
-rw-r--r--lib/ansible/modules/network/netvisor/pn_vrouterbgp.py4
-rw-r--r--lib/ansible/modules/network/netvisor/pn_vrouterif.py4
-rw-r--r--lib/ansible/modules/network/netvisor/pn_vrouterlbif.py4
-rw-r--r--lib/ansible/modules/network/omapi_host.py4
-rw-r--r--lib/ansible/modules/packaging/language/easy_install.py6
-rw-r--r--lib/ansible/modules/packaging/language/maven_artifact.py31
-rw-r--r--lib/ansible/modules/packaging/os/homebrew_tap.py4
-rw-r--r--lib/ansible/modules/packaging/os/layman.py8
-rw-r--r--lib/ansible/modules/packaging/os/openbsd_pkg.py17
-rw-r--r--lib/ansible/modules/packaging/os/pulp_repo.py20
-rw-r--r--lib/ansible/modules/packaging/os/sorcery.py4
-rw-r--r--lib/ansible/modules/packaging/os/swdepot.py7
-rw-r--r--lib/ansible/modules/packaging/os/yum.py58
-rw-r--r--lib/ansible/modules/packaging/os/yum_repository.py12
-rw-r--r--lib/ansible/modules/packaging/os/zypper.py6
-rw-r--r--lib/ansible/modules/remote_management/ipmi/ipmi_boot.py15
-rw-r--r--lib/ansible/modules/remote_management/ipmi/ipmi_power.py15
-rw-r--r--lib/ansible/modules/remote_management/stacki/stacki_host.py4
-rw-r--r--lib/ansible/modules/source_control/github_hooks.py23
-rw-r--r--lib/ansible/modules/storage/netapp/netapp_e_volume.py3
-rw-r--r--lib/ansible/modules/system/gconftool2.py11
-rw-r--r--lib/ansible/modules/system/kernel_blacklist.py7
-rw-r--r--lib/ansible/modules/system/pam_limits.py11
-rw-r--r--lib/ansible/modules/system/pamd.py9
-rw-r--r--lib/ansible/modules/system/puppet.py27
-rw-r--r--lib/ansible/modules/system/solaris_zone.py11
-rw-r--r--lib/ansible/modules/system/timezone.py19
-rw-r--r--lib/ansible/modules/utilities/logic/wait_for.py39
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py4
-rw-r--r--lib/ansible/modules/web_infrastructure/jenkins_plugin.py26
-rw-r--r--lib/ansible/modules/web_infrastructure/jenkins_script.py4
-rw-r--r--lib/ansible/modules/web_infrastructure/letsencrypt.py13
-rw-r--r--lib/ansible/modules/web_infrastructure/supervisorctl.py6
-rw-r--r--lib/ansible/modules/windows/win_shortcut.py4
-rw-r--r--test/sanity/validate-modules/schema.py10
-rw-r--r--test/sanity/validate-modules/test_validate_modules_regex.py31
-rw-r--r--test/sanity/validate-modules/utils.py28
-rwxr-xr-xtest/sanity/validate-modules/validate-modules178
178 files changed, 1850 insertions, 1784 deletions
diff --git a/lib/ansible/modules/cloud/amazon/cloudfront_facts.py b/lib/ansible/modules/cloud/amazon/cloudfront_facts.py
index affd6540fc..cf012ad02b 100644
--- a/lib/ansible/modules/cloud/amazon/cloudfront_facts.py
+++ b/lib/ansible/modules/cloud/amazon/cloudfront_facts.py
@@ -15,6 +15,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
'version': '1.0'}
DOCUMENTATION = '''
diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_igw_facts.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_igw_facts.py
index b94f6f14e8..911508d8d7 100644
--- a/lib/ansible/modules/cloud/amazon/ec2_vpc_igw_facts.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_igw_facts.py
@@ -13,12 +13,9 @@
# You should have received a copy of the GNU General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
-# import module snippets
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ec2 import ec2_argument_spec, get_aws_connection_info
-from ansible.module_utils.ec2 import boto3_conn, camel_dict_to_snake_dict
-from ansible.module_utils.ec2 import ansible_dict_to_boto3_filter_list, HAS_BOTO3
-
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
DOCUMENTATION = '''
---
@@ -100,6 +97,12 @@ changed:
sample: "false"
'''
+# import module snippets
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import ec2_argument_spec, get_aws_connection_info
+from ansible.module_utils.ec2 import boto3_conn, camel_dict_to_snake_dict
+from ansible.module_utils.ec2 import ansible_dict_to_boto3_filter_list, HAS_BOTO3
+
try:
import botocore
except ImportError:
diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py
index 9a5d9a20af..6d11831482 100644
--- a/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py
@@ -14,18 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# import module snippets
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ec2 import ec2_argument_spec, get_aws_connection_info, boto3_conn
-
-import datetime
-import random
-import re
-import time
-
-from dateutil.tz import tzutc
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -221,6 +209,16 @@ nat_gateway_addresses:
]
'''
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import ec2_argument_spec, get_aws_connection_info, boto3_conn
+
+import datetime
+import random
+import re
+import time
+
+from dateutil.tz import tzutc
+
try:
import botocore
import boto3
@@ -228,7 +226,6 @@ try:
except ImportError:
HAS_BOTO3 = False
-
DRY_RUN_GATEWAYS = [
{
"nat_gateway_id": "nat-123456789",
diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway_facts.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway_facts.py
index 75ca30c0e2..a4ececc932 100644
--- a/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway_facts.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway_facts.py
@@ -14,12 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import json
-
-# import module snippets
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ec2 import ec2_argument_spec, get_aws_connection_info, boto3_conn
-from ansible.module_utils.ec2 import ansible_dict_to_boto3_filter_list, HAS_BOTO3
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
DOCUMENTATION = '''
module: ec2_vpc_nat_gateway_facts
@@ -90,6 +87,12 @@ result:
type: list
'''
+import json
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import ec2_argument_spec, get_aws_connection_info, boto3_conn
+from ansible.module_utils.ec2 import ansible_dict_to_boto3_filter_list, HAS_BOTO3
+
try:
import botocore
except ImportError:
diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py
index 7a6bee6fa0..effc61026e 100644
--- a/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py
@@ -13,12 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
-import re
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ec2 import AnsibleAWSError, connect_to_aws, ec2_argument_spec, get_aws_connection_info
-
-
ANSIBLE_METADATA = {'status': ['stableinterface'],
'supported_by': 'committer',
'version': '1.0'}
@@ -120,6 +114,11 @@ EXAMPLES = '''
'''
+import re
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import AnsibleAWSError, connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
try:
import boto.ec2
import boto.vpc
diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py
index aa79a0844f..200ee03495 100644
--- a/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py
@@ -13,12 +13,9 @@
# You should have received a copy of the GNU General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
-# import module snippets
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ec2 import ec2_argument_spec, get_aws_connection_info
-from ansible.module_utils.ec2 import boto3_conn, camel_dict_to_snake_dict
-from ansible.module_utils.ec2 import ansible_dict_to_boto3_filter_list, HAS_BOTO3
-
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
DOCUMENTATION = '''
---
@@ -102,6 +99,11 @@ changed:
sample: "false"
'''
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import ec2_argument_spec, get_aws_connection_info
+from ansible.module_utils.ec2 import boto3_conn, camel_dict_to_snake_dict
+from ansible.module_utils.ec2 import ansible_dict_to_boto3_filter_list, HAS_BOTO3
+
try:
import botocore
except ImportError:
diff --git a/lib/ansible/modules/cloud/amazon/ecs_ecr.py b/lib/ansible/modules/cloud/amazon/ecs_ecr.py
index 2bb9807210..579fcb43b4 100755
--- a/lib/ansible/modules/cloud/amazon/ecs_ecr.py
+++ b/lib/ansible/modules/cloud/amazon/ecs_ecr.py
@@ -14,23 +14,6 @@
# 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 print_function
-
-import json
-import time
-import inspect
-
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
-
-try:
- import boto3
- from botocore.exceptions import ClientError
-
- HAS_BOTO3 = True
-except ImportError:
- HAS_BOTO3 = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -139,6 +122,21 @@ repository:
repositoryUri: 999999999999.dkr.ecr.us-east-1.amazonaws.com/ecr-test-1484664090
'''
+import json
+import time
+import inspect
+
+from ansible.module_utils.basic import *
+from ansible.module_utils.ec2 import *
+
+try:
+ import boto3
+ from botocore.exceptions import ClientError
+
+ HAS_BOTO3 = True
+except ImportError:
+ HAS_BOTO3 = False
+
def boto_exception(err):
'''boto error message handler'''
diff --git a/lib/ansible/modules/cloud/amazon/iam_role.py b/lib/ansible/modules/cloud/amazon/iam_role.py
index 40c51026bd..41c5c41e0d 100755
--- a/lib/ansible/modules/cloud/amazon/iam_role.py
+++ b/lib/ansible/modules/cloud/amazon/iam_role.py
@@ -14,6 +14,10 @@
# 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'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = '''
---
module: iam_role
diff --git a/lib/ansible/modules/cloud/amazon/lambda_alias.py b/lib/ansible/modules/cloud/amazon/lambda_alias.py
index a06880e410..82e25bb4a9 100644
--- a/lib/ansible/modules/cloud/amazon/lambda_alias.py
+++ b/lib/ansible/modules/cloud/amazon/lambda_alias.py
@@ -14,14 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-try:
- import boto3
- from botocore.exceptions import ClientError, ParamValidationError, MissingParametersError
- HAS_BOTO3 = True
-except ImportError:
- HAS_BOTO3 = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -154,6 +146,13 @@ name:
sample: dev
'''
+try:
+ import boto3
+ from botocore.exceptions import ClientError, ParamValidationError, MissingParametersError
+ HAS_BOTO3 = True
+except ImportError:
+ HAS_BOTO3 = False
+
class AWSConnection:
"""
diff --git a/lib/ansible/modules/cloud/amazon/lambda_event.py b/lib/ansible/modules/cloud/amazon/lambda_event.py
index acb057a8de..2d6b924347 100644
--- a/lib/ansible/modules/cloud/amazon/lambda_event.py
+++ b/lib/ansible/modules/cloud/amazon/lambda_event.py
@@ -14,16 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import sys
-
-try:
- import boto3
- from botocore.exceptions import ClientError, ParamValidationError, MissingParametersError
- HAS_BOTO3 = True
-except ImportError:
- HAS_BOTO3 = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -119,6 +109,16 @@ lambda_stream_events:
type: list
'''
+import sys
+
+try:
+ import boto3
+ from botocore.exceptions import ClientError, ParamValidationError, MissingParametersError
+ HAS_BOTO3 = True
+except ImportError:
+ HAS_BOTO3 = False
+
+
# ---------------------------------------------------------------------------------------------------
#
# Helper Functions & classes
diff --git a/lib/ansible/modules/cloud/amazon/lambda_facts.py b/lib/ansible/modules/cloud/amazon/lambda_facts.py
index ac3db66794..fa465df151 100644
--- a/lib/ansible/modules/cloud/amazon/lambda_facts.py
+++ b/lib/ansible/modules/cloud/amazon/lambda_facts.py
@@ -14,17 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import datetime
-import sys
-
-try:
- import boto3
- from botocore.exceptions import ClientError
- HAS_BOTO3 = True
-except ImportError:
- HAS_BOTO3 = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -106,6 +95,16 @@ lambda_facts.function.TheName:
type: dict
'''
+import datetime
+import sys
+
+try:
+ import boto3
+ from botocore.exceptions import ClientError
+ HAS_BOTO3 = True
+except ImportError:
+ HAS_BOTO3 = False
+
def fix_return(node):
"""
diff --git a/lib/ansible/modules/cloud/dimensiondata/dimensiondata_network.py b/lib/ansible/modules/cloud/dimensiondata/dimensiondata_network.py
index 8a00ed725e..f0dda2638e 100644
--- a/lib/ansible/modules/cloud/dimensiondata/dimensiondata_network.py
+++ b/lib/ansible/modules/cloud/dimensiondata/dimensiondata_network.py
@@ -22,6 +22,10 @@
# - Adam Friedman <tintoy@tintoy.io>
#
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = '''
---
module: dimensiondata_network
diff --git a/lib/ansible/modules/cloud/google/gce_snapshot.py b/lib/ansible/modules/cloud/google/gce_snapshot.py
index 62985f90ce..6d0e50043e 100644
--- a/lib/ansible/modules/cloud/google/gce_snapshot.py
+++ b/lib/ansible/modules/cloud/google/gce_snapshot.py
@@ -16,8 +16,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.gce import gce_connect
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
DOCUMENTATION = '''
---
@@ -129,6 +130,9 @@ snapshots_absent:
sample: "[disk0-example-snapshot, disk1-example-snapshot]"
'''
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.gce import gce_connect
+
try:
from libcloud.compute.types import Provider
_ = Provider.GCE
diff --git a/lib/ansible/modules/cloud/google/gcpubsub.py b/lib/ansible/modules/cloud/google/gcpubsub.py
index 5004b290a9..8d0c4136b8 100644
--- a/lib/ansible/modules/cloud/google/gcpubsub.py
+++ b/lib/ansible/modules/cloud/google/gcpubsub.py
@@ -16,6 +16,10 @@
# 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'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = '''
---
module: gcpubsub
diff --git a/lib/ansible/modules/cloud/google/gcpubsub_facts.py b/lib/ansible/modules/cloud/google/gcpubsub_facts.py
index 165f8a100a..d2aa9fad59 100644
--- a/lib/ansible/modules/cloud/google/gcpubsub_facts.py
+++ b/lib/ansible/modules/cloud/google/gcpubsub_facts.py
@@ -16,6 +16,10 @@
# 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'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = '''
---
module: gcpubsub_facts
diff --git a/lib/ansible/modules/cloud/misc/xenserver_facts.py b/lib/ansible/modules/cloud/misc/xenserver_facts.py
index 03dcdc2af7..947df0ec57 100644
--- a/lib/ansible/modules/cloud/misc/xenserver_facts.py
+++ b/lib/ansible/modules/cloud/misc/xenserver_facts.py
@@ -32,15 +32,6 @@ author:
options: {}
'''
-import platform
-
-HAVE_XENAPI = False
-try:
- import XenAPI
- HAVE_XENAPI = True
-except ImportError:
- pass
-
EXAMPLES = '''
- name: Gather facts from xenserver
xenserver:
@@ -60,6 +51,16 @@ EXAMPLES = '''
# }
'''
+import platform
+
+HAVE_XENAPI = False
+try:
+ import XenAPI
+ HAVE_XENAPI = True
+except ImportError:
+ pass
+
+
class XenServerFacts:
def __init__(self):
self.codes = {
diff --git a/lib/ansible/modules/cloud/openstack/_nova_compute.py b/lib/ansible/modules/cloud/openstack/_nova_compute.py
index d305e3b0de..fad08d9536 100644
--- a/lib/ansible/modules/cloud/openstack/_nova_compute.py
+++ b/lib/ansible/modules/cloud/openstack/_nova_compute.py
@@ -17,19 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-import operator
-import os
-import time
-
-try:
- from novaclient.v1_1 import client as nova_client
- from novaclient.v1_1 import floating_ips
- from novaclient import exceptions
- from novaclient import utils
- HAS_NOVACLIENT = True
-except ImportError:
- HAS_NOVACLIENT = False
-
ANSIBLE_METADATA = {'status': ['deprecated'],
'supported_by': 'community',
'version': '1.0'}
@@ -280,6 +267,18 @@ EXAMPLES = '''
flavor_include: Performance
'''
+import operator
+import os
+import time
+
+try:
+ from novaclient.v1_1 import client as nova_client
+ from novaclient.v1_1 import floating_ips
+ from novaclient import exceptions
+ from novaclient import utils
+ HAS_NOVACLIENT = True
+except ImportError:
+ HAS_NOVACLIENT = False
def _delete_server(module, nova):
diff --git a/lib/ansible/modules/cloud/openstack/_nova_keypair.py b/lib/ansible/modules/cloud/openstack/_nova_keypair.py
index 4c5265e3f0..2cfe8f92f4 100644
--- a/lib/ansible/modules/cloud/openstack/_nova_keypair.py
+++ b/lib/ansible/modules/cloud/openstack/_nova_keypair.py
@@ -17,14 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-import time
-try:
- from novaclient.v1_1 import client as nova_client
- from novaclient import exceptions as exc
- HAS_NOVACLIENT = True
-except ImportError:
- HAS_NOVACLIENT = False
-
ANSIBLE_METADATA = {'status': ['deprecated'],
'supported_by': 'community',
'version': '1.0'}
@@ -105,6 +97,15 @@ EXAMPLES = '''
name: ansible_key
'''
+import time
+try:
+ from novaclient.v1_1 import client as nova_client
+ from novaclient import exceptions as exc
+ HAS_NOVACLIENT = True
+except ImportError:
+ HAS_NOVACLIENT = False
+
+
def main():
argument_spec = openstack_argument_spec()
argument_spec.update(dict(
diff --git a/lib/ansible/modules/cloud/openstack/_quantum_floating_ip.py b/lib/ansible/modules/cloud/openstack/_quantum_floating_ip.py
index c6aee1f4eb..82aec2d41e 100644
--- a/lib/ansible/modules/cloud/openstack/_quantum_floating_ip.py
+++ b/lib/ansible/modules/cloud/openstack/_quantum_floating_ip.py
@@ -16,19 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-import time
-
-try:
- from novaclient.v1_1 import client as nova_client
- try:
- from neutronclient.neutron import client
- except ImportError:
- from quantumclient.quantum import client
- from keystoneclient.v2_0 import client as ksclient
- HAVE_DEPS = True
-except ImportError:
- HAVE_DEPS = False
-
ANSIBLE_METADATA = {'status': ['deprecated'],
'supported_by': 'community',
'version': '1.0'}
@@ -110,6 +97,20 @@ EXAMPLES = '''
internal_network_name: internal_network
'''
+import time
+
+try:
+ from novaclient.v1_1 import client as nova_client
+ try:
+ from neutronclient.neutron import client
+ except ImportError:
+ from quantumclient.quantum import client
+ from keystoneclient.v2_0 import client as ksclient
+ HAVE_DEPS = True
+except ImportError:
+ HAVE_DEPS = False
+
+
def _get_ksclient(module, kwargs):
try:
kclient = ksclient.Client(username=kwargs.get('login_username'),
diff --git a/lib/ansible/modules/cloud/openstack/_quantum_floating_ip_associate.py b/lib/ansible/modules/cloud/openstack/_quantum_floating_ip_associate.py
index ca000a0abe..6d48f75c9c 100644
--- a/lib/ansible/modules/cloud/openstack/_quantum_floating_ip_associate.py
+++ b/lib/ansible/modules/cloud/openstack/_quantum_floating_ip_associate.py
@@ -16,18 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-import time
-try:
- from novaclient.v1_1 import client as nova_client
- try:
- from neutronclient.neutron import client
- except ImportError:
- from quantumclient.quantum import client
- from keystoneclient.v2_0 import client as ksclient
- HAVE_DEPS = True
-except ImportError:
- HAVE_DEPS = False
-
ANSIBLE_METADATA = {'status': ['deprecated'],
'supported_by': 'community',
'version': '1.0'}
@@ -100,6 +88,19 @@ EXAMPLES = '''
instance_name: vm1
'''
+import time
+try:
+ from novaclient.v1_1 import client as nova_client
+ try:
+ from neutronclient.neutron import client
+ except ImportError:
+ from quantumclient.quantum import client
+ from keystoneclient.v2_0 import client as ksclient
+ HAVE_DEPS = True
+except ImportError:
+ HAVE_DEPS = False
+
+
def _get_ksclient(module, kwargs):
try:
kclient = ksclient.Client(username=kwargs.get('login_username'),
diff --git a/lib/ansible/modules/cloud/openstack/_quantum_network.py b/lib/ansible/modules/cloud/openstack/_quantum_network.py
index 426e9bd563..3662296a4e 100644
--- a/lib/ansible/modules/cloud/openstack/_quantum_network.py
+++ b/lib/ansible/modules/cloud/openstack/_quantum_network.py
@@ -16,16 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- try:
- from neutronclient.neutron import client
- except ImportError:
- from quantumclient.quantum import client
- from keystoneclient.v2_0 import client as ksclient
- HAVE_DEPS = True
-except ImportError:
- HAVE_DEPS = False
-
ANSIBLE_METADATA = {'status': ['deprecated'],
'supported_by': 'community',
'version': '1.0'}
@@ -139,9 +129,20 @@ EXAMPLES = '''
login_tenant_name: admin
'''
+try:
+ try:
+ from neutronclient.neutron import client
+ except ImportError:
+ from quantumclient.quantum import client
+ from keystoneclient.v2_0 import client as ksclient
+ HAVE_DEPS = True
+except ImportError:
+ HAVE_DEPS = False
+
_os_keystone = None
_os_tenant_id = None
+
def _get_ksclient(module, kwargs):
try:
kclient = ksclient.Client(username=kwargs.get('login_username'),
diff --git a/lib/ansible/modules/cloud/openstack/_quantum_router.py b/lib/ansible/modules/cloud/openstack/_quantum_router.py
index 3ba05c9fde..8431285b7c 100644
--- a/lib/ansible/modules/cloud/openstack/_quantum_router.py
+++ b/lib/ansible/modules/cloud/openstack/_quantum_router.py
@@ -16,16 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- try:
- from neutronclient.neutron import client
- except ImportError:
- from quantumclient.quantum import client
- from keystoneclient.v2_0 import client as ksclient
- HAVE_DEPS = True
-except ImportError:
- HAVE_DEPS = False
-
ANSIBLE_METADATA = {'status': ['deprecated'],
'supported_by': 'community',
'version': '1.0'}
@@ -101,9 +91,20 @@ EXAMPLES = '''
name: router1
'''
+try:
+ try:
+ from neutronclient.neutron import client
+ except ImportError:
+ from quantumclient.quantum import client
+ from keystoneclient.v2_0 import client as ksclient
+ HAVE_DEPS = True
+except ImportError:
+ HAVE_DEPS = False
+
_os_keystone = None
_os_tenant_id = None
+
def _get_ksclient(module, kwargs):
try:
kclient = ksclient.Client(username=kwargs.get('login_username'),
diff --git a/lib/ansible/modules/cloud/openstack/_quantum_router_gateway.py b/lib/ansible/modules/cloud/openstack/_quantum_router_gateway.py
index 1b7c09fb58..0601fb5677 100644
--- a/lib/ansible/modules/cloud/openstack/_quantum_router_gateway.py
+++ b/lib/ansible/modules/cloud/openstack/_quantum_router_gateway.py
@@ -16,16 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- try:
- from neutronclient.neutron import client
- except ImportError:
- from quantumclient.quantum import client
- from keystoneclient.v2_0 import client as ksclient
- HAVE_DEPS = True
-except ImportError:
- HAVE_DEPS = False
-
ANSIBLE_METADATA = {'status': ['deprecated'],
'supported_by': 'community',
'version': '1.0'}
@@ -97,7 +87,19 @@ EXAMPLES = '''
network_name: external_network
'''
+try:
+ try:
+ from neutronclient.neutron import client
+ except ImportError:
+ from quantumclient.quantum import client
+ from keystoneclient.v2_0 import client as ksclient
+ HAVE_DEPS = True
+except ImportError:
+ HAVE_DEPS = False
+
_os_keystone = None
+
+
def _get_ksclient(module, kwargs):
try:
kclient = ksclient.Client(username=kwargs.get('login_username'),
diff --git a/lib/ansible/modules/cloud/openstack/_quantum_router_interface.py b/lib/ansible/modules/cloud/openstack/_quantum_router_interface.py
index 5460f427cb..e1af1daf99 100644
--- a/lib/ansible/modules/cloud/openstack/_quantum_router_interface.py
+++ b/lib/ansible/modules/cloud/openstack/_quantum_router_interface.py
@@ -16,16 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- try:
- from neutronclient.neutron import client
- except ImportError:
- from quantumclient.quantum import client
- from keystoneclient.v2_0 import client as ksclient
- HAVE_DEPS = True
-except ImportError:
- HAVE_DEPS = False
-
ANSIBLE_METADATA = {'status': ['deprecated'],
'supported_by': 'community',
'version': '1.0'}
@@ -103,10 +93,20 @@ EXAMPLES = '''
subnet_name: t1subnet
'''
+try:
+ try:
+ from neutronclient.neutron import client
+ except ImportError:
+ from quantumclient.quantum import client
+ from keystoneclient.v2_0 import client as ksclient
+ HAVE_DEPS = True
+except ImportError:
+ HAVE_DEPS = False
_os_keystone = None
_os_tenant_id = None
+
def _get_ksclient(module, kwargs):
try:
kclient = ksclient.Client(username=kwargs.get('login_username'),
diff --git a/lib/ansible/modules/cloud/openstack/_quantum_subnet.py b/lib/ansible/modules/cloud/openstack/_quantum_subnet.py
index 51cc8eb467..b794875523 100644
--- a/lib/ansible/modules/cloud/openstack/_quantum_subnet.py
+++ b/lib/ansible/modules/cloud/openstack/_quantum_subnet.py
@@ -16,16 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- try:
- from neutronclient.neutron import client
- except ImportError:
- from quantumclient.quantum import client
- from keystoneclient.v2_0 import client as ksclient
- HAVE_DEPS = True
-except ImportError:
- HAVE_DEPS = False
-
ANSIBLE_METADATA = {'status': ['deprecated'],
'supported_by': 'community',
'version': '1.0'}
@@ -139,10 +129,21 @@ EXAMPLES = '''
cidr: 192.168.0.0/24
'''
+try:
+ try:
+ from neutronclient.neutron import client
+ except ImportError:
+ from quantumclient.quantum import client
+ from keystoneclient.v2_0 import client as ksclient
+ HAVE_DEPS = True
+except ImportError:
+ HAVE_DEPS = False
+
_os_keystone = None
_os_tenant_id = None
_os_network_id = None
+
def _get_ksclient(module, kwargs):
try:
kclient = ksclient.Client(username=kwargs.get('login_username'),
diff --git a/lib/ansible/modules/cloud/openstack/os_auth.py b/lib/ansible/modules/cloud/openstack/os_auth.py
index 1d1aadb9f2..5c8b68c534 100644
--- a/lib/ansible/modules/cloud/openstack/os_auth.py
+++ b/lib/ansible/modules/cloud/openstack/os_auth.py
@@ -15,13 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- from shade import meta
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -50,6 +43,14 @@ EXAMPLES = '''
var: service_catalog
'''
+try:
+ import shade
+ from shade import meta
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+
def main():
argument_spec = openstack_full_argument_spec()
diff --git a/lib/ansible/modules/cloud/openstack/os_client_config.py b/lib/ansible/modules/cloud/openstack/os_client_config.py
index aef425ccf3..3ec10cd19f 100644
--- a/lib/ansible/modules/cloud/openstack/os_client_config.py
+++ b/lib/ansible/modules/cloud/openstack/os_client_config.py
@@ -15,9 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-import os_client_config
-from os_client_config import exceptions
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -56,6 +53,9 @@ EXAMPLES = '''
- mordred
'''
+import os_client_config
+from os_client_config import exceptions
+
def main():
module = AnsibleModule(argument_spec=dict(
diff --git a/lib/ansible/modules/cloud/openstack/os_flavor_facts.py b/lib/ansible/modules/cloud/openstack/os_flavor_facts.py
index c6e938b63b..8489eaa517 100644
--- a/lib/ansible/modules/cloud/openstack/os_flavor_facts.py
+++ b/lib/ansible/modules/cloud/openstack/os_flavor_facts.py
@@ -15,17 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-import re
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-from distutils.version import StrictVersion
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -185,6 +174,16 @@ openstack_flavors:
sample: true
'''
+import re
+
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+from distutils.version import StrictVersion
+
def main():
argument_spec = openstack_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/openstack/os_floating_ip.py b/lib/ansible/modules/cloud/openstack/os_floating_ip.py
index 16c217c2d8..c014494db0 100644
--- a/lib/ansible/modules/cloud/openstack/os_floating_ip.py
+++ b/lib/ansible/modules/cloud/openstack/os_floating_ip.py
@@ -15,17 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- from shade import meta
-
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-from distutils.version import StrictVersion
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -141,6 +130,16 @@ EXAMPLES = '''
server: cattle001
'''
+try:
+ import shade
+ from shade import meta
+
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+from distutils.version import StrictVersion
+
def _get_floating_ip(cloud, floating_ip_address):
f_ips = cloud.search_floating_ips(
diff --git a/lib/ansible/modules/cloud/openstack/os_group.py b/lib/ansible/modules/cloud/openstack/os_group.py
index 2347efb483..e864e87054 100644
--- a/lib/ansible/modules/cloud/openstack/os_group.py
+++ b/lib/ansible/modules/cloud/openstack/os_group.py
@@ -14,13 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -101,6 +94,12 @@ group:
sample: "default"
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def _system_state_change(state, description, group):
if state == 'present' and not group:
diff --git a/lib/ansible/modules/cloud/openstack/os_image.py b/lib/ansible/modules/cloud/openstack/os_image.py
index 7632672555..d86181f32a 100644
--- a/lib/ansible/modules/cloud/openstack/os_image.py
+++ b/lib/ansible/modules/cloud/openstack/os_image.py
@@ -17,12 +17,6 @@
# along with this software. If not, see <http://www.gnu.org/licenses/>.
#TODO(mordred): we need to support "location"(v1) and "locations"(v2)
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
@@ -121,6 +115,12 @@ EXAMPLES = '''
distro: ubuntu
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def main():
diff --git a/lib/ansible/modules/cloud/openstack/os_image_facts.py b/lib/ansible/modules/cloud/openstack/os_image_facts.py
index a810ad467f..138defba35 100644
--- a/lib/ansible/modules/cloud/openstack/os_image_facts.py
+++ b/lib/ansible/modules/cloud/openstack/os_image_facts.py
@@ -15,12 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -136,6 +130,12 @@ openstack_image:
type: int
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def main():
diff --git a/lib/ansible/modules/cloud/openstack/os_ironic.py b/lib/ansible/modules/cloud/openstack/os_ironic.py
index 2296082f32..7a6f2fdd4d 100644
--- a/lib/ansible/modules/cloud/openstack/os_ironic.py
+++ b/lib/ansible/modules/cloud/openstack/os_ironic.py
@@ -16,13 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-import jsonpatch
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -152,6 +145,14 @@ EXAMPLES = '''
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+import jsonpatch
+
def _parse_properties(module):
p = module.params['properties']
diff --git a/lib/ansible/modules/cloud/openstack/os_ironic_inspect.py b/lib/ansible/modules/cloud/openstack/os_ironic_inspect.py
index 2b095fccbc..630f1bfb1e 100644
--- a/lib/ansible/modules/cloud/openstack/os_ironic_inspect.py
+++ b/lib/ansible/modules/cloud/openstack/os_ironic_inspect.py
@@ -16,14 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-from distutils.version import StrictVersion
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -100,6 +92,14 @@ EXAMPLES = '''
name: "testnode1"
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+from distutils.version import StrictVersion
+
def _choose_id_value(module):
if module.params['uuid']:
diff --git a/lib/ansible/modules/cloud/openstack/os_ironic_node.py b/lib/ansible/modules/cloud/openstack/os_ironic_node.py
index 8e7d44a240..6773bdcf29 100644
--- a/lib/ansible/modules/cloud/openstack/os_ironic_node.py
+++ b/lib/ansible/modules/cloud/openstack/os_ironic_node.py
@@ -16,14 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-from distutils.version import StrictVersion
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -133,6 +125,14 @@ os_ironic_node:
delegate_to: localhost
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+from distutils.version import StrictVersion
+
def _choose_id_value(module):
if module.params['uuid']:
diff --git a/lib/ansible/modules/cloud/openstack/os_keypair.py b/lib/ansible/modules/cloud/openstack/os_keypair.py
index 8651901a2a..ace1e7aba0 100644
--- a/lib/ansible/modules/cloud/openstack/os_keypair.py
+++ b/lib/ansible/modules/cloud/openstack/os_keypair.py
@@ -17,14 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -98,6 +90,12 @@ private_key:
type: string
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def _system_state_change(module, keypair):
state = module.params['state']
diff --git a/lib/ansible/modules/cloud/openstack/os_keystone_domain.py b/lib/ansible/modules/cloud/openstack/os_keystone_domain.py
index dce64f80eb..aad0a97bf6 100644
--- a/lib/ansible/modules/cloud/openstack/os_keystone_domain.py
+++ b/lib/ansible/modules/cloud/openstack/os_keystone_domain.py
@@ -14,13 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -105,6 +98,13 @@ id:
sample: "474acfe5-be34-494c-b339-50f06aa143e4"
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+
def _needs_update(module, domain):
if module.params['description'] is not None and \
domain.description != module.params['description']:
diff --git a/lib/ansible/modules/cloud/openstack/os_keystone_domain_facts.py b/lib/ansible/modules/cloud/openstack/os_keystone_domain_facts.py
index 9e36341521..01659846a4 100644
--- a/lib/ansible/modules/cloud/openstack/os_keystone_domain_facts.py
+++ b/lib/ansible/modules/cloud/openstack/os_keystone_domain_facts.py
@@ -14,13 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -99,6 +92,13 @@ openstack_domains:
type: bool
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+
def main():
argument_spec = openstack_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/openstack/os_keystone_role.py b/lib/ansible/modules/cloud/openstack/os_keystone_role.py
index db5b0027c0..0ab07f16ba 100644
--- a/lib/ansible/modules/cloud/openstack/os_keystone_role.py
+++ b/lib/ansible/modules/cloud/openstack/os_keystone_role.py
@@ -14,13 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -79,6 +72,12 @@ role:
sample: "demo"
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def _system_state_change(state, role):
if state == 'present' and not role:
diff --git a/lib/ansible/modules/cloud/openstack/os_keystone_service.py b/lib/ansible/modules/cloud/openstack/os_keystone_service.py
index d23f288162..e864a8a81d 100644
--- a/lib/ansible/modules/cloud/openstack/os_keystone_service.py
+++ b/lib/ansible/modules/cloud/openstack/os_keystone_service.py
@@ -14,14 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-from distutils.version import StrictVersion
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -115,6 +107,14 @@ id:
sample: "3292f020780b4d5baf27ff7e1d224c44"
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+from distutils.version import StrictVersion
+
def _needs_update(module, service):
if service.enabled != module.params['enabled']:
diff --git a/lib/ansible/modules/cloud/openstack/os_network.py b/lib/ansible/modules/cloud/openstack/os_network.py
index 240fee7518..34793e414c 100644
--- a/lib/ansible/modules/cloud/openstack/os_network.py
+++ b/lib/ansible/modules/cloud/openstack/os_network.py
@@ -16,15 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-from distutils.version import StrictVersion
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -163,6 +154,14 @@ network:
sample: 101
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+from distutils.version import StrictVersion
+
def main():
argument_spec = openstack_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/openstack/os_networks_facts.py b/lib/ansible/modules/cloud/openstack/os_networks_facts.py
index f39580321e..f813b4f093 100644
--- a/lib/ansible/modules/cloud/openstack/os_networks_facts.py
+++ b/lib/ansible/modules/cloud/openstack/os_networks_facts.py
@@ -15,12 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -126,6 +120,13 @@ openstack_networks:
type: boolean
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+
def main():
argument_spec = openstack_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/openstack/os_nova_flavor.py b/lib/ansible/modules/cloud/openstack/os_nova_flavor.py
index 0f9f5afa91..b02c246483 100644
--- a/lib/ansible/modules/cloud/openstack/os_nova_flavor.py
+++ b/lib/ansible/modules/cloud/openstack/os_nova_flavor.py
@@ -15,12 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -157,6 +151,12 @@ flavor:
sample: true
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def _system_state_change(module, flavor):
state = module.params['state']
diff --git a/lib/ansible/modules/cloud/openstack/os_nova_host_aggregate.py b/lib/ansible/modules/cloud/openstack/os_nova_host_aggregate.py
index a5dfa27467..8e9a4d72ae 100644
--- a/lib/ansible/modules/cloud/openstack/os_nova_host_aggregate.py
+++ b/lib/ansible/modules/cloud/openstack/os_nova_host_aggregate.py
@@ -14,13 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-from distutils.version import StrictVersion
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
DOCUMENTATION = '''
---
@@ -80,6 +76,15 @@ RETURN = '''
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+from distutils.version import StrictVersion
+
+
def _needs_update(module, aggregate):
new_metadata = (module.params['metadata'] or {})
new_metadata['availability_zone'] = module.params['availability_zone']
diff --git a/lib/ansible/modules/cloud/openstack/os_object.py b/lib/ansible/modules/cloud/openstack/os_object.py
index 4cadae5a03..58dc69f3d5 100644
--- a/lib/ansible/modules/cloud/openstack/os_object.py
+++ b/lib/ansible/modules/cloud/openstack/os_object.py
@@ -16,13 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -79,6 +72,12 @@ EXAMPLES = '''
container: config
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def process_object(
cloud_obj, container, name, filename, container_access, **kwargs):
diff --git a/lib/ansible/modules/cloud/openstack/os_port.py b/lib/ansible/modules/cloud/openstack/os_port.py
index 56625a63f5..183440f671 100644
--- a/lib/ansible/modules/cloud/openstack/os_port.py
+++ b/lib/ansible/modules/cloud/openstack/os_port.py
@@ -15,13 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -211,6 +204,12 @@ admin_state_up:
type: bool
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def _needs_update(module, port, cloud):
"""Check for differences in the updatable values.
diff --git a/lib/ansible/modules/cloud/openstack/os_port_facts.py b/lib/ansible/modules/cloud/openstack/os_port_facts.py
index 0da37d88ef..9d26ef5f1c 100644
--- a/lib/ansible/modules/cloud/openstack/os_port_facts.py
+++ b/lib/ansible/modules/cloud/openstack/os_port_facts.py
@@ -15,12 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -198,6 +192,12 @@ openstack_ports:
sample: "51fce036d7984ba6af4f6c849f65ef00"
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def main():
argument_spec = openstack_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/openstack/os_project.py b/lib/ansible/modules/cloud/openstack/os_project.py
index 7f75c14925..f58c82698f 100644
--- a/lib/ansible/modules/cloud/openstack/os_project.py
+++ b/lib/ansible/modules/cloud/openstack/os_project.py
@@ -14,15 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-from distutils.version import StrictVersion
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -114,6 +105,15 @@ project:
sample: True
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+from distutils.version import StrictVersion
+
+
def _needs_update(module, project):
keys = ('description', 'enabled')
for key in keys:
diff --git a/lib/ansible/modules/cloud/openstack/os_project_facts.py b/lib/ansible/modules/cloud/openstack/os_project_facts.py
index f4e3168214..b1cc30a5fe 100644
--- a/lib/ansible/modules/cloud/openstack/os_project_facts.py
+++ b/lib/ansible/modules/cloud/openstack/os_project_facts.py
@@ -14,13 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -118,6 +111,13 @@ openstack_projects:
type: bool
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+
def main():
argument_spec = openstack_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/openstack/os_quota.py b/lib/ansible/modules/cloud/openstack/os_quota.py
index 407afe0e6a..9047d4fed2 100644
--- a/lib/ansible/modules/cloud/openstack/os_quota.py
+++ b/lib/ansible/modules/cloud/openstack/os_quota.py
@@ -14,14 +14,10 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-import sys
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
DOCUMENTATION = '''
---
@@ -278,6 +274,15 @@ openstack_quotas:
'''
+import sys
+
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+
def _get_volume_quotas(cloud, project):
return cloud.get_volume_quotas(project)
diff --git a/lib/ansible/modules/cloud/openstack/os_recordset.py b/lib/ansible/modules/cloud/openstack/os_recordset.py
index 2a13a94fde..ad18363834 100644
--- a/lib/ansible/modules/cloud/openstack/os_recordset.py
+++ b/lib/ansible/modules/cloud/openstack/os_recordset.py
@@ -14,15 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-from distutils.version import StrictVersion
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -139,6 +130,14 @@ recordset:
sample: ['10.0.0.1']
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+from distutils.version import StrictVersion
+
def _system_state_change(state, records, description, ttl, zone, recordset):
if state == 'present':
diff --git a/lib/ansible/modules/cloud/openstack/os_router.py b/lib/ansible/modules/cloud/openstack/os_router.py
index d4a6b28bc8..34da32d733 100644
--- a/lib/ansible/modules/cloud/openstack/os_router.py
+++ b/lib/ansible/modules/cloud/openstack/os_router.py
@@ -13,15 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-from distutils.version import StrictVersion
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -178,6 +169,14 @@ router:
type: list
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+from distutils.version import StrictVersion
+
def _needs_update(cloud, module, router, network, internal_subnet_ids):
"""Decide if the given router needs an update.
diff --git a/lib/ansible/modules/cloud/openstack/os_security_group.py b/lib/ansible/modules/cloud/openstack/os_security_group.py
index 3ed5dfceb7..a611544500 100644
--- a/lib/ansible/modules/cloud/openstack/os_security_group.py
+++ b/lib/ansible/modules/cloud/openstack/os_security_group.py
@@ -16,13 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -70,6 +63,12 @@ EXAMPLES = '''
description: updated description for the foo security group
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def _needs_update(module, secgroup):
"""Check for differences in the updatable values.
diff --git a/lib/ansible/modules/cloud/openstack/os_security_group_rule.py b/lib/ansible/modules/cloud/openstack/os_security_group_rule.py
index 3379d16040..3b75562750 100644
--- a/lib/ansible/modules/cloud/openstack/os_security_group_rule.py
+++ b/lib/ansible/modules/cloud/openstack/os_security_group_rule.py
@@ -16,13 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -168,6 +161,12 @@ security_group_id:
type: string
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def _ports_match(protocol, module_min, module_max, rule_min, rule_max):
"""
diff --git a/lib/ansible/modules/cloud/openstack/os_server.py b/lib/ansible/modules/cloud/openstack/os_server.py
index 850409f8ba..5857de0ee6 100644
--- a/lib/ansible/modules/cloud/openstack/os_server.py
+++ b/lib/ansible/modules/cloud/openstack/os_server.py
@@ -18,15 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- from shade import meta
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -379,6 +370,13 @@ EXAMPLES = '''
- music
'''
+try:
+ import shade
+ from shade import meta
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def _exit_hostvars(module, cloud, server, changed=True):
hostvars = meta.get_hostvars_from_server(cloud, server)
diff --git a/lib/ansible/modules/cloud/openstack/os_server_actions.py b/lib/ansible/modules/cloud/openstack/os_server_actions.py
index ae37e358a8..6fe0898d15 100644
--- a/lib/ansible/modules/cloud/openstack/os_server_actions.py
+++ b/lib/ansible/modules/cloud/openstack/os_server_actions.py
@@ -16,15 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- from shade import meta
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -86,6 +77,14 @@ EXAMPLES = '''
timeout: 200
'''
+try:
+ import shade
+ from shade import meta
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+
_action_map = {'stop': 'SHUTOFF',
'start': 'ACTIVE',
'pause': 'PAUSED',
diff --git a/lib/ansible/modules/cloud/openstack/os_server_facts.py b/lib/ansible/modules/cloud/openstack/os_server_facts.py
index efeb778069..efb6fd8327 100644
--- a/lib/ansible/modules/cloud/openstack/os_server_facts.py
+++ b/lib/ansible/modules/cloud/openstack/os_server_facts.py
@@ -15,15 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-import fnmatch
-
-try:
- import shade
- from shade import meta
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -66,6 +57,15 @@ EXAMPLES = '''
var: openstack_servers
'''
+import fnmatch
+
+try:
+ import shade
+ from shade import meta
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def main():
diff --git a/lib/ansible/modules/cloud/openstack/os_server_group.py b/lib/ansible/modules/cloud/openstack/os_server_group.py
index 0103fef867..d67e69aa37 100644
--- a/lib/ansible/modules/cloud/openstack/os_server_group.py
+++ b/lib/ansible/modules/cloud/openstack/os_server_group.py
@@ -15,13 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -114,6 +107,12 @@ user_id:
type: string
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def _system_state_change(state, server_group):
if state == 'present' and not server_group:
diff --git a/lib/ansible/modules/cloud/openstack/os_server_volume.py b/lib/ansible/modules/cloud/openstack/os_server_volume.py
index a6549649d8..369c727c8e 100644
--- a/lib/ansible/modules/cloud/openstack/os_server_volume.py
+++ b/lib/ansible/modules/cloud/openstack/os_server_volume.py
@@ -16,15 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- from shade import meta
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -77,6 +68,13 @@ EXAMPLES = '''
device: /dev/vdb
'''
+try:
+ import shade
+ from shade import meta
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def _system_state_change(state, device):
"""Check if system state would change."""
diff --git a/lib/ansible/modules/cloud/openstack/os_stack.py b/lib/ansible/modules/cloud/openstack/os_stack.py
index fc42b62112..b3fb625bd3 100644
--- a/lib/ansible/modules/cloud/openstack/os_stack.py
+++ b/lib/ansible/modules/cloud/openstack/os_stack.py
@@ -17,14 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-from time import sleep
-from distutils.version import StrictVersion
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -157,6 +149,15 @@ stack:
'updated_time': null}"
'''
+from time import sleep
+from distutils.version import StrictVersion
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+
def _create_stack(module, stack, cloud):
try:
stack = cloud.create_stack(module.params['name'],
diff --git a/lib/ansible/modules/cloud/openstack/os_subnet.py b/lib/ansible/modules/cloud/openstack/os_subnet.py
index cdb0a982ea..8c5d396934 100644
--- a/lib/ansible/modules/cloud/openstack/os_subnet.py
+++ b/lib/ansible/modules/cloud/openstack/os_subnet.py
@@ -16,13 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -161,6 +154,13 @@ EXAMPLES = '''
ipv6_address_mode: dhcpv6-stateless
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+
def _can_update(subnet, module, cloud):
"""Check for differences in non-updatable values"""
network_name = module.params['network_name']
diff --git a/lib/ansible/modules/cloud/openstack/os_subnets_facts.py b/lib/ansible/modules/cloud/openstack/os_subnets_facts.py
index b4beedab5a..824ef8647b 100644
--- a/lib/ansible/modules/cloud/openstack/os_subnets_facts.py
+++ b/lib/ansible/modules/cloud/openstack/os_subnets_facts.py
@@ -15,12 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -139,6 +133,13 @@ openstack_subnets:
type: list of dicts
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+
def main():
argument_spec = openstack_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/openstack/os_user.py b/lib/ansible/modules/cloud/openstack/os_user.py
index 341723ba14..bb2fed6a5c 100644
--- a/lib/ansible/modules/cloud/openstack/os_user.py
+++ b/lib/ansible/modules/cloud/openstack/os_user.py
@@ -14,13 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -143,6 +136,13 @@ user:
sample: "demouser"
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+
def _needs_update(params_dict, user):
for k, v in params_dict.items():
if k not in ('password', 'update_password') and user[k] != v:
diff --git a/lib/ansible/modules/cloud/openstack/os_user_facts.py b/lib/ansible/modules/cloud/openstack/os_user_facts.py
index 52af5b8e62..ac40625105 100644
--- a/lib/ansible/modules/cloud/openstack/os_user_facts.py
+++ b/lib/ansible/modules/cloud/openstack/os_user_facts.py
@@ -14,13 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -126,6 +119,13 @@ openstack_users:
type: string
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+
def main():
argument_spec = openstack_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/openstack/os_user_group.py b/lib/ansible/modules/cloud/openstack/os_user_group.py
index 2f39f34679..8f4c47ed8f 100644
--- a/lib/ansible/modules/cloud/openstack/os_user_group.py
+++ b/lib/ansible/modules/cloud/openstack/os_user_group.py
@@ -14,13 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -61,6 +54,12 @@ EXAMPLES = '''
group: demo
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def _system_state_change(state, in_group):
if state == 'present' and not in_group:
diff --git a/lib/ansible/modules/cloud/openstack/os_user_role.py b/lib/ansible/modules/cloud/openstack/os_user_role.py
index 90f7aa2388..132ae88e18 100644
--- a/lib/ansible/modules/cloud/openstack/os_user_role.py
+++ b/lib/ansible/modules/cloud/openstack/os_user_role.py
@@ -14,16 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-from distutils.version import StrictVersion
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -99,6 +89,15 @@ RETURN = '''
#
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+from distutils.version import StrictVersion
+
+
def _system_state_change(state, assignment):
if state == 'present' and not assignment:
return True
diff --git a/lib/ansible/modules/cloud/openstack/os_volume.py b/lib/ansible/modules/cloud/openstack/os_volume.py
index e523e3bebe..778b050ec9 100644
--- a/lib/ansible/modules/cloud/openstack/os_volume.py
+++ b/lib/ansible/modules/cloud/openstack/os_volume.py
@@ -15,14 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -97,6 +89,12 @@ EXAMPLES = '''
display_name: test_volume
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
def _present_volume(module, cloud):
if cloud.volume_exists(module.params['display_name']):
diff --git a/lib/ansible/modules/cloud/openstack/os_zone.py b/lib/ansible/modules/cloud/openstack/os_zone.py
index 6174cb4ecc..c4d063d885 100644
--- a/lib/ansible/modules/cloud/openstack/os_zone.py
+++ b/lib/ansible/modules/cloud/openstack/os_zone.py
@@ -14,15 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
-try:
- import shade
- HAS_SHADE = True
-except ImportError:
- HAS_SHADE = False
-
-from distutils.version import StrictVersion
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -138,6 +129,14 @@ zone:
sample: []
'''
+try:
+ import shade
+ HAS_SHADE = True
+except ImportError:
+ HAS_SHADE = False
+
+from distutils.version import StrictVersion
+
def _system_state_change(state, email, description, ttl, masters, zone):
if state == 'present':
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_affinity_groups.py b/lib/ansible/modules/cloud/ovirt/ovirt_affinity_groups.py
index 76b05d2426..968f4fa18e 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_affinity_groups.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_affinity_groups.py
@@ -19,25 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- check_support,
- create_connection,
- equal,
- ovirt_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -151,6 +132,24 @@ affinity_group:
returned: On success if affinity group is found.
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ check_support,
+ create_connection,
+ equal,
+ ovirt_full_argument_spec,
+ search_by_name,
+)
+
class AffinityGroupsModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_affinity_labels.py b/lib/ansible/modules/cloud/ovirt/ovirt_affinity_labels.py
index 80f7c0f5a8..bf120aa2fa 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_affinity_labels.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_affinity_labels.py
@@ -19,23 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from collections import defaultdict
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- create_connection,
- ovirt_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -109,6 +92,22 @@ affinity_label:
returned: On success if affinity label is found.
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from collections import defaultdict
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ create_connection,
+ ovirt_full_argument_spec,
+)
+
class AffinityLabelsModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_affinity_labels_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_affinity_labels_facts.py
index cab1547eaf..214fd71279 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_affinity_labels_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_affinity_labels_facts.py
@@ -19,18 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import fnmatch
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -100,6 +88,17 @@ ovirt_affinity_labels:
type: list
'''
+import fnmatch
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_auth.py b/lib/ansible/modules/cloud/ovirt/ovirt_auth.py
index 7fed7a2adf..aa82e9a436 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_auth.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_auth.py
@@ -19,17 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4 as sdk
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import check_sdk
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -171,6 +160,16 @@ ovirt_auth:
sample: False
'''
+import traceback
+
+try:
+ import ovirtsdk4 as sdk
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import check_sdk
+
def main():
module = AnsibleModule(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_clusters.py b/lib/ansible/modules/cloud/ovirt/ovirt_clusters.py
index 39c4237b20..cf86dbe6cb 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_clusters.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_clusters.py
@@ -19,24 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- create_connection,
- equal,
- ovirt_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -276,6 +258,23 @@ cluster:
returned: On success if cluster is found.
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ create_connection,
+ equal,
+ ovirt_full_argument_spec,
+ search_by_name,
+)
+
class ClustersModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_clusters_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_clusters_facts.py
index 012eaf9349..9d1e82fa80 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_clusters_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_clusters_facts.py
@@ -19,17 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -73,6 +62,16 @@ ovirt_clusters:
type: list
'''
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_datacenters.py b/lib/ansible/modules/cloud/ovirt/ovirt_datacenters.py
index 7a6e3aa7af..5ff5c414a4 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_datacenters.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_datacenters.py
@@ -19,25 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- check_params,
- create_connection,
- equal,
- ovirt_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -115,6 +96,24 @@ data_center:
returned: "On success if datacenter is found."
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ check_params,
+ create_connection,
+ equal,
+ ovirt_full_argument_spec,
+ search_by_name,
+)
+
class DatacentersModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_datacenters_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_datacenters_facts.py
index e6061ba863..2415ded6b1 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_datacenters_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_datacenters_facts.py
@@ -19,17 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -72,6 +61,16 @@ ovirt_datacenters:
type: list
'''
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_disks.py b/lib/ansible/modules/cloud/ovirt/ovirt_disks.py
index 5c5deb9c73..0adc218697 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_disks.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_disks.py
@@ -19,38 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import os
-import time
-import traceback
-import ssl
-
-from httplib import HTTPSConnection
-
-try:
- from urllib.parse import urlparse
-except ImportError:
- from urlparse import urlparse
-
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- check_params,
- create_connection,
- convert_to_bytes,
- equal,
- follow_link,
- ovirt_full_argument_spec,
- search_by_name,
- wait,
-)
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -212,6 +180,38 @@ disk_attachment:
returned: "On success if disk is found and C(vm_id) or C(vm_name) was passed and VM was found."
'''
+import os
+import time
+import traceback
+import ssl
+
+from httplib import HTTPSConnection
+
+try:
+ from urllib.parse import urlparse
+except ImportError:
+ from urlparse import urlparse
+
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ check_params,
+ create_connection,
+ convert_to_bytes,
+ equal,
+ follow_link,
+ ovirt_full_argument_spec,
+ search_by_name,
+ wait,
+)
+
def _search_by_lun(disks_service, lun_id):
"""
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_external_providers.py b/lib/ansible/modules/cloud/ovirt/ovirt_external_providers.py
index 7af65119da..035da0a9ec 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_external_providers.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_external_providers.py
@@ -19,24 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_params,
- check_sdk,
- create_connection,
- equal,
- ovirt_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -168,6 +150,23 @@ openstack_network_provider:
type: dictionary
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_params,
+ check_sdk,
+ create_connection,
+ equal,
+ ovirt_full_argument_spec,
+)
+
class ExternalProviderModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_external_providers_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_external_providers_facts.py
index d5c96b5228..73b38147fb 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_external_providers_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_external_providers_facts.py
@@ -19,18 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import fnmatch
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -92,6 +80,17 @@ openstack_network_providers:
type: list
'''
+import fnmatch
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+)
+
def _external_provider_service(provider_type, system_service):
if provider_type == 'os_image':
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_groups.py b/lib/ansible/modules/cloud/ovirt/ovirt_groups.py
index 5798eacdfb..02f73a9318 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_groups.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_groups.py
@@ -19,24 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- check_params,
- create_connection,
- equal,
- ovirt_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -107,6 +89,23 @@ group:
returned: On success if group is found.
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ check_params,
+ create_connection,
+ equal,
+ ovirt_full_argument_spec,
+)
+
def _group(connection, module):
groups = connection.system_service().groups_service().list(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_groups_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_groups_facts.py
index 76bf0c6b77..d9c84b4fd6 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_groups_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_groups_facts.py
@@ -19,17 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -72,6 +61,16 @@ ovirt_groups:
type: list
'''
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_host_networks.py b/lib/ansible/modules/cloud/ovirt/ovirt_host_networks.py
index 5bdb7d6938..0d25e7e512 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_host_networks.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_host_networks.py
@@ -19,27 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- create_connection,
- equal,
- get_dict_of_struct,
- get_entity,
- get_link_name,
- ovirt_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -158,6 +137,26 @@ host_nic:
returned: On success if host NIC is found.
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ create_connection,
+ equal,
+ get_dict_of_struct,
+ get_entity,
+ get_link_name,
+ ovirt_full_argument_spec,
+ search_by_name,
+)
+
class HostNetworksModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_host_pm.py b/lib/ansible/modules/cloud/ovirt/ovirt_host_pm.py
index 3117eb2fc5..f2cd4b72a5 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_host_pm.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_host_pm.py
@@ -19,24 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- create_connection,
- equal,
- ovirt_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -131,6 +113,23 @@ agent:
returned: On success if agent is found.
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ create_connection,
+ equal,
+ ovirt_full_argument_spec,
+ search_by_name,
+)
+
class HostModule(BaseModule):
def build_entity(self):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_hosts.py b/lib/ansible/modules/cloud/ovirt/ovirt_hosts.py
index e2e7c29bb7..a07b1cb742 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_hosts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_hosts.py
@@ -19,27 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import time
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-
- from ovirtsdk4.types import HostStatus as hoststate
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- create_connection,
- equal,
- ovirt_full_argument_spec,
- wait,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -178,6 +157,26 @@ host:
returned: On success if host is found.
'''
+import time
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+
+ from ovirtsdk4.types import HostStatus as hoststate
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ create_connection,
+ equal,
+ ovirt_full_argument_spec,
+ wait,
+)
+
class HostsModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_hosts_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_hosts_facts.py
index 48fd1dddfb..6d57ee9d49 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_hosts_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_hosts_facts.py
@@ -19,17 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -74,6 +63,16 @@ ovirt_hosts:
type: list
'''
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_mac_pools.py b/lib/ansible/modules/cloud/ovirt/ovirt_mac_pools.py
index 47561ea4d2..deccaa9af2 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_mac_pools.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_mac_pools.py
@@ -19,23 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- equal,
- create_connection,
- ovirt_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -102,6 +85,22 @@ template:
returned: On success if MAC pool is found.
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ equal,
+ create_connection,
+ ovirt_full_argument_spec,
+)
+
class MACPoolModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_networks.py b/lib/ansible/modules/cloud/ovirt/ovirt_networks.py
index 93923e3c57..838d25ef05 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_networks.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_networks.py
@@ -19,25 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- check_params,
- create_connection,
- equal,
- ovirt_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -121,6 +102,24 @@ network:
returned: "On success if network is found."
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ check_params,
+ create_connection,
+ equal,
+ ovirt_full_argument_spec,
+ search_by_name,
+)
+
class NetworksModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_networks_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_networks_facts.py
index a787c425bc..84fad09ddb 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_networks_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_networks_facts.py
@@ -19,17 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -74,6 +63,16 @@ ovirt_networks:
type: list
'''
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_nics.py b/lib/ansible/modules/cloud/ovirt/ovirt_nics.py
index 98ef13bac2..ce4eabd0ca 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_nics.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_nics.py
@@ -19,25 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- create_connection,
- equal,
- get_link_name,
- ovirt_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -127,6 +108,24 @@ nic:
returned: On success if network interface is found.
'''
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ create_connection,
+ equal,
+ get_link_name,
+ ovirt_full_argument_spec,
+ search_by_name,
+)
+
class VmNicsModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_nics_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_nics_facts.py
index 3f5f71e49e..09918aeba9 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_nics_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_nics_facts.py
@@ -19,19 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import fnmatch
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -78,6 +65,18 @@ ovirt_nics:
type: list
'''
+import fnmatch
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+ search_by_name,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_permissions.py b/lib/ansible/modules/cloud/ovirt/ovirt_permissions.py
index be791549e6..79df8b3044 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_permissions.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_permissions.py
@@ -19,27 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- create_connection,
- equal,
- follow_link,
- get_link_name,
- ovirt_full_argument_spec,
- search_by_attributes,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -144,6 +123,26 @@ permission:
returned: On success if permission is found.
'''
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ create_connection,
+ equal,
+ follow_link,
+ get_link_name,
+ ovirt_full_argument_spec,
+ search_by_attributes,
+ search_by_name,
+)
+
def _objects_service(connection, object_type):
if object_type == 'system':
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_permissions_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_permissions_facts.py
index 7694db54bf..8ed486a27e 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_permissions_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_permissions_facts.py
@@ -19,23 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4 as sdk
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_link_name,
- ovirt_facts_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -90,6 +73,22 @@ ovirt_permissions:
type: list
'''
+import traceback
+
+try:
+ import ovirtsdk4 as sdk
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_link_name,
+ ovirt_facts_full_argument_spec,
+ search_by_name,
+)
+
def _permissions_service(connection, module):
if module.params['user_name']:
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_quotas.py b/lib/ansible/modules/cloud/ovirt/ovirt_quotas.py
index f26c42ecb4..29e0cfed26 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_quotas.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_quotas.py
@@ -19,25 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- create_connection,
- equal,
- get_link_name,
- ovirt_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -145,6 +126,24 @@ quota:
returned: On success if quota is found.
'''
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ create_connection,
+ equal,
+ get_link_name,
+ ovirt_full_argument_spec,
+ search_by_name,
+)
+
class QuotasModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_quotas_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_quotas_facts.py
index 1090d7a852..dcfe34d8f0 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_quotas_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_quotas_facts.py
@@ -19,19 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import fnmatch
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -77,6 +64,18 @@ ovirt_quotas:
type: list
'''
+import fnmatch
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+ search_by_name,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py b/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py
index bb0fe20a5f..ecb6611366 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py
@@ -19,28 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-try:
- import ovirtsdk4.types as otypes
-
- from ovirtsdk4.types import StorageDomainStatus as sdstate
-except ImportError:
- pass
-
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- create_connection,
- equal,
- get_entity,
- ovirt_full_argument_spec,
- search_by_name,
- wait,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -204,6 +182,27 @@ storage_domain:
returned: On success if storage domain is found.
'''
+try:
+ import ovirtsdk4.types as otypes
+
+ from ovirtsdk4.types import StorageDomainStatus as sdstate
+except ImportError:
+ pass
+
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ create_connection,
+ equal,
+ get_entity,
+ ovirt_full_argument_spec,
+ search_by_name,
+ wait,
+)
+
class StorageDomainModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains_facts.py
index e90438b440..c0173b764a 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains_facts.py
@@ -19,17 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -74,6 +63,16 @@ ovirt_storage_domains:
type: list
'''
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_tags.py b/lib/ansible/modules/cloud/ovirt/ovirt_tags.py
index 29f4508f9a..913b78ddb2 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_tags.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_tags.py
@@ -19,24 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- create_connection,
- equal,
- ovirt_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -106,6 +88,23 @@ tag:
returned: On success if tag is found.
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ create_connection,
+ equal,
+ ovirt_full_argument_spec,
+ search_by_name,
+)
+
class TagsModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_tags_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_tags_facts.py
index 78e217906e..b4108878ce 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_tags_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_tags_facts.py
@@ -19,19 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import fnmatch
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -91,6 +78,18 @@ ovirt_tags:
type: list
'''
+import fnmatch
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+ search_by_name,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_templates.py b/lib/ansible/modules/cloud/ovirt/ovirt_templates.py
index faeb00651a..7a9f51f484 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_templates.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_templates.py
@@ -19,28 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import time
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- create_connection,
- equal,
- get_dict_of_struct,
- get_link_name,
- ovirt_full_argument_spec,
- search_by_attributes,
- search_by_name,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -140,6 +118,27 @@ template:
returned: On success if template is found.
'''
+import time
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ create_connection,
+ equal,
+ get_dict_of_struct,
+ get_link_name,
+ ovirt_full_argument_spec,
+ search_by_attributes,
+ search_by_name,
+)
+
class TemplatesModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_templates_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_templates_facts.py
index 8c839ff185..9f948f6dcc 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_templates_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_templates_facts.py
@@ -19,17 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -74,6 +63,16 @@ ovirt_templates:
type: list
'''
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_users.py b/lib/ansible/modules/cloud/ovirt/ovirt_users.py
index 09dbc2a7a3..fbaaaff4c3 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_users.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_users.py
@@ -19,23 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_sdk,
- check_params,
- create_connection,
- ovirt_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -100,6 +83,22 @@ user:
returned: On success if user is found.
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_sdk,
+ check_params,
+ create_connection,
+ ovirt_full_argument_spec,
+)
+
def username(module):
return '{}@{}'.format(module.params['name'], module.params['authz_name'])
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_users_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_users_facts.py
index 6db2684194..b18cc6584b 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_users_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_users_facts.py
@@ -19,17 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -72,6 +61,16 @@ ovirt_users:
type: list
'''
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_vmpools.py b/lib/ansible/modules/cloud/ovirt/ovirt_vmpools.py
index 5147d9c770..9b048b3c18 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_vmpools.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_vmpools.py
@@ -19,26 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_params,
- check_sdk,
- create_connection,
- equal,
- get_link_name,
- ovirt_full_argument_spec,
- wait,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -127,6 +107,25 @@ vm_pool:
returned: On success if VM pool is found.
'''
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_params,
+ check_sdk,
+ create_connection,
+ equal,
+ get_link_name,
+ ovirt_full_argument_spec,
+ wait,
+)
+
class VmPoolsModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_vmpools_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_vmpools_facts.py
index 4d9acda7b9..4a90e71a5c 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_vmpools_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_vmpools_facts.py
@@ -19,17 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -72,6 +61,16 @@ ovirt_vm_pools:
type: list
'''
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_vms.py b/lib/ansible/modules/cloud/ovirt/ovirt_vms.py
index bd380d3914..c4ebc23b82 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_vms.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_vms.py
@@ -19,30 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-try:
- import ovirtsdk4.types as otypes
-except ImportError:
- pass
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- BaseModule,
- check_params,
- check_sdk,
- convert_to_bytes,
- create_connection,
- equal,
- get_entity,
- get_link_name,
- get_id_by_name,
- ovirt_full_argument_spec,
- search_by_name,
- wait,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -454,6 +430,29 @@ vm:
returned: On success if VM is found.
'''
+import traceback
+
+try:
+ import ovirtsdk4.types as otypes
+except ImportError:
+ pass
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ BaseModule,
+ check_params,
+ check_sdk,
+ convert_to_bytes,
+ create_connection,
+ equal,
+ get_entity,
+ get_link_name,
+ get_id_by_name,
+ ovirt_full_argument_spec,
+ search_by_name,
+ wait,
+)
+
class VmsModule(BaseModule):
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_vms_facts.py b/lib/ansible/modules/cloud/ovirt/ovirt_vms_facts.py
index 32d344977a..64358cdf21 100644
--- a/lib/ansible/modules/cloud/ovirt/ovirt_vms_facts.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_vms_facts.py
@@ -19,17 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.ovirt import (
- check_sdk,
- create_connection,
- get_dict_of_struct,
- ovirt_facts_full_argument_spec,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -84,6 +73,16 @@ ovirt_vms:
type: list
'''
+import traceback
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ovirt import (
+ check_sdk,
+ create_connection,
+ get_dict_of_struct,
+ ovirt_facts_full_argument_spec,
+)
+
def main():
argument_spec = ovirt_facts_full_argument_spec(
diff --git a/lib/ansible/modules/cloud/packet/packet_device.py b/lib/ansible/modules/cloud/packet/packet_device.py
index f01d963a6a..25b5136e7d 100644
--- a/lib/ansible/modules/cloud/packet/packet_device.py
+++ b/lib/ansible/modules/cloud/packet/packet_device.py
@@ -18,6 +18,10 @@
# 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'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = '''
---
module: packet_device
diff --git a/lib/ansible/modules/cloud/packet/packet_sshkey.py b/lib/ansible/modules/cloud/packet/packet_sshkey.py
index 0d074a7bea..eda9dd16e0 100644
--- a/lib/ansible/modules/cloud/packet/packet_sshkey.py
+++ b/lib/ansible/modules/cloud/packet/packet_sshkey.py
@@ -16,6 +16,10 @@
# 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'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = '''
---
module: packet_sshkey
diff --git a/lib/ansible/modules/cloud/univention/udm_dns_record.py b/lib/ansible/modules/cloud/univention/udm_dns_record.py
index 120666bede..32f138a5c8 100644
--- a/lib/ansible/modules/cloud/univention/udm_dns_record.py
+++ b/lib/ansible/modules/cloud/univention/udm_dns_record.py
@@ -20,28 +20,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.univention_umc import (
- umc_module_for_add,
- umc_module_for_edit,
- ldap_search,
- base_dn,
- config,
- uldap,
-)
-
-HAVE_UNIVENTION = False
-try:
- from univention.admin.handlers.dns import (
- forward_zone,
- reverse_zone,
- )
- HAVE_UNIVENTION = True
-except ImportError:
- pass
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -103,6 +81,26 @@ EXAMPLES = '''
RETURN = '''# '''
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.univention_umc import (
+ umc_module_for_add,
+ umc_module_for_edit,
+ ldap_search,
+ base_dn,
+ config,
+ uldap,
+)
+
+HAVE_UNIVENTION = False
+try:
+ from univention.admin.handlers.dns import (
+ forward_zone,
+ reverse_zone,
+ )
+ HAVE_UNIVENTION = True
+except ImportError:
+ pass
+
def main():
module = AnsibleModule(
diff --git a/lib/ansible/modules/cloud/univention/udm_dns_zone.py b/lib/ansible/modules/cloud/univention/udm_dns_zone.py
index 2d7bbd0907..51aea85fda 100644
--- a/lib/ansible/modules/cloud/univention/udm_dns_zone.py
+++ b/lib/ansible/modules/cloud/univention/udm_dns_zone.py
@@ -20,16 +20,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.univention_umc import (
- umc_module_for_add,
- umc_module_for_edit,
- ldap_search,
- base_dn,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -119,6 +109,14 @@ EXAMPLES = '''
RETURN = '''# '''
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.univention_umc import (
+ umc_module_for_add,
+ umc_module_for_edit,
+ ldap_search,
+ base_dn,
+)
+
def convert_time(time):
"""Convert a time in seconds into the biggest unit"""
diff --git a/lib/ansible/modules/cloud/univention/udm_group.py b/lib/ansible/modules/cloud/univention/udm_group.py
index 82ef43faef..7b30904bcc 100644
--- a/lib/ansible/modules/cloud/univention/udm_group.py
+++ b/lib/ansible/modules/cloud/univention/udm_group.py
@@ -20,16 +20,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.univention_umc import (
- umc_module_for_add,
- umc_module_for_edit,
- ldap_search,
- base_dn,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -96,6 +86,14 @@ EXAMPLES = '''
RETURN = '''# '''
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.univention_umc import (
+ umc_module_for_add,
+ umc_module_for_edit,
+ ldap_search,
+ base_dn,
+)
+
def main():
module = AnsibleModule(
diff --git a/lib/ansible/modules/cloud/univention/udm_share.py b/lib/ansible/modules/cloud/univention/udm_share.py
index 7cb472c314..f12a49adf8 100644
--- a/lib/ansible/modules/cloud/univention/udm_share.py
+++ b/lib/ansible/modules/cloud/univention/udm_share.py
@@ -20,16 +20,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.univention_umc import (
- umc_module_for_add,
- umc_module_for_edit,
- ldap_search,
- base_dn,
-)
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -389,6 +379,14 @@ EXAMPLES = '''
RETURN = '''# '''
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.univention_umc import (
+ umc_module_for_add,
+ umc_module_for_edit,
+ ldap_search,
+ base_dn,
+)
+
def main():
module = AnsibleModule(
diff --git a/lib/ansible/modules/cloud/univention/udm_user.py b/lib/ansible/modules/cloud/univention/udm_user.py
index dcebf50082..3a4b892fd1 100644
--- a/lib/ansible/modules/cloud/univention/udm_user.py
+++ b/lib/ansible/modules/cloud/univention/udm_user.py
@@ -20,19 +20,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-from datetime import date
-import crypt
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.univention_umc import (
- umc_module_for_add,
- umc_module_for_edit,
- ldap_search,
- base_dn,
-)
-from dateutil.relativedelta import relativedelta
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -356,6 +343,17 @@ EXAMPLES = '''
RETURN = '''# '''
+from datetime import date
+import crypt
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.univention_umc import (
+ umc_module_for_add,
+ umc_module_for_edit,
+ ldap_search,
+ base_dn,
+)
+from dateutil.relativedelta import relativedelta
+
def main():
expiry = date.strftime(date.today() + relativedelta(years=1), "%Y-%m-%d")
diff --git a/lib/ansible/modules/cloud/vmware/vsphere_guest.py b/lib/ansible/modules/cloud/vmware/vsphere_guest.py
index 7a5323c6a8..3c119c3fcb 100644
--- a/lib/ansible/modules/cloud/vmware/vsphere_guest.py
+++ b/lib/ansible/modules/cloud/vmware/vsphere_guest.py
@@ -19,24 +19,6 @@
# TODO:
# Ability to set CPU/Memory reservations
-
-try:
- import json
-except ImportError:
- import simplejson as json
-
-HAS_PYSPHERE = False
-try:
- from pysphere import VIServer, VIProperty, MORTypes
- from pysphere.resources import VimService_services as VI
- from pysphere.vi_task import VITask
- from pysphere import VIException, VIApiException, FaultTypes
- HAS_PYSPHERE = True
-except ImportError:
- pass
-
-import ssl
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -320,6 +302,24 @@ as seen in the VMPowerState-Class of PySphere: http://git.io/vlwOq
force: yes
'''
+try:
+ import json
+except ImportError:
+ import simplejson as json
+
+HAS_PYSPHERE = False
+try:
+ from pysphere import VIServer, VIProperty, MORTypes
+ from pysphere.resources import VimService_services as VI
+ from pysphere.vi_task import VITask
+ from pysphere import VIException, VIApiException, FaultTypes
+ HAS_PYSPHERE = True
+except ImportError:
+ pass
+
+import ssl
+
+
def add_scsi_controller(module, s, config, devices, type="paravirtual", bus_num=0, disk_ctrl_key=1):
# add a scsi controller
scsi_ctrl_spec = config.new_deviceChange()
diff --git a/lib/ansible/modules/clustering/pacemaker_cluster.py b/lib/ansible/modules/clustering/pacemaker_cluster.py
index 1aa7740548..b5f8359d5d 100644
--- a/lib/ansible/modules/clustering/pacemaker_cluster.py
+++ b/lib/ansible/modules/clustering/pacemaker_cluster.py
@@ -16,8 +16,9 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-import time
-from distutils.version import StrictVersion
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
DOCUMENTATION = '''
---
@@ -77,8 +78,12 @@ rc:
type: bool
'''
+import time
+from distutils.version import StrictVersion
+
_PCS_CLUSTER_DOWN="Error: cluster is not currently running on this node"
+
def get_cluster_status(module):
cmd = "pcs cluster status"
rc, out, err = module.run_command(cmd)
diff --git a/lib/ansible/modules/crypto/openssl_privatekey.py b/lib/ansible/modules/crypto/openssl_privatekey.py
index 8f6ea5c70d..087b8b25b0 100644
--- a/lib/ansible/modules/crypto/openssl_privatekey.py
+++ b/lib/ansible/modules/crypto/openssl_privatekey.py
@@ -16,18 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from ansible.module_utils.basic import *
-
-try:
- from OpenSSL import crypto
-except ImportError:
- pyopenssl_found = False
-else:
- pyopenssl_found = True
-
-
-import os
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -120,9 +108,23 @@ filename:
sample: /etc/ssl/private/ansible.com.pem
'''
+from ansible.module_utils.basic import *
+
+try:
+ from OpenSSL import crypto
+except ImportError:
+ pyopenssl_found = False
+else:
+ pyopenssl_found = True
+
+
+import os
+
+
class PrivateKeyError(Exception):
pass
+
class PrivateKey(object):
def __init__(self, module):
diff --git a/lib/ansible/modules/crypto/openssl_publickey.py b/lib/ansible/modules/crypto/openssl_publickey.py
index 1f7424d73b..d4f5824f9a 100644
--- a/lib/ansible/modules/crypto/openssl_publickey.py
+++ b/lib/ansible/modules/crypto/openssl_publickey.py
@@ -16,18 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from ansible.module_utils.basic import *
-
-try:
- from OpenSSL import crypto
-except ImportError:
- pyopenssl_found = False
-else:
- pyopenssl_found = True
-
-
-import os
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -103,9 +91,23 @@ filename:
sample: /etc/ssl/public/ansible.com.pem
'''
+from ansible.module_utils.basic import *
+
+try:
+ from OpenSSL import crypto
+except ImportError:
+ pyopenssl_found = False
+else:
+ pyopenssl_found = True
+
+
+import os
+
+
class PublicKeyError(Exception):
pass
+
class PublicKey(object):
def __init__(self, module):
diff --git a/lib/ansible/modules/database/misc/elasticsearch_plugin.py b/lib/ansible/modules/database/misc/elasticsearch_plugin.py
index d6ade97f91..29ff1a15ab 100644
--- a/lib/ansible/modules/database/misc/elasticsearch_plugin.py
+++ b/lib/ansible/modules/database/misc/elasticsearch_plugin.py
@@ -1,26 +1,22 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-import os
-
-"""
-Ansible module to manage elasticsearch plugins
-(c) 2015, Mathew Davies <thepixeldeveloper@googlemail.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/>.
-"""
+# Ansible module to manage elasticsearch plugins
+# (c) 2015, Mathew Davies <thepixeldeveloper@googlemail.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/>.
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
@@ -103,6 +99,8 @@ EXAMPLES = '''
name: mobz/elasticsearch-head
'''
+import os
+
PACKAGE_STATE_MAP = dict(
present="install",
absent="remove"
diff --git a/lib/ansible/modules/database/misc/kibana_plugin.py b/lib/ansible/modules/database/misc/kibana_plugin.py
index b747a99b7d..6d4aeb14d7 100644
--- a/lib/ansible/modules/database/misc/kibana_plugin.py
+++ b/lib/ansible/modules/database/misc/kibana_plugin.py
@@ -1,27 +1,23 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-"""
-Ansible module to manage elasticsearch shield role
-(c) 2016, Thierno IB. BARRY @barryib
-Sponsored by Polyconseil http://polyconseil.fr.
-
-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/>.
-"""
-
-import os
+# Ansible module to manage elasticsearch shield role
+# (c) 2016, Thierno IB. BARRY @barryib
+# Sponsored by Polyconseil http://polyconseil.fr.
+#
+# 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 = {'status': ['preview'],
'supported_by': 'community',
@@ -130,6 +126,8 @@ state:
type: string
'''
+import os
+
PACKAGE_STATE_MAP = dict(
present="--install",
absent="--remove"
diff --git a/lib/ansible/modules/files/archive.py b/lib/ansible/modules/files/archive.py
index 93ddbe76cd..0f7a3ae90d 100644
--- a/lib/ansible/modules/files/archive.py
+++ b/lib/ansible/modules/files/archive.py
@@ -1,29 +1,23 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# import module snippets
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.pycompat24 import get_exception
-
-"""
-(c) 2016, Ben Doherty <bendohmv@gmail.com>
-Sponsored by Oomph, Inc. http://www.oomphinc.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/>.
-"""
+# (c) 2016, Ben Doherty <bendohmv@gmail.com>
+# Sponsored by Oomph, Inc. http://www.oomphinc.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/>.
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
@@ -125,6 +119,9 @@ import bz2
import filecmp
import zipfile
import tarfile
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.pycompat24 import get_exception
+
def main():
module = AnsibleModule(
diff --git a/lib/ansible/modules/files/find.py b/lib/ansible/modules/files/find.py
index 7d329bc929..465f807001 100644
--- a/lib/ansible/modules/files/find.py
+++ b/lib/ansible/modules/files/find.py
@@ -19,13 +19,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>
-
-import os
-import stat
-import fnmatch
-import time
-import re
-
ANSIBLE_METADATA = {'status': ['stableinterface'],
'supported_by': 'core',
'version': '1.0'}
@@ -185,6 +178,13 @@ examined:
sample: 34
'''
+import os
+import stat
+import fnmatch
+import time
+import re
+
+
def pfilter(f, patterns=None, use_regex=False):
'''filter using glob patterns'''
diff --git a/lib/ansible/modules/files/replace.py b/lib/ansible/modules/files/replace.py
index 0e0eef2165..5248e67bcb 100644
--- a/lib/ansible/modules/files/replace.py
+++ b/lib/ansible/modules/files/replace.py
@@ -18,11 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import re
-import tempfile
-
-from ansible.module_utils._text import to_text, to_bytes
-
ANSIBLE_METADATA = {'status': ['stableinterface'],
'supported_by': 'community',
'version': '1.0'}
@@ -107,10 +102,13 @@ EXAMPLES = r"""
"""
import os
+import re
+import tempfile
-# import module snippets
+from ansible.module_utils._text import to_text, to_bytes
from ansible.module_utils.basic import AnsibleModule
+
def write_changes(module, contents, path):
tmpfd, tmpfile = tempfile.mkstemp()
diff --git a/lib/ansible/modules/monitoring/datadog_event.py b/lib/ansible/modules/monitoring/datadog_event.py
index 4e3bf03b15..597b7c15eb 100644
--- a/lib/ansible/modules/monitoring/datadog_event.py
+++ b/lib/ansible/modules/monitoring/datadog_event.py
@@ -22,13 +22,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Import Datadog
-try:
- from datadog import initialize, api
- HAS_DATADOG = True
-except:
- HAS_DATADOG = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -115,6 +108,13 @@ EXAMPLES = '''
'''
# Import Datadog
+try:
+ from datadog import initialize, api
+ HAS_DATADOG = True
+except:
+ HAS_DATADOG = False
+
+
def main():
module = AnsibleModule(
argument_spec=dict(
diff --git a/lib/ansible/modules/monitoring/logicmonitor.py b/lib/ansible/modules/monitoring/logicmonitor.py
index 96a4c70f22..cd0e6f824b 100644
--- a/lib/ansible/modules/monitoring/logicmonitor.py
+++ b/lib/ansible/modules/monitoring/logicmonitor.py
@@ -1,58 +1,21 @@
#!/usr/bin/python
-"""LogicMonitor Ansible module for managing Collectors, Hosts and Hostgroups
- Copyright (C) 2015 LogicMonitor
-
- This program 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.
-
- This program 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 program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA"""
-
-import datetime
-import os
-import platform
-import socket
-import sys
-import types
-import urllib
-
-HAS_LIB_JSON = True
-try:
- import json
- # Detect the python-json library which is incompatible
- # Look for simplejson if that's the case
- try:
- if (
- not isinstance(json.loads, types.FunctionType) or
- not isinstance(json.dumps, types.FunctionType)
- ):
- raise ImportError
- except AttributeError:
- raise ImportError
-except ImportError:
- try:
- import simplejson as json
- except ImportError:
- print(
- '\n{"msg": "Error: ansible requires the stdlib json or ' +
- 'simplejson module, neither was found!", "failed": true}'
- )
- HAS_LIB_JSON = False
- except SyntaxError:
- print(
- '\n{"msg": "SyntaxError: probably due to installed simplejson ' +
- 'being for a different python version", "failed": true}'
- )
- HAS_LIB_JSON = False
+# LogicMonitor Ansible module for managing Collectors, Hosts and Hostgroups
+# Copyright (C) 2015 LogicMonitor
+#
+# This program 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.
+#
+# This program 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 program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
RETURN = '''
---
@@ -555,6 +518,36 @@ EXAMPLES = '''
delegate_to: localhost
'''
+import datetime
+import os
+import platform
+import socket
+import sys
+import types
+import urllib
+
+HAS_LIB_JSON = True
+try:
+ import json
+ # Detect the python-json library which is incompatible
+ # Look for simplejson if that's the case
+ try:
+ if (
+ not isinstance(json.loads, types.FunctionType) or
+ not isinstance(json.dumps, types.FunctionType)
+ ):
+ raise ImportError
+ except AttributeError:
+ raise ImportError
+except ImportError:
+ try:
+ import simplejson as json
+ except ImportError:
+ HAS_LIB_JSON = False
+ except SyntaxError:
+ HAS_LIB_JSON = False
+
+
class LogicMonitor(object):
diff --git a/lib/ansible/modules/monitoring/logicmonitor_facts.py b/lib/ansible/modules/monitoring/logicmonitor_facts.py
index dbcd139159..1e0660cc66 100644
--- a/lib/ansible/modules/monitoring/logicmonitor_facts.py
+++ b/lib/ansible/modules/monitoring/logicmonitor_facts.py
@@ -1,56 +1,21 @@
#!/usr/bin/python
-"""LogicMonitor Ansible module for managing Collectors, Hosts and Hostgroups
- Copyright (C) 2015 LogicMonitor
-
- This program 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.
-
- This program 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 program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA"""
-
-
-import socket
-import types
-import urllib
-
-HAS_LIB_JSON = True
-try:
- import json
- # Detect the python-json library which is incompatible
- # Look for simplejson if that's the case
- try:
- if (
- not isinstance(json.loads, types.FunctionType) or
- not isinstance(json.dumps, types.FunctionType)
- ):
- raise ImportError
- except AttributeError:
- raise ImportError
-except ImportError:
- try:
- import simplejson as json
- except ImportError:
- print(
- '\n{"msg": "Error: ansible requires the stdlib json or ' +
- 'simplejson module, neither was found!", "failed": true}'
- )
- HAS_LIB_JSON = False
- except SyntaxError:
- print(
- '\n{"msg": "SyntaxError: probably due to installed simplejson ' +
- 'being for a different python version", "failed": true}'
- )
- HAS_LIB_JSON = False
-
+# LogicMonitor Ansible module for managing Collectors, Hosts and Hostgroups
+# Copyright (C) 2015 LogicMonitor
+#
+# This program 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.
+#
+# This program 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 program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
@@ -167,6 +132,31 @@ RETURN = '''
...
'''
+import socket
+import types
+import urllib
+
+HAS_LIB_JSON = True
+try:
+ import json
+ # Detect the python-json library which is incompatible
+ # Look for simplejson if that's the case
+ try:
+ if (
+ not isinstance(json.loads, types.FunctionType) or
+ not isinstance(json.dumps, types.FunctionType)
+ ):
+ raise ImportError
+ except AttributeError:
+ raise ImportError
+except ImportError:
+ try:
+ import simplejson as json
+ except ImportError:
+ HAS_LIB_JSON = False
+ except SyntaxError:
+ HAS_LIB_JSON = False
+
class LogicMonitor(object):
diff --git a/lib/ansible/modules/monitoring/monit.py b/lib/ansible/modules/monitoring/monit.py
index c180f79ed3..8975eb6d68 100644
--- a/lib/ansible/modules/monitoring/monit.py
+++ b/lib/ansible/modules/monitoring/monit.py
@@ -18,7 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import time
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
@@ -62,6 +61,9 @@ EXAMPLES = '''
state: started
'''
+import time
+
+
def main():
arg_spec = dict(
name=dict(required=True),
diff --git a/lib/ansible/modules/network/basics/get_url.py b/lib/ansible/modules/network/basics/get_url.py
index a265877078..64b61481de 100644
--- a/lib/ansible/modules/network/basics/get_url.py
+++ b/lib/ansible/modules/network/basics/get_url.py
@@ -20,11 +20,6 @@
#
# see examples/playbooks/get_url.yml
-import shutil
-import datetime
-import re
-import tempfile
-
ANSIBLE_METADATA = {'status': ['stableinterface'],
'supported_by': 'core',
'version': '1.0'}
@@ -208,6 +203,10 @@ EXAMPLES='''
dest: /tmp/afilecopy.txt
'''
+import shutil
+import datetime
+import re
+import tempfile
from ansible.module_utils.six.moves.urllib.parse import urlsplit
# ==============================================================
diff --git a/lib/ansible/modules/network/eos/eos_banner.py b/lib/ansible/modules/network/eos/eos_banner.py
index 607dcde827..3482ba1c75 100644
--- a/lib/ansible/modules/network/eos/eos_banner.py
+++ b/lib/ansible/modules/network/eos/eos_banner.py
@@ -16,6 +16,10 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = """
---
module: eos_banner_
diff --git a/lib/ansible/modules/network/eos/eos_user.py b/lib/ansible/modules/network/eos/eos_user.py
index 21317657b3..e5bad1380f 100644
--- a/lib/ansible/modules/network/eos/eos_user.py
+++ b/lib/ansible/modules/network/eos/eos_user.py
@@ -16,6 +16,10 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = """
---
module: eos_user
diff --git a/lib/ansible/modules/network/ldap_attr.py b/lib/ansible/modules/network/ldap_attr.py
index 849df06b31..efef330e64 100644
--- a/lib/ansible/modules/network/ldap_attr.py
+++ b/lib/ansible/modules/network/ldap_attr.py
@@ -19,19 +19,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.pycompat24 import get_exception
-
-try:
- import ldap
- import ldap.sasl
-
- HAS_LDAP = True
-except ImportError:
- HAS_LDAP = False
-
-
ANSIBLE_METADATA = {
'status': [
'preview'
@@ -201,6 +188,17 @@ modlist:
sample: '[[2, "olcRootDN", ["cn=root,dc=example,dc=com"]]]'
"""
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.pycompat24 import get_exception
+
+try:
+ import ldap
+ import ldap.sasl
+
+ HAS_LDAP = True
+except ImportError:
+ HAS_LDAP = False
+
class LdapAttr(object):
def __init__(self, module):
diff --git a/lib/ansible/modules/network/ldap_entry.py b/lib/ansible/modules/network/ldap_entry.py
index c52609c03b..574359c189 100644
--- a/lib/ansible/modules/network/ldap_entry.py
+++ b/lib/ansible/modules/network/ldap_entry.py
@@ -19,19 +19,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.pycompat24 import get_exception
-
-try:
- import ldap
- import ldap.modlist
- import ldap.sasl
-
- HAS_LDAP = True
-except ImportError:
- HAS_LDAP = False
-
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
DOCUMENTATION = """
---
@@ -157,6 +147,18 @@ RETURN = """
# Default return values
"""
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.pycompat24 import get_exception
+
+try:
+ import ldap
+ import ldap.modlist
+ import ldap.sasl
+
+ HAS_LDAP = True
+except ImportError:
+ HAS_LDAP = False
+
class LdapEntry(object):
def __init__(self, module):
diff --git a/lib/ansible/modules/network/lldp.py b/lib/ansible/modules/network/lldp.py
index 29c3f47546..27763e1e02 100644
--- a/lib/ansible/modules/network/lldp.py
+++ b/lib/ansible/modules/network/lldp.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import subprocess
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -51,6 +49,9 @@ EXAMPLES = '''
'''
+import subprocess
+
+
def gather_lldp():
cmd = ['lldpctl', '-f', 'keyvalue']
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
diff --git a/lib/ansible/modules/network/netvisor/pn_cluster.py b/lib/ansible/modules/network/netvisor/pn_cluster.py
index de02198e2d..12228b7ebd 100644
--- a/lib/ansible/modules/network/netvisor/pn_cluster.py
+++ b/lib/ansible/modules/network/netvisor/pn_cluster.py
@@ -18,9 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-import shlex
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -111,6 +108,8 @@ changed:
type: bool
"""
+import shlex
+
NAME_EXISTS = None
NODE1_EXISTS = None
NODE2_EXISTS = None
diff --git a/lib/ansible/modules/network/netvisor/pn_ospf.py b/lib/ansible/modules/network/netvisor/pn_ospf.py
index 7c4cbd1400..d75c48558b 100644
--- a/lib/ansible/modules/network/netvisor/pn_ospf.py
+++ b/lib/ansible/modules/network/netvisor/pn_ospf.py
@@ -18,8 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import shlex
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -99,6 +97,7 @@ changed:
type: bool
"""
+import shlex
VROUTER_EXISTS = None
NETWORK_EXISTS = None
diff --git a/lib/ansible/modules/network/netvisor/pn_ospfarea.py b/lib/ansible/modules/network/netvisor/pn_ospfarea.py
index d34b145d28..2df554ec92 100644
--- a/lib/ansible/modules/network/netvisor/pn_ospfarea.py
+++ b/lib/ansible/modules/network/netvisor/pn_ospfarea.py
@@ -18,9 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-import shlex
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -115,6 +112,8 @@ changed:
type: bool
"""
+import shlex
+
def get_command_from_state(state):
"""
diff --git a/lib/ansible/modules/network/netvisor/pn_show.py b/lib/ansible/modules/network/netvisor/pn_show.py
index ff22667a43..87e321b880 100644
--- a/lib/ansible/modules/network/netvisor/pn_show.py
+++ b/lib/ansible/modules/network/netvisor/pn_show.py
@@ -18,9 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-import shlex
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -96,6 +93,8 @@ changed:
type: bool
"""
+import shlex
+
def pn_cli(module):
"""
diff --git a/lib/ansible/modules/network/netvisor/pn_trunk.py b/lib/ansible/modules/network/netvisor/pn_trunk.py
index 3174fc203f..35ef4e615d 100644
--- a/lib/ansible/modules/network/netvisor/pn_trunk.py
+++ b/lib/ansible/modules/network/netvisor/pn_trunk.py
@@ -18,9 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-import shlex
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -161,6 +158,9 @@ changed:
returned: always
type: bool
"""
+
+import shlex
+
TRUNK_EXISTS = None
diff --git a/lib/ansible/modules/network/netvisor/pn_vlag.py b/lib/ansible/modules/network/netvisor/pn_vlag.py
index 66b9ce0596..83cf1ac155 100644
--- a/lib/ansible/modules/network/netvisor/pn_vlag.py
+++ b/lib/ansible/modules/network/netvisor/pn_vlag.py
@@ -18,9 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-import shlex
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -134,6 +131,8 @@ changed:
type: bool
"""
+import shlex
+
VLAG_EXISTS = None
diff --git a/lib/ansible/modules/network/netvisor/pn_vlan.py b/lib/ansible/modules/network/netvisor/pn_vlan.py
index c79e4ba5e3..77f26a2a19 100644
--- a/lib/ansible/modules/network/netvisor/pn_vlan.py
+++ b/lib/ansible/modules/network/netvisor/pn_vlan.py
@@ -18,9 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-import shlex
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -114,6 +111,8 @@ changed:
type: bool
"""
+import shlex
+
VLAN_EXISTS = None
MAX_VLAN_ID = 4092
MIN_VLAN_ID = 2
diff --git a/lib/ansible/modules/network/netvisor/pn_vrouter.py b/lib/ansible/modules/network/netvisor/pn_vrouter.py
index bb0cadc76d..255220e78e 100644
--- a/lib/ansible/modules/network/netvisor/pn_vrouter.py
+++ b/lib/ansible/modules/network/netvisor/pn_vrouter.py
@@ -18,9 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-import shlex
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -148,6 +145,8 @@ changed:
type: bool
"""
+import shlex
+
VROUTER_EXISTS = None
VROUTER_NAME_EXISTS = None
diff --git a/lib/ansible/modules/network/netvisor/pn_vrouterbgp.py b/lib/ansible/modules/network/netvisor/pn_vrouterbgp.py
index e53403da07..f0b78e4fb4 100644
--- a/lib/ansible/modules/network/netvisor/pn_vrouterbgp.py
+++ b/lib/ansible/modules/network/netvisor/pn_vrouterbgp.py
@@ -18,9 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-import shlex
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -161,6 +158,7 @@ changed:
type: bool
"""
+import shlex
VROUTER_EXISTS = None
NEIGHBOR_EXISTS = None
diff --git a/lib/ansible/modules/network/netvisor/pn_vrouterif.py b/lib/ansible/modules/network/netvisor/pn_vrouterif.py
index 4c5df6b7fd..6da1a0b177 100644
--- a/lib/ansible/modules/network/netvisor/pn_vrouterif.py
+++ b/lib/ansible/modules/network/netvisor/pn_vrouterif.py
@@ -18,9 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-import shlex
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -160,6 +157,7 @@ changed:
type: bool
"""
+import shlex
VROUTER_EXISTS = None
INTERFACE_EXISTS = None
diff --git a/lib/ansible/modules/network/netvisor/pn_vrouterlbif.py b/lib/ansible/modules/network/netvisor/pn_vrouterlbif.py
index e6fc928a20..c0c6375290 100644
--- a/lib/ansible/modules/network/netvisor/pn_vrouterlbif.py
+++ b/lib/ansible/modules/network/netvisor/pn_vrouterlbif.py
@@ -18,9 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-
-import shlex
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -101,6 +98,7 @@ changed:
type: bool
"""
+import shlex
VROUTER_EXISTS = None
LB_INTERFACE_EXISTS = None
diff --git a/lib/ansible/modules/network/omapi_host.py b/lib/ansible/modules/network/omapi_host.py
index a67fae4660..a7da22d284 100644
--- a/lib/ansible/modules/network/omapi_host.py
+++ b/lib/ansible/modules/network/omapi_host.py
@@ -22,6 +22,10 @@ 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'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = '''
---
module: omapi_host
diff --git a/lib/ansible/modules/packaging/language/easy_install.py b/lib/ansible/modules/packaging/language/easy_install.py
index e84ed37fe1..1f633c6b9d 100644
--- a/lib/ansible/modules/packaging/language/easy_install.py
+++ b/lib/ansible/modules/packaging/language/easy_install.py
@@ -19,9 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import tempfile
-import os.path
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -104,6 +101,9 @@ EXAMPLES = '''
virtualenv: /webapps/myapp/venv
'''
+import tempfile
+import os.path
+
def _is_package_installed(module, name, easy_install, executable_arguments):
executable_arguments = executable_arguments + ['--dry-run']
cmd = '%s %s %s' % (easy_install, ' '.join(executable_arguments), name)
diff --git a/lib/ansible/modules/packaging/language/maven_artifact.py b/lib/ansible/modules/packaging/language/maven_artifact.py
index 727c171117..09e891af55 100644
--- a/lib/ansible/modules/packaging/language/maven_artifact.py
+++ b/lib/ansible/modules/packaging/language/maven_artifact.py
@@ -19,22 +19,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-__author__ = 'cschmidt'
-
-from lxml import etree
-import os
-import hashlib
-import sys
-import posixpath
-import urlparse
-from ansible.module_utils.basic import *
-from ansible.module_utils.urls import *
-try:
- import boto3
- HAS_BOTO = True
-except ImportError:
- HAS_BOTO = False
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -153,6 +137,21 @@ EXAMPLES = '''
dest: /var/lib/tomcat7/webapps/web-app.war
'''
+from lxml import etree
+import os
+import hashlib
+import sys
+import posixpath
+import urlparse
+from ansible.module_utils.basic import *
+from ansible.module_utils.urls import *
+try:
+ import boto3
+ HAS_BOTO = True
+except ImportError:
+ HAS_BOTO = False
+
+
class Artifact(object):
def __init__(self, group_id, artifact_id, version, classifier=None, extension='jar'):
if not group_id:
diff --git a/lib/ansible/modules/packaging/os/homebrew_tap.py b/lib/ansible/modules/packaging/os/homebrew_tap.py
index 649a32f1b8..6562c0bcee 100644
--- a/lib/ansible/modules/packaging/os/homebrew_tap.py
+++ b/lib/ansible/modules/packaging/os/homebrew_tap.py
@@ -21,8 +21,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import re
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -79,6 +77,8 @@ EXAMPLES = '''
url: 'https://bitbucket.org/telemachus/brew'
'''
+import re
+
def a_valid_tap(tap):
'''Returns True if the tap is valid.'''
diff --git a/lib/ansible/modules/packaging/os/layman.py b/lib/ansible/modules/packaging/os/layman.py
index aad3051dc9..f0fbafdb91 100644
--- a/lib/ansible/modules/packaging/os/layman.py
+++ b/lib/ansible/modules/packaging/os/layman.py
@@ -18,9 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import shutil
-from os import path
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -93,7 +90,8 @@ EXAMPLES = '''
state: absent
'''
-USERAGENT = 'ansible-httpget'
+import shutil
+from os import path
try:
from layman.api import LaymanAPI
@@ -102,6 +100,8 @@ try:
except ImportError:
HAS_LAYMAN_API = False
+USERAGENT = 'ansible-httpget'
+
class ModuleError(Exception):
pass
diff --git a/lib/ansible/modules/packaging/os/openbsd_pkg.py b/lib/ansible/modules/packaging/os/openbsd_pkg.py
index eb47eac143..85e4d9a6d5 100644
--- a/lib/ansible/modules/packaging/os/openbsd_pkg.py
+++ b/lib/ansible/modules/packaging/os/openbsd_pkg.py
@@ -18,14 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import os
-import platform
-import re
-import shlex
-import sqlite3
-
-from distutils.version import StrictVersion
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -136,6 +128,15 @@ EXAMPLES = '''
- openbsd_pkg: name=qt5 quick=yes state=absent
'''
+import os
+import platform
+import re
+import shlex
+import sqlite3
+
+from distutils.version import StrictVersion
+
+
# Function used for executing commands.
def execute_command(cmd, module):
# Break command line into arguments.
diff --git a/lib/ansible/modules/packaging/os/pulp_repo.py b/lib/ansible/modules/packaging/os/pulp_repo.py
index 5a0b558af8..b0bc1bcdcd 100644
--- a/lib/ansible/modules/packaging/os/pulp_repo.py
+++ b/lib/ansible/modules/packaging/os/pulp_repo.py
@@ -18,14 +18,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import json
-import os
-from time import sleep
-
-# import module snippets
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.urls import fetch_url
-from ansible.module_utils.urls import url_argument_spec
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
DOCUMENTATION = '''
---
@@ -192,6 +187,15 @@ repo:
sample: my_repo
'''
+import json
+import os
+from time import sleep
+
+# import module snippets
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.urls import fetch_url
+from ansible.module_utils.urls import url_argument_spec
+
class pulp_server(object):
"""
diff --git a/lib/ansible/modules/packaging/os/sorcery.py b/lib/ansible/modules/packaging/os/sorcery.py
index 9b81bb609d..5b31e78d8c 100644
--- a/lib/ansible/modules/packaging/os/sorcery.py
+++ b/lib/ansible/modules/packaging/os/sorcery.py
@@ -19,6 +19,10 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = '''
---
module: sorcery
diff --git a/lib/ansible/modules/packaging/os/swdepot.py b/lib/ansible/modules/packaging/os/swdepot.py
index c155960faa..2b88c985cb 100644
--- a/lib/ansible/modules/packaging/os/swdepot.py
+++ b/lib/ansible/modules/packaging/os/swdepot.py
@@ -18,9 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-import re
-import pipes
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -77,6 +74,10 @@ EXAMPLES = '''
state: absent
'''
+import re
+import pipes
+
+
def compare_package(version1, version2):
""" Compare version packages.
Return values:
diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py
index 800c9fd022..50a26fc207 100644
--- a/lib/ansible/modules/packaging/os/yum.py
+++ b/lib/ansible/modules/packaging/os/yum.py
@@ -21,35 +21,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import os
-import re
-import shutil
-import tempfile
-
-try:
- import rpm
- HAS_RPM_PYTHON = True
-except ImportError:
- HAS_RPM_PYTHON = False
-
-try:
- import yum
- HAS_YUM_PYTHON = True
-except ImportError:
- HAS_YUM_PYTHON = False
-
-try:
- from yum.misc import find_unfinished_transactions, find_ts_remaining
- from rpmUtils.miscutils import splitFilename
- transaction_helpers = True
-except:
- transaction_helpers = False
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.pycompat24 import get_exception
-from ansible.module_utils.urls import fetch_url
-
-
ANSIBLE_METADATA = {'status': ['stableinterface'],
'supported_by': 'core',
'version': '1.0'}
@@ -236,12 +207,41 @@ EXAMPLES = '''
register: result
'''
+import os
+import re
+import shutil
+import tempfile
+
+try:
+ import rpm
+ HAS_RPM_PYTHON = True
+except ImportError:
+ HAS_RPM_PYTHON = False
+
+try:
+ import yum
+ HAS_YUM_PYTHON = True
+except ImportError:
+ HAS_YUM_PYTHON = False
+
+try:
+ from yum.misc import find_unfinished_transactions, find_ts_remaining
+ from rpmUtils.miscutils import splitFilename
+ transaction_helpers = True
+except:
+ transaction_helpers = False
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.pycompat24 import get_exception
+from ansible.module_utils.urls import fetch_url
+
# 64k. Number of bytes to read at a time when manually downloading pkgs via a url
BUFSIZE = 65536
def_qf = "%{name}-%{version}-%{release}.%{arch}"
rpmbin = None
+
def yum_base(conf_file=None, installroot='/'):
my = yum.YumBase()
diff --git a/lib/ansible/modules/packaging/os/yum_repository.py b/lib/ansible/modules/packaging/os/yum_repository.py
index 11ede3e510..ccf49a5154 100644
--- a/lib/ansible/modules/packaging/os/yum_repository.py
+++ b/lib/ansible/modules/packaging/os/yum_repository.py
@@ -18,13 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-import os
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.pycompat24 import get_exception
-from ansible.module_utils.six.moves import configparser
-
-
ANSIBLE_METADATA = {'status': ['stableinterface'],
'supported_by': 'core',
'version': '1.0'}
@@ -478,6 +471,11 @@ state:
sample: "present"
'''
+import os
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.pycompat24 import get_exception
+from ansible.module_utils.six.moves import configparser
+
class YumRepo(object):
# Class global variables
diff --git a/lib/ansible/modules/packaging/os/zypper.py b/lib/ansible/modules/packaging/os/zypper.py
index 5b36489d5a..72e778b0d6 100644
--- a/lib/ansible/modules/packaging/os/zypper.py
+++ b/lib/ansible/modules/packaging/os/zypper.py
@@ -26,9 +26,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from xml.dom.minidom import parseString as parseXML
-import re
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'committer',
'version': '1.0'}
@@ -178,6 +175,9 @@ EXAMPLES = '''
ZYPP_LOCK_TIMEOUT: 20
'''
+from xml.dom.minidom import parseString as parseXML
+import re
+
def split_name_version(name):
"""splits of the package name and desired version
diff --git a/lib/ansible/modules/remote_management/ipmi/ipmi_boot.py b/lib/ansible/modules/remote_management/ipmi/ipmi_boot.py
index 06281d4d46..514422dadc 100644
--- a/lib/ansible/modules/remote_management/ipmi/ipmi_boot.py
+++ b/lib/ansible/modules/remote_management/ipmi/ipmi_boot.py
@@ -16,14 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-try:
- from pyghmi.ipmi import command
-except ImportError:
- command = None
-
-from ansible.module_utils.basic import *
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -129,7 +121,12 @@ EXAMPLES = '''
state: absent
'''
-# ==================================================
+try:
+ from pyghmi.ipmi import command
+except ImportError:
+ command = None
+
+from ansible.module_utils.basic import *
def main():
diff --git a/lib/ansible/modules/remote_management/ipmi/ipmi_power.py b/lib/ansible/modules/remote_management/ipmi/ipmi_power.py
index b661be4c53..137cf44b38 100644
--- a/lib/ansible/modules/remote_management/ipmi/ipmi_power.py
+++ b/lib/ansible/modules/remote_management/ipmi/ipmi_power.py
@@ -16,14 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-try:
- from pyghmi.ipmi import command
-except ImportError:
- command = None
-
-from ansible.module_utils.basic import *
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -94,7 +86,12 @@ EXAMPLES = '''
state: on
'''
-# ==================================================
+try:
+ from pyghmi.ipmi import command
+except ImportError:
+ command = None
+
+from ansible.module_utils.basic import *
def main():
diff --git a/lib/ansible/modules/remote_management/stacki/stacki_host.py b/lib/ansible/modules/remote_management/stacki/stacki_host.py
index 7bae22c0e9..a0e82d39c5 100644
--- a/lib/ansible/modules/remote_management/stacki/stacki_host.py
+++ b/lib/ansible/modules/remote_management/stacki/stacki_host.py
@@ -16,6 +16,10 @@
# 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 = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = '''
---
module: stacki_host
diff --git a/lib/ansible/modules/source_control/github_hooks.py b/lib/ansible/modules/source_control/github_hooks.py
index ec14f2bc17..f285201c96 100644
--- a/lib/ansible/modules/source_control/github_hooks.py
+++ b/lib/ansible/modules/source_control/github_hooks.py
@@ -18,17 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-try:
- import json
-except ImportError:
- try:
- import simplejson as json
- except ImportError:
- # Let snippet from module_utils/basic.py return a proper error in this case
- pass
-
-import base64
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -97,6 +86,18 @@ EXAMPLES = '''
delegate_to: localhost
'''
+try:
+ import json
+except ImportError:
+ try:
+ import simplejson as json
+ except ImportError:
+ # Let snippet from module_utils/basic.py return a proper error in this case
+ pass
+
+import base64
+
+
def _list(module, hookurl, oauthkey, repo, user):
url = "%s/hooks" % repo
auth = base64.encodestring('%s:%s' % (user, oauthkey)).replace('\n', '')
diff --git a/lib/ansible/modules/storage/netapp/netapp_e_volume.py b/lib/ansible/modules/storage/netapp/netapp_e_volume.py
index 2610796585..d3f7c3925c 100644
--- a/lib/ansible/modules/storage/netapp/netapp_e_volume.py
+++ b/lib/ansible/modules/storage/netapp/netapp_e_volume.py
@@ -18,8 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-from ansible.module_utils.api import basic_auth_argument_spec
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -154,6 +152,7 @@ from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.urls import open_url
from ansible.module_utils.six.moves.urllib.error import HTTPError
+from ansible.module_utils.api import basic_auth_argument_spec
def request(url, data=None, headers=None, method='GET', use_proxy=True,
diff --git a/lib/ansible/modules/system/gconftool2.py b/lib/ansible/modules/system/gconftool2.py
index 3c4a919c82..eb712257d0 100644
--- a/lib/ansible/modules/system/gconftool2.py
+++ b/lib/ansible/modules/system/gconftool2.py
@@ -16,9 +16,10 @@
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from ansible.module_utils.basic import AnsibleModule, BOOLEANS_TRUE
-from ansible.module_utils.pycompat24 import get_exception
-import subprocess
+
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
DOCUMENTATION = """
module: gconftool2
@@ -101,6 +102,10 @@ RETURN = '''
...
'''
+from ansible.module_utils.basic import AnsibleModule, BOOLEANS_TRUE
+from ansible.module_utils.pycompat24 import get_exception
+import subprocess
+
class GConf2Preference(object):
def __init__(self, ansible, key, value_type, value,
diff --git a/lib/ansible/modules/system/kernel_blacklist.py b/lib/ansible/modules/system/kernel_blacklist.py
index 5498f10b3a..8ad8b4e042 100644
--- a/lib/ansible/modules/system/kernel_blacklist.py
+++ b/lib/ansible/modules/system/kernel_blacklist.py
@@ -18,10 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import os
-import re
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -61,6 +57,9 @@ EXAMPLES = '''
state: present
'''
+import os
+import re
+
class Blacklist(object):
def __init__(self, module, filename):
diff --git a/lib/ansible/modules/system/pam_limits.py b/lib/ansible/modules/system/pam_limits.py
index f730924d9a..3e520dc850 100644
--- a/lib/ansible/modules/system/pam_limits.py
+++ b/lib/ansible/modules/system/pam_limits.py
@@ -18,11 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import os
-import os.path
-import shutil
-import re
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -116,6 +111,12 @@ EXAMPLES = '''
comment: unlimited memory lock for james
'''
+import os
+import os.path
+import shutil
+import re
+
+
def main():
pam_items = [ 'core', 'data', 'fsize', 'memlock', 'nofile', 'rss', 'stack', 'cpu', 'nproc', 'as', 'maxlogins', 'maxsyslogins', 'priority', 'locks', 'sigpending', 'msgqueue', 'nice', 'rtprio', 'chroot' ]
diff --git a/lib/ansible/modules/system/pamd.py b/lib/ansible/modules/system/pamd.py
index ffc7dc4672..dac74b3446 100644
--- a/lib/ansible/modules/system/pamd.py
+++ b/lib/ansible/modules/system/pamd.py
@@ -16,8 +16,10 @@
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.pycompat24 import get_exception
+
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
DOCUMENTATION = """
module: pamd
@@ -196,6 +198,9 @@ dest:
...
'''
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.pycompat24 import get_exception
+
# The PamdRule class encapsulates a rule in a pam.d service
class PamdRule(object):
diff --git a/lib/ansible/modules/system/puppet.py b/lib/ansible/modules/system/puppet.py
index 15acb97d26..d7e1183255 100644
--- a/lib/ansible/modules/system/puppet.py
+++ b/lib/ansible/modules/system/puppet.py
@@ -15,20 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-import os
-import pipes
-import stat
-
-try:
- import json
-except ImportError:
- try:
- import simplejson as json
- except ImportError:
- # Let snippet from module_utils/basic.py return a proper error in this case
- pass
-
-
ANSIBLE_METADATA = {'status': ['stableinterface'],
'supported_by': 'community',
'version': '1.0'}
@@ -127,6 +113,19 @@ EXAMPLES = '''
tags: update,nginx
'''
+import os
+import pipes
+import stat
+
+try:
+ import json
+except ImportError:
+ try:
+ import simplejson as json
+ except ImportError:
+ # Let snippet from module_utils/basic.py return a proper error in this case
+ pass
+
def _get_facter_dir():
if os.getuid() == 0:
diff --git a/lib/ansible/modules/system/solaris_zone.py b/lib/ansible/modules/system/solaris_zone.py
index ae72309e19..5157e38327 100644
--- a/lib/ansible/modules/system/solaris_zone.py
+++ b/lib/ansible/modules/system/solaris_zone.py
@@ -17,11 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import sys
-import os
-import platform
-import tempfile
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -159,6 +154,12 @@ EXAMPLES = '''
attach_options: -u
'''
+import sys
+import os
+import platform
+import tempfile
+
+
class Zone(object):
def __init__(self, module):
self.changed = False
diff --git a/lib/ansible/modules/system/timezone.py b/lib/ansible/modules/system/timezone.py
index 0c29c6165d..285e413a28 100644
--- a/lib/ansible/modules/system/timezone.py
+++ b/lib/ansible/modules/system/timezone.py
@@ -18,16 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import os
-import platform
-import random
-import re
-import string
-
-from ansible.module_utils.basic import AnsibleModule, get_platform
-from ansible.module_utils.six import iteritems
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'committer',
'version': '1.0'}
@@ -89,6 +79,15 @@ EXAMPLES = '''
name: Asia/Tokyo
'''
+import os
+import platform
+import random
+import re
+import string
+
+from ansible.module_utils.basic import AnsibleModule, get_platform
+from ansible.module_utils.six import iteritems
+
class Timezone(object):
"""This is a generic Timezone manipulation class that is subclassed based on platform.
diff --git a/lib/ansible/modules/utilities/logic/wait_for.py b/lib/ansible/modules/utilities/logic/wait_for.py
index ee133818dd..9f2cfbb09a 100644
--- a/lib/ansible/modules/utilities/logic/wait_for.py
+++ b/lib/ansible/modules/utilities/logic/wait_for.py
@@ -18,25 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import binascii
-import datetime
-import math
-import re
-import select
-import socket
-import sys
-import time
-
-from ansible.module_utils._text import to_native
-
-HAS_PSUTIL = False
-try:
- import psutil
- HAS_PSUTIL = True
- # just because we can import it on Linux doesn't mean we will use it
-except ImportError:
- pass
-
ANSIBLE_METADATA = {'status': ['stableinterface'],
'supported_by': 'core',
'version': '1.0'}
@@ -176,6 +157,26 @@ EXAMPLES = '''
- local_action: wait_for port=22 host="{{ ansible_ssh_host | default(inventory_hostname) }}" search_regex=OpenSSH delay=10
'''
+import binascii
+import datetime
+import math
+import re
+import select
+import socket
+import sys
+import time
+
+from ansible.module_utils._text import to_native
+
+HAS_PSUTIL = False
+try:
+ import psutil
+ HAS_PSUTIL = True
+ # just because we can import it on Linux doesn't mean we will use it
+except ImportError:
+ pass
+
+
class TCPConnectionInfo(object):
"""
This is a generic TCP Connection Info strategy class that relies
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py
index 8788f58ef0..7c1d3397ac 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py
@@ -16,6 +16,10 @@
# 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 = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = '''
---
module: tower_organization
diff --git a/lib/ansible/modules/web_infrastructure/jenkins_plugin.py b/lib/ansible/modules/web_infrastructure/jenkins_plugin.py
index b90aebe2a9..cb7584d14e 100644
--- a/lib/ansible/modules/web_infrastructure/jenkins_plugin.py
+++ b/lib/ansible/modules/web_infrastructure/jenkins_plugin.py
@@ -18,20 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.pycompat24 import get_exception
-from ansible.module_utils.urls import fetch_url, url_argument_spec
-from ansible.module_utils._text import to_native
-import base64
-import hashlib
-import json
-import os
-import tempfile
-import time
-import urllib
-
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -307,6 +293,18 @@ state:
sample: "present"
'''
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.pycompat24 import get_exception
+from ansible.module_utils.urls import fetch_url, url_argument_spec
+from ansible.module_utils._text import to_native
+import base64
+import hashlib
+import json
+import os
+import tempfile
+import time
+import urllib
+
class JenkinsPlugin(object):
def __init__(self, module):
diff --git a/lib/ansible/modules/web_infrastructure/jenkins_script.py b/lib/ansible/modules/web_infrastructure/jenkins_script.py
index 9f618c3476..9b0e64c867 100644
--- a/lib/ansible/modules/web_infrastructure/jenkins_script.py
+++ b/lib/ansible/modules/web_infrastructure/jenkins_script.py
@@ -20,6 +20,10 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = '''
---
author: James Hogarth
diff --git a/lib/ansible/modules/web_infrastructure/letsencrypt.py b/lib/ansible/modules/web_infrastructure/letsencrypt.py
index 946f7fb338..527f4b9a28 100644
--- a/lib/ansible/modules/web_infrastructure/letsencrypt.py
+++ b/lib/ansible/modules/web_infrastructure/letsencrypt.py
@@ -18,12 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-import binascii
-import copy
-import locale
-import textwrap
-from datetime import datetime
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -168,6 +162,13 @@ authorizations:
type: dict
'''
+import binascii
+import copy
+import locale
+import textwrap
+from datetime import datetime
+
+
def nopad_b64(data):
return base64.urlsafe_b64encode(data).decode('utf8').replace("=", "")
diff --git a/lib/ansible/modules/web_infrastructure/supervisorctl.py b/lib/ansible/modules/web_infrastructure/supervisorctl.py
index 84c8ece749..7c6f4776a0 100644
--- a/lib/ansible/modules/web_infrastructure/supervisorctl.py
+++ b/lib/ansible/modules/web_infrastructure/supervisorctl.py
@@ -18,9 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-import os
-from ansible.module_utils.basic import AnsibleModule, is_executable
-
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
@@ -111,6 +108,9 @@ EXAMPLES = '''
server_url: http://localhost:9001
'''
+import os
+from ansible.module_utils.basic import AnsibleModule, is_executable
+
def main():
arg_spec = dict(
diff --git a/lib/ansible/modules/windows/win_shortcut.py b/lib/ansible/modules/windows/win_shortcut.py
index f22c3a4682..ad4bfe019b 100644
--- a/lib/ansible/modules/windows/win_shortcut.py
+++ b/lib/ansible/modules/windows/win_shortcut.py
@@ -18,6 +18,10 @@
# 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'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
DOCUMENTATION = '''
---
module: win_shortcut
diff --git a/test/sanity/validate-modules/schema.py b/test/sanity/validate-modules/schema.py
index dbe606c648..7aef6e7e61 100644
--- a/test/sanity/validate-modules/schema.py
+++ b/test/sanity/validate-modules/schema.py
@@ -43,3 +43,13 @@ doc_schema = Schema(
},
extra=ALLOW_EXTRA
)
+
+metadata_schema = Schema(
+ {
+ Required('status'): [Any('stableinterface', 'preview', 'deprecated',
+ 'removed')],
+ Required('version'): '1.0',
+ Required('supported_by'): Any('core', 'community', 'unmaintained',
+ 'committer')
+ }
+)
diff --git a/test/sanity/validate-modules/test_validate_modules_regex.py b/test/sanity/validate-modules/test_validate_modules_regex.py
index 95b502e048..0e41ee7e2d 100644
--- a/test/sanity/validate-modules/test_validate_modules_regex.py
+++ b/test/sanity/validate-modules/test_validate_modules_regex.py
@@ -10,17 +10,17 @@
# 2) source hacking/env-setup
# 3) PYTHONPATH=./lib nosetests -d -w test -v --nocapture sanity/validate-modules
-import os
import re
from ansible.compat.tests import unittest
-#TYPE_REGEX = re.compile(r'.*\stype\(.*')
-#TYPE_REGEX = re.compile(r'.*(if|or)\stype\(.*')
-#TYPE_REGEX = re.compile(r'.*(if|or)(\s+.*|\s+)type\(.*')
-#TYPE_REGEX = re.compile(r'.*(if|or)(\s+.*|\s+)type\(.*')
-#TYPE_REGEX = re.compile(r'.*(if|\sor)(\s+.*|\s+)type\(.*')
-#TYPE_REGEX = re.compile(r'.*(if|\sor)(\s+.*|\s+)(?<!_)type\(.*')
-TYPE_REGEX = re.compile(r'.*(if|or)(\s+.*|\s+)(?<!_)(?<!str\()type\(.*')
+# TYPE_REGEX = re.compile(r'.*\stype\(.*')
+# TYPE_REGEX = re.compile(r'.*(if|or)\stype\(.*')
+# TYPE_REGEX = re.compile(r'.*(if|or)(\s+.*|\s+)type\(.*')
+# TYPE_REGEX = re.compile(r'.*(if|or)(\s+.*|\s+)type\(.*')
+# TYPE_REGEX = re.compile(r'.*(if|\sor)(\s+.*|\s+)type\(.*')
+# TYPE_REGEX = re.compile(r'.*(if|\sor)(\s+.*|\s+)(?<!_)type\(.*')
+TYPE_REGEX = re.compile(r'.*(if|or)(\s+.*|\s+)(?<!_)(?<!str\()type\(.*')
+
class TestValidateModulesRegex(unittest.TestCase):
@@ -42,18 +42,18 @@ class TestValidateModulesRegex(unittest.TestCase):
['if foo or type(bar) != Bar', True],
['x = type(foo)', False],
["error = err.message + ' ' + str(err) + ' - ' + str(type(err))", False],
- #cloud/amazon/ec2_group.py
+ # cloud/amazon/ec2_group.py
["module.fail_json(msg='Invalid rule parameter type [%s].' % type(rule))", False],
- #files/patch.py
- ["p = type('Params', (), module.params)", False], #files/patch.py
- #system/osx_defaults.py
+ # files/patch.py
+ ["p = type('Params', (), module.params)", False], # files/patch.py
+ # system/osx_defaults.py
["if self.current_value is not None and not isinstance(self.current_value, type(self.value)):", True],
- #system/osx_defaults.py
+ # system/osx_defaults.py
['raise OSXDefaultsException("Type mismatch. Type in defaults: " + type(self.current_value).__name__)', False],
- #network/nxos/nxos_interface.py
+ # network/nxos/nxos_interface.py
["if get_interface_type(interface) == 'svi':", False],
]
- for idc,check in enumerate(checks):
+ for idc, check in enumerate(checks):
cstring = check[0]
cexpected = check[1]
@@ -62,4 +62,3 @@ class TestValidateModulesRegex(unittest.TestCase):
assert False, "%s should have matched" % cstring
elif not cexpected and match:
assert False, "%s should not have matched" % cstring
-
diff --git a/test/sanity/validate-modules/utils.py b/test/sanity/validate-modules/utils.py
index 46ba81d926..32a7fbb06c 100644
--- a/test/sanity/validate-modules/utils.py
+++ b/test/sanity/validate-modules/utils.py
@@ -22,6 +22,9 @@ import sys
# We only use StringIO, since we cannot setattr on cStringIO
from StringIO import StringIO
+import yaml
+import yaml.reader
+
def find_globals(g, tree):
"""Uses AST to find globals in an ast tree"""
@@ -66,3 +69,28 @@ class CaptureStd():
"""Return ``(stdout, stderr)``"""
return self.stdout.getvalue(), self.stderr.getvalue()
+
+
+def parse_yaml(value, lineno, module, name):
+ traces = []
+ errors = []
+ data = None
+ try:
+ data = yaml.safe_load(value)
+ except yaml.MarkedYAMLError as e:
+ e.problem_mark.line += lineno - 1
+ e.problem_mark.name = '%s.%s' % (module, name)
+ errors.append('%s is not valid YAML. Line %d column %d' %
+ (name, e.problem_mark.line + 1,
+ e.problem_mark.column + 1))
+ traces.append(e)
+ except yaml.reader.ReaderError as e:
+ traces.append(e)
+ errors.append('%s is not valid YAML. Character '
+ '0x%x at position %d.' %
+ (name, e.character, e.position))
+ except yaml.YAMLError as e:
+ traces.append(e)
+ errors.append('%s is not valid YAML: %s: %s' % (name, type(e), e))
+
+ return data, errors, traces
diff --git a/test/sanity/validate-modules/validate-modules b/test/sanity/validate-modules/validate-modules
index 1e76fb3518..b794b0d9c4 100755
--- a/test/sanity/validate-modules/validate-modules
+++ b/test/sanity/validate-modules/validate-modules
@@ -36,18 +36,15 @@ from ansible.utils.module_docs import BLACKLIST_MODULES, get_docstring
from module_args import get_argument_spec
-from schema import doc_schema, option_schema
+from schema import doc_schema, option_schema, metadata_schema
-from utils import CaptureStd
+from utils import CaptureStd, parse_yaml
from voluptuous.humanize import humanize_error
-import yaml
-import yaml.reader
-
BLACKLIST_DIRS = frozenset(('.git', 'test', '.github', '.idea'))
INDENT_REGEX = re.compile(r'([\t]*)')
-TYPE_REGEX = re.compile(r'.*(if|or)(\s+.*|\s+)(?<!_)(?<!str\()type\(.*')
+TYPE_REGEX = re.compile(r'.*(if|or)(\s+.*|\s+)(?<!_)(?<!str\()type\(.*')
BLACKLIST_IMPORTS = {
'requests': {
'new_only': True,
@@ -205,7 +202,10 @@ class ModuleValidator(Validator):
for line_no, line in enumerate(self.text.splitlines()):
typekeyword = TYPE_REGEX.match(line)
if typekeyword:
- self.errors.append('Type comparison using type() found on line %d. Use isinstance() instead' % (line_no + 1))
+ self.errors.append(
+ 'Type comparison using type() found on '
+ 'line %d. Use isinstance() instead' % (line_no + 1)
+ )
def _check_for_sys_exit(self):
if 'sys.exit(' in self.text:
@@ -325,6 +325,37 @@ class ModuleValidator(Validator):
self.warnings.append('Found Try/Except block without HAS_ '
'assginment')
+ def _ensure_imports_below_docs(self, doc_info):
+ doc_lines = [doc_info[key]['lineno'] for key in doc_info]
+
+ for child in self.ast.body:
+ if isinstance(child, (ast.Import, ast.ImportFrom)):
+ for lineno in doc_lines:
+ if child.lineno < lineno:
+ self.errors.append(
+ 'Import found before documentation variables. '
+ 'All imports must appear below '
+ 'DOCUMENTATION/EXAMPLES/RETURN/ANSIBLE_METADATA. '
+ 'line %d' % (child.lineno,)
+ )
+ break
+ elif isinstance(child, ast.TryExcept):
+ bodies = child.body
+ for handler in child.handlers:
+ bodies.extend(handler.body)
+ for grandchild in bodies:
+ if isinstance(grandchild, (ast.Import, ast.ImportFrom)):
+ for lineno in doc_lines:
+ if child.lineno < lineno:
+ self.errors.append(
+ 'Import found before documentation '
+ 'variables. All imports must appear below '
+ 'DOCUMENTATION/EXAMPLES/RETURN/'
+ 'ANSIBLE_METADATA. line %d' %
+ (child.lineno,)
+ )
+ break
+
def _find_ps_replacers(self):
if 'WANT_JSON' not in self.text:
self.errors.append('WANT_JSON not found in module')
@@ -352,6 +383,10 @@ class ModuleValidator(Validator):
'RETURN': {
'value': None,
'lineno': 0
+ },
+ 'ANSIBLE_METADATA': {
+ 'value': None,
+ 'lineno': 0
}
}
for child in self.ast.body:
@@ -366,13 +401,16 @@ class ModuleValidator(Validator):
elif grandchild.id == 'RETURN':
docs['RETURN']['value'] = child.value.s
docs['RETURN']['lineno'] = child.lineno
+ elif grandchild.id == 'ANSIBLE_METADATA':
+ docs['ANSIBLE_METADATA']['value'] = child.value
+ docs['ANSIBLE_METADATA']['lineno'] = child.lineno
return docs
- def _validate_docs_schema(self, doc):
+ def _validate_docs_schema(self, doc, schema, name):
errors = []
try:
- doc_schema(doc)
+ schema(doc)
except Exception as e:
for error in e.errors:
error.data = doc
@@ -390,52 +428,40 @@ class ModuleValidator(Validator):
for error in errors:
path = [str(p) for p in error.path]
- self.errors.append('DOCUMENTATION.%s: %s' %
- ('.'.join(path), humanize_error(error.data, error)))
+ self.errors.append('%s.%s: %s' %
+ (name, '.'.join(path),
+ humanize_error(error.data, error)))
def _validate_docs(self):
doc_info = self._get_docs()
- try:
- doc = yaml.safe_load(doc_info['DOCUMENTATION']['value'])
- except yaml.MarkedYAMLError as e:
- doc = None
- # This offsets the error line number to where the
- # DOCUMENTATION starts so we can just go to that line in the
- # module
- e.problem_mark.line += (
- doc_info['DOCUMENTATION']['lineno'] - 1
- )
- e.problem_mark.name = '%s.DOCUMENTATION' % self.name
- self.traces.append(e)
- self.errors.append('DOCUMENTATION is not valid YAML. Line %d '
- 'column %d' %
- (e.problem_mark.line + 1,
- e.problem_mark.column + 1))
- except yaml.reader.ReaderError as e:
- self.traces.append(e)
- self.errors.append('DOCUMENTATION is not valid YAML. Character 0x%x at position %d.' %
- (e.character, e.position))
- except yaml.YAMLError as e:
- self.traces.append(e)
- self.errors.append('DOCUMENTATION is not valid YAML: %s: %s' % (type(e), e))
- except AttributeError:
+ if not bool(doc_info['DOCUMENTATION']['value']):
self.errors.append('No DOCUMENTATION provided')
else:
- with CaptureStd():
- try:
- get_docstring(self.path, verbose=True)
- except AssertionError:
- fragment = doc['extends_documentation_fragment']
- self.errors.append('DOCUMENTATION fragment missing: %s' %
- fragment)
- except Exception as e:
- self.traces.append(e)
- self.errors.append('Unknown DOCUMENTATION error, see '
- 'TRACE')
-
- self._validate_docs_schema(doc)
- self._check_version_added(doc)
- self._check_for_new_args(doc)
+ doc, errors, traces = parse_yaml(
+ doc_info['DOCUMENTATION']['value'],
+ doc_info['DOCUMENTATION']['lineno'],
+ self.name, 'DOCUMENTATION'
+ )
+ self.errors.extend(errors)
+ self.traces.extend(traces)
+ if not errors and not traces:
+ with CaptureStd():
+ try:
+ get_docstring(self.path, verbose=True)
+ except AssertionError:
+ fragment = doc['extends_documentation_fragment']
+ self.errors.append(
+ 'DOCUMENTATION fragment missing: %s' %
+ fragment
+ )
+ except Exception as e:
+ self.traces.append(e)
+ self.errors.append('Unknown DOCUMENTATION error, see '
+ 'TRACE')
+
+ self._validate_docs_schema(doc, doc_schema, 'DOCUMENTATION')
+ self._check_version_added(doc)
+ self._check_for_new_args(doc)
if not bool(doc_info['EXAMPLES']['value']):
self.errors.append('No EXAMPLES provided')
@@ -446,25 +472,34 @@ class ModuleValidator(Validator):
else:
self.warnings.append('No RETURN provided')
else:
- try:
- yaml.safe_load(doc_info['RETURN']['value'])
- except yaml.MarkedYAMLError as e:
- e.problem_mark.line += (
- doc_info['RETURN']['lineno'] - 1
+ _, errors, traces = parse_yaml(doc_info['RETURN']['value'],
+ doc_info['RETURN']['lineno'],
+ self.name, 'RETURN')
+ self.errors.extend(errors)
+ self.traces.extend(traces)
+
+ if not bool(doc_info['ANSIBLE_METADATA']['value']):
+ self.errors.append('No ANSIBLE_METADATA provided')
+ else:
+ metadata = None
+ if isinstance(doc_info['ANSIBLE_METADATA']['value'], ast.Dict):
+ metadata = ast.literal_eval(
+ doc_info['ANSIBLE_METADATA']['value']
)
- e.problem_mark.name = '%s.RETURN' % self.name
- self.errors.append('RETURN is not valid YAML. Line %d '
- 'column %d' %
- (e.problem_mark.line + 1,
- e.problem_mark.column + 1))
- self.traces.append(e)
- except yaml.reader.ReaderError as e:
- self.traces.append(e)
- self.errors.append('RETURN is not valid YAML. Character 0x%x at position %d.' %
- (e.character, e.position))
- except yaml.YAMLError as e:
- self.traces.append(e)
- self.errors.append('RETURN is not valid YAML: %s: %s' % (type(e), e))
+ else:
+ metadata, errors, traces = parse_yaml(
+ doc_info['ANSIBLE_METADATA']['value'].s,
+ doc_info['ANSIBLE_METADATA']['lineno'],
+ self.name, 'ANSIBLE_METADATA'
+ )
+ self.errors.extend(errors)
+ self.traces.extend(traces)
+
+ if metadata:
+ self._validate_docs_schema(metadata, metadata_schema,
+ 'ANSIBLE_METADATA')
+
+ return doc_info
def _check_version_added(self, doc):
if not self._is_new_module():
@@ -587,7 +622,7 @@ class ModuleValidator(Validator):
return
if self._python_module():
- self._validate_docs()
+ doc_info = self._validate_docs()
if self._python_module() and not self._just_docs():
self._validate_argument_spec()
@@ -597,6 +632,7 @@ class ModuleValidator(Validator):
self._find_module_utils(main)
self._find_has_import()
self._check_for_tabs()
+ self._ensure_imports_below_docs(doc_info)
if self._powershell_module():
self._find_ps_replacers()
@@ -605,7 +641,9 @@ class ModuleValidator(Validator):
self._check_for_gpl3_header()
if not self._just_docs():
self._check_interpreter(powershell=self._powershell_module())
- self._check_type_instead_of_isinstance(powershell=self._powershell_module())
+ self._check_type_instead_of_isinstance(
+ powershell=self._powershell_module()
+ )
class PythonPackageValidator(Validator):