k8s_info: Add support for wait (#235)

Fixes: #18
This commit is contained in:
Abhijeet Kasurde
2020-09-28 10:52:00 +05:30
committed by GitHub
parent 70a4b068ff
commit f03d2ce243
7 changed files with 331 additions and 85 deletions

View File

@@ -46,6 +46,7 @@ options:
extends_documentation_fragment:
- community.kubernetes.k8s_auth_options
- community.kubernetes.k8s_name_options
- community.kubernetes.k8s_wait_options
requirements:
- "python >= 2.7"
@@ -99,6 +100,15 @@ EXAMPLES = r'''
community.kubernetes.k8s_info:
kind: MyCustomObject
api_version: "stable.example.com/v1"
- name: Wait till the Object is created
community.kubernetes.k8s_info:
kind: Pod
wait: yes
name: pod-not-yet-created
namespace: default
wait_sleep: 10
wait_timeout: 360
'''
RETURN = r'''
@@ -134,7 +144,7 @@ import copy
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.kubernetes.plugins.module_utils.common import (
K8sAnsibleMixin, AUTH_ARG_SPEC)
K8sAnsibleMixin, AUTH_ARG_SPEC, WAIT_ARG_SPEC)
class KubernetesInfoModule(K8sAnsibleMixin):
@@ -156,14 +166,19 @@ class KubernetesInfoModule(K8sAnsibleMixin):
self.exit_json(changed=False,
**self.kubernetes_facts(self.params['kind'],
self.params['api_version'],
self.params['name'],
self.params['namespace'],
self.params['label_selectors'],
self.params['field_selectors']))
name=self.params['name'],
namespace=self.params['namespace'],
label_selectors=self.params['label_selectors'],
field_selectors=self.params['field_selectors'],
wait=self.params['wait'],
wait_sleep=self.params['wait_sleep'],
wait_timeout=self.params['wait_timeout'],
condition=self.params['wait_condition']))
@property
def argspec(self):
args = copy.deepcopy(AUTH_ARG_SPEC)
args.update(WAIT_ARG_SPEC)
args.update(
dict(
kind=dict(required=True),