Пример #1
0
    def __init__(self, *args, **kwargs):
        kwargs['argument_spec'] = self.argspec
        AnsibleModule.__init__(self, *args, **kwargs)
        K8sAnsibleMixin.__init__(self, *args, **kwargs)

        self.warn("class KubernetesAnsibleModule is deprecated"
                  " and will be removed in 2.0.0. Please use K8sAnsibleMixin instead.")
Пример #2
0
    def __init__(self, kind, api_version):
        self.api_version = api_version
        self.kind = kind
        self.argspec_cache = None

        if not HAS_K8S_MODULE_HELPER:
            raise KubernetesAnsibleException(
                "This module requires the OpenShift Python client. Try `pip install openshift`"
            )

        if not HAS_YAML:
            raise KubernetesAnsibleException(
                "This module requires PyYAML. Try `pip install PyYAML`"
            )

        try:
            self.helper = self.get_helper(api_version, kind)
        except Exception as exc:
            raise KubernetesAnsibleException(
                "Error initializing AnsibleModuleHelper: {}".format(exc)
            )

        mutually_exclusive = (
            ('resource_definition', 'src'),
        )

        AnsibleModule.__init__(self,
                               argument_spec=self.argspec,
                               supports_check_mode=True,
                               mutually_exclusive=mutually_exclusive)
Пример #3
0
    def __init__(self, *args, **kwargs):
        arg_spec = {}
        if 'argument_spec' in kwargs:
            arg_spec = kwargs['argument_spec']

        kwargs['argument_spec'] = self._merge_dictionaries(
            arg_spec,
            dict(project=dict(required=True, type='str'),
                 auth_kind=dict(required=False,
                                fallback=(env_fallback, ['GCP_AUTH_KIND']),
                                choices=[
                                    'machineaccount', 'serviceaccount',
                                    'application'
                                ],
                                type='str'),
                 service_account_email=dict(
                     required=False,
                     fallback=(env_fallback, ['GCP_SERVICE_ACCOUNT_EMAIL']),
                     type='str'),
                 service_account_file=dict(
                     required=False,
                     fallback=(env_fallback, ['GCP_SERVICE_ACCOUNT_FILE']),
                     type='path'),
                 scopes=dict(required=False,
                             fallback=(env_fallback, ['GCP_SCOPES']),
                             type='list')))

        mutual = []
        if 'mutually_exclusive' in kwargs:
            mutual = kwargs['mutually_exclusive']

        kwargs['mutually_exclusive'] = mutual.append(
            ['service_account_email', 'service_account_file'])

        AnsibleModule.__init__(self, *args, **kwargs)
Пример #4
0
    def __init__(self, kind, api_version):
        self.api_version = api_version
        self.kind = kind
        self.argspec_cache = None

        if not HAS_K8S_MODULE_HELPER:
            raise KubernetesAnsibleException(
                "This module requires the OpenShift Python client. Try `pip install openshift`"
            )

        if not HAS_YAML:
            raise KubernetesAnsibleException(
                "This module requires PyYAML. Try `pip install PyYAML`")

        try:
            self.helper = self.get_helper(api_version, kind)
        except Exception as exc:
            raise KubernetesAnsibleException(
                "Error initializing AnsibleModuleHelper: {}".format(exc))

        mutually_exclusive = (('resource_definition', 'src'), )

        AnsibleModule.__init__(self,
                               argument_spec=self.argspec,
                               supports_check_mode=True,
                               mutually_exclusive=mutually_exclusive)
Пример #5
0
    def __init__(self, *args, **kwargs):

        kwargs['argument_spec'] = self.argspec
        AnsibleModule.__init__(self, *args, **kwargs)

        if not HAS_K8S_MODULE_HELPER:
            self.fail_json(msg="This module requires the OpenShift Python client. Try `pip install openshift`")

        if not HAS_YAML:
            self.fail_json(msg="This module requires PyYAML. Try `pip install PyYAML`")
Пример #6
0
    def __init__(self, *args, **kwargs):

        kwargs['argument_spec'] = self.argspec
        AnsibleModule.__init__(self, *args, **kwargs)

        if not HAS_K8S_MODULE_HELPER:
            self.fail_json(msg="This module requires the OpenShift Python client. Try `pip install openshift`", error=str(k8s_import_exception))
        self.openshift_version = openshift.__version__

        if not HAS_YAML:
            self.fail_json(msg="This module requires PyYAML. Try `pip install PyYAML`")
Пример #7
0
    def __init__(self, *args, **kwargs):

        kwargs['argument_spec'] = self.argspec
        AnsibleModule.__init__(self, *args, **kwargs)

        if not HAS_K8S_MODULE_HELPER:
            self.fail_json(msg=missing_required_lib('openshift'), exception=K8S_IMP_ERR,
                           error=to_native(k8s_import_exception))
        self.openshift_version = openshift.__version__

        if not HAS_YAML:
            self.fail_json(msg=missing_required_lib("PyYAML"), exception=YAML_IMP_ERR)
Пример #8
0
    def __init__(self, *args, **kwargs):

        kwargs['argument_spec'] = self.argspec
        AnsibleModule.__init__(self, *args, **kwargs)

        if not HAS_K8S_MODULE_HELPER:
            self.fail_json(msg="This module requires the OpenShift Python client. Try `pip install openshift`")

        if not HAS_YAML:
            self.fail_json(msg="This module requires PyYAML. Try `pip install PyYAML`")

        if not HAS_STRING_UTILS:
            self.fail_json(msg="This module requires Python string utils. Try `pip install python-string-utils`")
Пример #9
0
 def __init__(self, *args, **kwargs):
     AnsibleModule.__init__(self,
                            argument_spec=dict(
                                kubeconfig=dict(required=False,
                                                type='dict'),
                                context=dict(required=False, type='str'),
                                namespace=dict(required=False, type='str'),
                                debug=dict(required=False,
                                           type='bool',
                                           default='false'),
                                definition=dict(required=False, type='str'),
                                src=dict(required=False, type='str'),
                            ))
Пример #10
0
    def __init__(self):

        if not HAS_K8S_MODULE_HELPER:
            raise Exception(
                "This module requires the OpenShift Python client. Try `pip install openshift`"
            )

        if not HAS_YAML:
            raise Exception(
                "This module requires PyYAML. Try `pip install PyYAML`"
            )

        if not HAS_STRING_UTILS:
            raise Exception(
                "This module requires Python string utils. Try `pip install python-string-utils`"
            )

        mutually_exclusive = [
            ('resource_definition', 'src'),
        ]

        AnsibleModule.__init__(self,
                               argument_spec=self._argspec,
                               supports_check_mode=True,
                               mutually_exclusive=mutually_exclusive)

        self.kind = self.params.pop('kind')
        self.api_version = self.params.pop('api_version')
        self.resource_definition = self.params.pop('resource_definition')
        self.src = self.params.pop('src')
        if self.src:
            self.resource_definition = self.load_resource_definition(self.src)

        if self.resource_definition:
            self.api_version = self.resource_definition.get('apiVersion')
            self.kind = self.resource_definition.get('kind')

        self.api_version = self.api_version.lower()
        self.kind = self._to_snake(self.kind)

        if not self.api_version:
            self.fail_json(
                msg=("Error: no api_version specified. Use the api_version parameter, or provide it as part of a ",
                     "resource_definition.")
            )
        if not self.kind:
            self.fail_json(
                msg="Error: no kind specified. Use the kind parameter, or provide it as part of a resource_definition"
            )

        self.helper = self._get_helper(self.api_version, self.kind)
Пример #11
0
 def __init__(self, *args, **kwargs):
     AnsibleModule.__init__(
         self,
         argument_spec=dict(
             chart=dict(type='dict'),
             release=dict(type='str', aliases=['name']),
             namespace=dict(type='str'),
             binary=dict(type='str'),
             state=dict(default='present',
                        choice=['latest', 'present', 'absent', 'purged']),
             values=dict(type='list'),
         ))
     self._helm_bin = None
     self.delete_temp_file = True
Пример #12
0
    def __init__(self):
        AnsibleModule.__init__(
            self,
            argument_spec=K8S_AUTH_ARG_SPEC,
            required_if=[
                ('state', 'present', ['username', 'password']),
                ('state', 'absent', ['api_key']),
            ]
        )

        if not HAS_REQUESTS:
            self.fail("This module requires the python 'requests' package. Try `pip install requests`.")

        if not HAS_REQUESTS_OAUTH:
            self.fail("This module requires the python 'requests-oauthlib' package. Try `pip install requests-oauthlib`.")

        if not HAS_URLLIB3:
            self.fail("This module requires the python 'urllib3' package. Try `pip install urllib3`.")
Пример #13
0
    def __init__(self, *args, **kwargs):

        if not HAS_K8S_MODULE_HELPER:
            raise Exception(
                "This module requires the OpenShift Python client. Try `pip install openshift`"
            )

        if not HAS_YAML:
            raise Exception(
                "This module requires PyYAML. Try `pip install PyYAML`")

        if not HAS_STRING_UTILS:
            raise Exception(
                "This module requires Python string utils. Try `pip install python-string-utils`"
            )

        kwargs['argument_spec'] = self.argspec
        AnsibleModule.__init__(self, *args, **kwargs)
Пример #14
0
    def __init__(self, *args, **kwargs):
        arg_spec = kwargs.get('argument_spec', {})

        kwargs['argument_spec'] = self._merge_dictionaries(
            arg_spec,
            dict(project=dict(required=False,
                              type='str',
                              fallback=(env_fallback, ['GCP_PROJECT'])),
                 auth_kind=dict(required=True,
                                fallback=(env_fallback, ['GCP_AUTH_KIND']),
                                choices=[
                                    'machineaccount', 'serviceaccount',
                                    'application'
                                ],
                                type='str'),
                 service_account_email=dict(
                     required=False,
                     fallback=(env_fallback, ['GCP_SERVICE_ACCOUNT_EMAIL']),
                     type='str'),
                 service_account_file=dict(
                     required=False,
                     fallback=(env_fallback, ['GCP_SERVICE_ACCOUNT_FILE']),
                     type='path'),
                 service_account_contents=dict(
                     required=False,
                     fallback=(env_fallback, ['GCP_SERVICE_ACCOUNT_CONTENTS']),
                     no_log=True,
                     type='jsonarg'),
                 scopes=dict(required=False,
                             fallback=(env_fallback, ['GCP_SCOPES']),
                             type='list',
                             elements='str'),
                 env_type=dict(required=False,
                               fallback=(env_fallback, ['GCP_ENV_TYPE']),
                               type='str')))

        mutual = kwargs.get('mutually_exclusive', [])

        kwargs['mutually_exclusive'] = mutual.append([
            'service_account_email', 'service_account_file',
            'service_account_contents'
        ])

        AnsibleModule.__init__(self, *args, **kwargs)
Пример #15
0
 def __init__(self, *args, **kwargs):
     # TODO: add support for template name, pre-existing on server
     # TODO: check for conflicting params
     # TODO: support parameter files
     AnsibleModule.__init__(self,
                            argument_spec=dict(
                                kubeconfig=dict(required=False,
                                                type='dict'),
                                context=dict(required=False, type='str'),
                                namespace=dict(required=False, type='str'),
                                debug=dict(required=False,
                                           type='bool',
                                           default='false'),
                                template_definition=dict(required=False,
                                                         type='str'),
                                template_file=dict(required=False,
                                                   type='str'),
                                parameters=dict(required=False,
                                                type='dict'),
                            ))
Пример #16
0
    def __init__(self, *args, **kwargs):
        arg_spec = {}
        if 'argument_spec' in kwargs:
            arg_spec = kwargs['argument_spec']

        kwargs['argument_spec'] = self._merge_dictionaries(
            arg_spec,
            dict(
                project=dict(required=True, type='str'),
                auth_kind=dict(
                    required=False,
                    fallback=(env_fallback, ['GCP_AUTH_KIND']),
                    choices=['machineaccount', 'serviceaccount', 'application'],
                    type='str'),
                service_account_email=dict(
                    required=False,
                    fallback=(env_fallback, ['GCP_SERVICE_ACCOUNT_EMAIL']),
                    type='str'),
                service_account_file=dict(
                    required=False,
                    fallback=(env_fallback, ['GCP_SERVICE_ACCOUNT_FILE']),
                    type='path'),
                scopes=dict(
                    required=False,
                    fallback=(env_fallback, ['GCP_SCOPES']),
                    type='list')
            )
        )

        mutual = []
        if 'mutually_exclusive' in kwargs:
            mutual = kwargs['mutually_exclusive']

        kwargs['mutually_exclusive'] = mutual.append(
            ['service_account_email', 'service_account_file']
        )

        AnsibleModule.__init__(self, *args, **kwargs)
Пример #17
0
 def __init__(self, *args, **kwargs):
     kwargs['argument_spec'] = self.argspec
     kwargs['supports_check_mode'] = True
     AnsibleModule.__init__(self, *args, **kwargs)
Пример #18
0
    def __init__(self, argument_spec, supports_check_mode):
        argument_spec.update(JBOSS_COMMON_ARGS)

        AnsibleModule.__init__(self, argument_spec=argument_spec, supports_check_mode=supports_check_mode)