Commit Graph

91 Commits

Author SHA1 Message Date
Abhijeet Kasurde
f03d2ce243 k8s_info: Add support for wait (#235)
Fixes: #18
2020-09-28 10:52:00 +05:30
Abhijeet Kasurde
308956b313 Replace KubernetesRawModule class (#231)
* Migrate from KubernetesRawModule to K8sAnsibleMixin
* Modified k8s.py
* Modified k8s_service.py

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-09-19 09:54:40 +05:30
Abhijeet Kasurde
51cadb7150 Replace KubernetesAnsibleModule class with dummy class (#227)
* Make an AnsibleMixin parent class for every module
* Replace KubernetesAnsibleModule class with dummy class
* Modified k8s_log
* k8s_exec refactor
* k8s_info refactor
* k8s_service refactor
* k8s_scale refactor
* Fix integration tests
* Add a warning about the deprecation of KubernetesAnsibleModule
* Add a dummy class for backward compatibility

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-09-16 20:35:05 +05:30
Fabian von Feilitzsch
28dcf76cfb Merge pull request #228 from fabianvf/ignore-diff-with-warning
Do not mark task as changed when diff is irrelevant
2020-09-15 14:42:08 -04:00
Fabian von Feilitzsch
1ea0fa1c70 Merge pull request #229 from Akasurde/helm_kubeconfig_fix
helm: Support vaulted kubeconfig
2020-09-15 14:41:54 -04:00
Fabian von Feilitzsch
571406ce47 Merge pull request #224 from Akasurde/handle_exc
handle exception raised due to DynamicClient
2020-09-15 14:40:59 -04:00
Abhijeet Kasurde
f2b1b267a5 helm: Support vaulted kubeconfig
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-09-15 13:56:43 +05:30
Fabian von Feilitzsch
0afe40e657 Do not mark task as changed when diff is irrelevant
When the diff contains changes only to the fields `metadata.generation`
or `metadata.resourceVersion`, do not mark the task as changed. Instead,
   emit a warning highlighting that the API itself may not be
   idempotent, but that there was no meaningful difference between the
   desired and actual state of the resource.
2020-09-14 15:51:08 -04:00
Abhijeet Kasurde
527859c9cd Refactor module_utils (#223)
Moved a bunch of common things to module_utils.
2020-09-08 20:37:16 +05:30
Abhijeet Kasurde
ffb7032dc2 handle exception raised due to DynamicClient
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-09-07 19:03:28 +05:30
Abhijeet Kasurde
c49f896fa0 helm: Add replace parameter (#214)
Fixes: #106

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-09-07 12:42:00 +05:30
Abhijeet Kasurde
23f9588732 kubectl: correct usage in console (#204)
kubectl exec is printed twice in the console log.

Fixes: #200

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-08-31 09:29:27 +05:30
Fabian von Feilitzsch
1c5a8fd49f Set the connection plugin and transport separately, add tests 2020-08-26 14:48:40 -04:00
Abhijeet Kasurde
16059a8111 k8s_*: Group argument_spec accroding to usage (#199)
Partially fix #36

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-08-26 19:48:07 +05:30
Abhijeet Kasurde
d39fcfc2d8 k8s_*: Add support for vaulted kubeconfig and src (#193) 2020-08-26 10:22:47 +05:30
Abhijeet Kasurde
ab77b79f9c k8s_info: Update documentation
* Used name_option doc_fragments
* Updated doc formatting
* Updated k8s_info example for custom resource

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-08-24 15:47:00 +05:30
Abhijeet Kasurde
4f33ba7b39 raw: Handle exception raised by underlying APIs (#180)
kind can be provided by number of ways. It is diffcult to
find all cases. So, handle exceptions raised by underlying
APIs and provide good error message to user.

Fixes: ansible/ansible#63652

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-08-11 11:12:53 +05:30
Jeff Geerling
1ef28bcd73 Issue #171: Update changelog and make sure things are ready for 1.0.0 release. 2020-07-28 10:37:15 -05:00
Jeff Geerling
b51bbdf200 Issue #171: Update changelog fragments for 1.0.0 release. 2020-07-28 10:37:15 -05:00
Abhijeet Kasurde
3aaf182c30 k8s_exec: Return rc for the command executed (#158)
k8s_exec now returns command return code in output.

Fixes: #122

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-07-23 10:52:26 +05:30
Abhijeet Kasurde
6c059bd2bc helm_plugin and helm_plugin_info: new module (#154)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-07-22 09:14:23 +05:30
Abhijeet Kasurde
c4f3e5a034 k8s_info: Update example using vars (#156)
Fixes: #151

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-07-13 16:35:33 +05:30
Abhijeet Kasurde
6b28ef3c17 kubectl: redacted token and password from console log (#159)
** SECURITY_FIX ** for CVE-2020-1753

kubectl connection plugin now redact kubectl_token and
kubectl_password from console log.

Fixes: #65

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-07-11 08:50:15 +05:30
LucasBoisserie
3e971e0ad3 Create ns with helm (#157)
Added support `--create-namespace` in helm module.
2020-07-11 08:45:22 +05:30
Fabian von Feilitzsch
806c808c9d Merge pull request #155 from willthames/check_mode_results
Ensure check mode results are as expected
2020-07-10 16:04:42 -04:00
Fabian von Feilitzsch
dd4ebf2194 Merge pull request #152 from Akasurde/context_aliases
helm_: Add context aliases for kube_context
2020-07-10 15:55:51 -04:00
Will Thames
e3223a8f60 Ensure check mode results are as expected
check_mode with wait updates the result based on the existing resource
which won't change with check_mode, so returns incorrect results.
Only run the wait checks in non check_mode (this also avoids the issue
of waiting for resource creation that will never happen in check mode)
2020-07-08 21:47:23 +10:00
Yaakov Selkowitz
9aa85e8eb5 Update openshift requirements in k8s module doc 2020-07-06 11:10:59 -04:00
Abhijeet Kasurde
48a45de8b0 helm_: Add context aliases for kube_context
Added 'context' aliases for 'kube_context' in
helm and helm_info module.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-07-06 11:18:23 +05:30
Abhijeet Kasurde
ef6722d290 helm: Add support for K8S_AUTH_CONTEXT, K8S_AUTH_KUBECONFIG env (#141)
Added support for K8S_AUTH_CONTEXT, K8S_AUTH_KUBECONFIG env
2020-07-02 18:48:41 +05:30
Jeff Geerling
881ca3d006 Fixes #145: Use FQCN in module docs and in plugin examples. 2020-06-29 16:25:42 -05:00
Abhijeet Kasurde
9fb808c7f3 k8s: Fix a bug when manifest file ends with '---' (#139)
Any kubernetes manifest file ending with '---' will
generate an error when applied using 'k8s' module.

Although this may not be 'legal' YAML, this is quite frequent,
specially on helm's generated manifest files.

migrated from https://github.com/ansible/ansible/pull/59160

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-06-25 09:11:03 +10:00
Abhijeet Kasurde
5b7046470e helm: Add option 'atomic'
helm command provides option to remove installation on failure using
'atomic' flag.
This fix adds this parameter in helm module.

Fixes: #109

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-06-18 17:01:45 +05:30
Abhijeet Kasurde
3004c8d3f0 Handle invalid kubeconfig parsing error (#119)
Provide message to user about invalid or empty kubeconfig
by handling exception raised by kubernetes Python API

Fixes: #90

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-06-16 11:03:08 +05:30
Jeff Geerling
0e92889d34 Merge pull request #123 from willthames/flake8
Flake8
2020-06-15 12:34:46 -05:00
Will Thames
510a069de9 F841 remove unused variables 2020-06-09 19:00:21 +10:00
Will Thames
43ae9664fc W504 Move binary operator to start of line from end of line
PEP8 prefers binary operators at the start of a line
https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator
2020-06-09 19:00:21 +10:00
Will Thames
59348066a0 F401: Remove unused imports 2020-06-09 19:00:21 +10:00
Will Thames
4b7db6f7f9 Use improved kubernetes diffs where possible
Use information from strategic merges to improve
the quality of diffs, particularly for list items
(order no longer important, and adding/removing an
item from a list just shows that item in the diff,
not the whole list)
2020-06-08 19:35:59 +10:00
Abhijeet Kasurde
18dfb687e6 Handle set object retrieved from lookup plugin (#118)
api_groups is returned as "dict_keys()" which k8s lookip plugin does not handle.
Typecasting with list make it available to default callback plugin.
2020-06-05 12:18:57 +05:30
Abhijeet Kasurde
c8ef0ae1ad Minor refactor in helm_info and helm_repository (#117)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-06-05 12:16:56 +05:30
Abhijeet Kasurde
3078131db5 Minor doc fixes (#114)
* Spelling fixes
* Documentation update
* Example update to use FQCN

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-06-05 11:32:26 +05:30
Fabian von Feilitzsch
01399ea840 Merge pull request #110 from Akasurde/helm_fix
helm: minor code refactoring
2020-06-04 11:48:40 -04:00
Abhijeet Kasurde
9a952697a2 Minor documentation fix (#113)
Inventory plugin example should read 'api_key' instead of 'token'

Fixes: #101

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-06-02 15:49:04 +10:00
Abhijeet Kasurde
641fbd92f5 helm: minor code refactoring
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-06-01 18:55:30 +05:30
Will Thames
beebe98ce6 Fix scale wait and add tests
Move wait logic out of raw and into common and use that
logic in scale

Fix a few broken wait condition cases highlighted by scaling
up and down

Move scale-related tests into dedicated test task file

Additional service related tests
2020-05-22 12:39:43 +10:00
Toshio Kuratomi
d9ece473dd Fix the docs for the inventory plugins.
Documenting the structure of the dictionary to pass in needs to be done
via suboptions rather than putting the structure directoly inside of the
toplevel option.
2020-05-20 07:48:35 -07:00
Fabian von Feilitzsch
2f7b55270d Merge pull request #35 from willthames/wait_conditions
Make deployments and daemonsets wait for pods to be ready
2020-05-19 13:38:35 -04:00
Fabian von Feilitzsch
9ccec43c6e Merge pull request #84 from willthames/k8s_apply_check_mode_fix
K8s apply check mode fix
2020-05-15 12:58:40 -04:00
Will Thames
35ffd0e431 Improve k8s Deployment and Daemonset wait conditions
Ensure that Deployments and Daemonsets properly await
all replicas to be available. Correctly handles the
subtle edge case when a service account no longer exists.

Note that this will dramatically slow Daemonset updates
2020-05-15 09:24:35 +10:00