Esempio n. 1
0
def main():
    module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True)
    from ansible_collections.kubernetes.core.plugins.module_utils.common import (
        K8sAnsibleMixin, get_api_client)

    k8s_ansible_mixin = K8sAnsibleMixin(module)
    k8s_ansible_mixin.client = get_api_client(module=module)
    execute_module(module, k8s_ansible_mixin)
Esempio n. 2
0
def main():
    args = copy.deepcopy(AUTH_ARG_SPEC)
    args.update(copy.deepcopy(WAIT_ARG_SPEC))
    args.update(JSON_PATCH_ARGS)
    module = AnsibleModule(argument_spec=args, supports_check_mode=True)
    k8s_module = K8sAnsibleMixin(module)
    k8s_module.params = module.params
    k8s_module.check_library_version()
    client = get_api_client(module)
    k8s_module.client = client
    execute_module(k8s_module, module)
def main():
    mutually_exclusive = [
        ('resource_definition', 'src'),
    ]
    module = AnsibleModule(argument_spec=argspec(),
                           mutually_exclusive=mutually_exclusive,
                           supports_check_mode=True)
    from ansible_collections.kubernetes.core.plugins.module_utils.common import (
        K8sAnsibleMixin, get_api_client)
    k8s_ansible_mixin = K8sAnsibleMixin(module)
    k8s_ansible_mixin.client = get_api_client(module=module)
    execute_module(module, k8s_ansible_mixin)
Esempio n. 4
0
 def __init__(self, module):
     self.module = module
     self.k8s_ansible_mixin = K8sAnsibleMixin(module=self.module)
     self.k8s_ansible_mixin.client = get_api_client(module=self.module)
     self.k8s_ansible_mixin.module = self.module
     self.k8s_ansible_mixin.argspec = self.module.argument_spec
     self.k8s_ansible_mixin.check_mode = self.module.check_mode
     self.k8s_ansible_mixin.params = self.module.params
     self.k8s_ansible_mixin.fail_json = self.module.fail_json
     self.k8s_ansible_mixin.fail = self.module.fail_json
     self.k8s_ansible_mixin.exit_json = self.module.exit_json
     self.k8s_ansible_mixin.warn = self.module.warn
     self.k8s_ansible_mixin.warnings = []
     self.api_instance = core_v1_api.CoreV1Api(
         self.k8s_ansible_mixin.client.client)
     self.k8s_ansible_mixin.check_library_version()
     self.changed = False
Esempio n. 5
0
    def __init__(self, module):
        from ansible_collections.kubernetes.core.plugins.module_utils.common import (
            K8sAnsibleMixin,
            get_api_client,
        )

        self._module = module
        self._k8s_ansible_mixin = K8sAnsibleMixin(module)
        self._k8s_ansible_mixin.client = get_api_client(module=self._module)

        self._k8s_ansible_mixin.module = self._module
        self._k8s_ansible_mixin.argspec = self._module.argument_spec
        self._k8s_ansible_mixin.check_mode = self._module.check_mode
        self._k8s_ansible_mixin.params = self._module.params
        self._k8s_ansible_mixin.fail_json = self._module.fail_json
        self._k8s_ansible_mixin.fail = self._module.fail_json
        self._k8s_ansible_mixin.exit_json = self._module.exit_json
        self._k8s_ansible_mixin.warn = self._module.warn
        self._k8s_ansible_mixin.warnings = []

        self._api_instance = core_v1_api.CoreV1Api(
            self._k8s_ansible_mixin.client.client
        )
        self._k8s_ansible_mixin.check_library_version()

        # delete options
        self._drain_options = module.params.get("delete_options", {})
        self._delete_options = None
        if self._drain_options.get("terminate_grace_period"):
            self._delete_options = {}
            self._delete_options.update({"apiVersion": "v1"})
            self._delete_options.update({"kind": "DeleteOptions"})
            self._delete_options.update(
                {
                    "gracePeriodSeconds": self._drain_options.get(
                        "terminate_grace_period"
                    )
                }
            )

        self._changed = False
Esempio n. 6
0
def main():
    mutually_exclusive = [
        ("resource_definition", "src"),
        ("merge_type", "apply"),
        ("template", "resource_definition"),
        ("template", "src"),
        ("name", "generate_name"),
    ]
    module = AnsibleModule(
        argument_spec=argspec(),
        mutually_exclusive=mutually_exclusive,
        supports_check_mode=True,
    )
    from ansible_collections.kubernetes.core.plugins.module_utils.common import (
        K8sAnsibleMixin,
        get_api_client,
    )

    k8s_ansible_mixin = K8sAnsibleMixin(module)
    k8s_ansible_mixin.client = get_api_client(module=module)
    execute_module(module, k8s_ansible_mixin)
Esempio n. 7
0
 def _get_host(connectionConfig):
     client = K8sAnsibleMixin().get_api_client(**connectionConfig)
     url = client.configuration.host
     if url:
         return re.sub("^https?://", "", url)
     return url