Update for Ansible 2.15 sanity tests (#173)

This commit is contained in:
Mike Graves
2022-09-22 09:38:20 -04:00
committed by GitHub
parent ed9fb196f9
commit 1691951788
12 changed files with 128 additions and 4 deletions

View File

@@ -13,6 +13,8 @@ try:
get_api_client,
)
HAS_KUBERNETES_COLLECTION = True
k8s_collection_import_exception = None
K8S_COLLECTION_ERROR = None
except ImportError as e:
HAS_KUBERNETES_COLLECTION = False
k8s_collection_import_exception = e

View File

@@ -14,6 +14,8 @@ try:
get_api_client,
)
HAS_KUBERNETES_COLLECTION = True
k8s_collection_import_exception = None
K8S_COLLECTION_ERROR = None
except ImportError as e:
HAS_KUBERNETES_COLLECTION = False
k8s_collection_import_exception = e

View File

@@ -17,6 +17,8 @@ try:
get_api_client,
)
HAS_KUBERNETES_COLLECTION = True
k8s_collection_import_exception = None
K8S_COLLECTION_ERROR = None
except ImportError as e:
HAS_KUBERNETES_COLLECTION = False
k8s_collection_import_exception = e

View File

@@ -15,6 +15,8 @@ try:
get_api_client,
)
HAS_KUBERNETES_COLLECTION = True
k8s_collection_import_exception = None
K8S_COLLECTION_ERROR = None
except ImportError as e:
HAS_KUBERNETES_COLLECTION = False
k8s_collection_import_exception = e

View File

@@ -26,6 +26,7 @@ from ansible_collections.community.okd.plugins.module_utils.openshift_ldap impor
try:
import ldap
HAS_PYTHON_LDAP = True
PYTHON_LDAP_ERROR = None
except ImportError as e:
HAS_PYTHON_LDAP = False
PYTHON_LDAP_ERROR = e
@@ -36,6 +37,8 @@ try:
get_api_client,
)
HAS_KUBERNETES_COLLECTION = True
k8s_collection_import_exception = None
K8S_COLLECTION_ERROR = None
except ImportError as e:
HAS_KUBERNETES_COLLECTION = False
k8s_collection_import_exception = e
@@ -225,12 +228,11 @@ class OpenshiftLDAPGroups(object):
name = definition["metadata"]["name"]
existing = self.get_group_info(name=name)
if not self.module.check_mode:
method = "patch" if existing else "create"
try:
if existing:
method = 'patch'
definition = self.k8s_group_api.patch(definition).to_dict()
else:
method = 'create'
definition = self.k8s_group_api.create(definition).to_dict()
except DynamicApiError as exc:
self.module.fail_json(msg="Failed to %s Group '%s' due to: %s" % (method, name, exc.body))

View File

@@ -16,6 +16,8 @@ try:
get_api_client,
)
HAS_KUBERNETES_COLLECTION = True
k8s_collection_import_exception = None
K8S_COLLECTION_ERROR = None
except ImportError as e:
HAS_KUBERNETES_COLLECTION = False
k8s_collection_import_exception = e

View File

@@ -56,7 +56,7 @@ def validate_ldap_sync_config(config):
schemas.append(schema)
if len(schemas) == 0:
return "No schema-specific config was provided, should be one of %s" % schema_list
return "No schema-specific config was provided, should be one of %s" % ", ".join(schema_list)
if len(schemas) > 1:
return "Exactly one schema-specific config is required; found (%d) %s" % (len(schemas), ','.join(schemas))

View File

@@ -16,6 +16,8 @@ from ansible.module_utils._text import to_native
try:
from kubernetes.dynamic.exceptions import DynamicApiError, NotFoundError
HAS_KUBERNETES_COLLECTION = True
k8s_collection_import_exception = None
K8S_COLLECTION_ERROR = None
except ImportError as e:
HAS_KUBERNETES_COLLECTION = False
k8s_collection_import_exception = e

View File

@@ -14,6 +14,8 @@ try:
get_api_client,
)
HAS_KUBERNETES_COLLECTION = True
k8s_collection_import_exception = None
K8S_COLLECTION_ERROR = None
except ImportError as e:
HAS_KUBERNETES_COLLECTION = False
k8s_collection_import_exception = e
@@ -27,6 +29,7 @@ try:
from requests import request
from requests.auth import HTTPBasicAuth
HAS_REQUESTS_MODULE = True
requests_import_exception = None
except ImportError as e:
HAS_REQUESTS_MODULE = False
requests_import_exception = e

View File

@@ -241,6 +241,8 @@ try:
from kubernetes.dynamic.exceptions import DynamicApiError
HAS_KUBERNETES_COLLECTION = True
k8s_collection_import_exception = None
K8S_COLLECTION_ERROR = None
except ImportError as e:
HAS_KUBERNETES_COLLECTION = False
k8s_collection_import_exception = e

View File

@@ -321,6 +321,8 @@ try:
AUTH_ARG_SPEC, WAIT_ARG_SPEC, COMMON_ARG_SPEC
)
HAS_KUBERNETES_COLLECTION = True
k8s_collection_import_exception = None
K8S_COLLECTION_ERROR = None
except ImportError as e:
HAS_KUBERNETES_COLLECTION = False
k8s_collection_import_exception = e
@@ -542,7 +544,7 @@ class OpenShiftRoute(K8sAnsibleMixin):
def wait_predicate(route):
if not(route.status and route.status.ingress):
if not (route.status and route.status.ingress):
return False
for ingress in route.status.ingress:
match = [x for x in ingress.conditions if x.type == 'Admitted']