This commit is contained in:
abikouo
2021-05-20 11:45:35 +02:00
parent 2691b0f43d
commit 3939c5304b
4 changed files with 6 additions and 5 deletions

View File

@@ -242,7 +242,7 @@ class K8sAnsibleMixin(object):
self.fail(msg='Failed to find exact match for {0}.{1} by [kind, name, singularName, shortNames]'.format(api_version, kind)) self.fail(msg='Failed to find exact match for {0}.{1} by [kind, name, singularName, shortNames]'.format(api_version, kind))
def kubernetes_facts(self, kind, api_version, name=None, namespace=None, label_selectors=None, field_selectors=None, def kubernetes_facts(self, kind, api_version, name=None, namespace=None, label_selectors=None, field_selectors=None,
wait=False, wait_sleep=5, wait_timeout=120, state='present', condition=None, wait_property=None): wait=False, wait_sleep=5, wait_timeout=120, state='present', condition=None, property=None):
resource = self.find_resource(kind, api_version) resource = self.find_resource(kind, api_version)
api_found = bool(resource) api_found = bool(resource)
if not api_found: if not api_found:
@@ -298,7 +298,7 @@ class K8sAnsibleMixin(object):
for resource_instance in resource_list: for resource_instance in resource_list:
success, res, duration = self.wait(resource, resource_instance, success, res, duration = self.wait(resource, resource_instance,
sleep=wait_sleep, timeout=wait_timeout, sleep=wait_sleep, timeout=wait_timeout,
state=state, condition=condition, wait_property=wait_property) state=state, condition=condition, property=property)
if not success: if not success:
self.fail(msg="Failed to gather information about %s(s) even" self.fail(msg="Failed to gather information about %s(s) even"
" after waiting for %s seconds" % (res.get('kind'), duration)) " after waiting for %s seconds" % (res.get('kind'), duration))

View File

@@ -140,6 +140,7 @@ requirements:
- "kubernetes >= 12.0.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
- "jsonpatch" - "jsonpatch"
- "jmespath"
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@@ -249,6 +250,7 @@ EXAMPLES = r'''
wait_condition: wait_condition:
type: Progressing type: Progressing
status: Unknown status: Unknown
reason: DeploymentPaused
# Wait for this service to have acquired an External IP # Wait for this service to have acquired an External IP
- name: Create ingress and wait for ip to be assigned - name: Create ingress and wait for ip to be assigned

View File

@@ -52,7 +52,7 @@ requirements:
- "python >= 3.6" - "python >= 3.6"
- "kubernetes >= 12.0.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
- "jsonpath-rw" - "jmespath"
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@@ -165,7 +165,7 @@ def execute_module(module, k8s_ansible_mixin):
wait_sleep=module.params["wait_sleep"], wait_sleep=module.params["wait_sleep"],
wait_timeout=module.params["wait_timeout"], wait_timeout=module.params["wait_timeout"],
condition=module.params["wait_condition"], condition=module.params["wait_condition"],
wait_for=module.params["wait_for"] property=module.params["wait_property"]
) )
module.exit_json(changed=False, **facts) module.exit_json(changed=False, **facts)

View File

@@ -34,7 +34,6 @@ requirements:
- "python >= 3.6" - "python >= 3.6"
- "kubernetes >= 12.0.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
- "jsonpath-rw"
''' '''
EXAMPLES = r''' EXAMPLES = r'''