Commit Graph

195 Commits

Author SHA1 Message Date
GomathiselviS
1670e35cd8 Update python kubernetes library to 24.2.0 , helm/kind-action to 1.8.0 2023-11-15 15:43:15 -05:00
Bikouo Aubin
b44fdd3f05 helm - fix issue for helm command when chart contains space into its name (#657)
* fix issue for helm command when chart contains space into its name
2023-11-13 11:48:13 +01:00
GomathiselviS
b066a2dda3 Cleanup GitHub workflows (#655)
* Cleanup gha

* test by removing matrix excludes

* Rename sanity tests

* trigger integration tests

* Fix ansible-lint workflow

* Fix concurrency

* Add ansible-lint config

* Add ansible-lint config

* Fix integration and lint issues

* integration wf

* fix yamllint issues

* fix yamllint issues

* update readme and add ignore-2.16.txt

* fix ansible-doc

* Add version

* Use /dev/random to generate random data

The GHA environment has difficultly generating entropy. Trying to read
from /dev/urandom just blocks forever. We don't care if the random data
is cryptographically secure; it's just garbage data for the test. Read
from /dev/random, instead. This is only used during the k8s_copy test
target.

This also removes the custom test module that was being used to generate
the files. It's not worth maintaining this for two task that can be
replaced with some simple command/shell tasks.

* Fix saniry errors

* test github_action fix

* Address review comments

* Remove default types

* review comments

* isort fixes

* remove tags

* Add setuptools to venv

* Test gh changes

* update changelog

* update ignore-2.16

* Fix indentation in inventory plugin example

* Update .github/workflows/integration-tests.yaml

* Update integration-tests.yaml

---------

Co-authored-by: Mike Graves <mgraves@redhat.com>
Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
2023-11-10 16:33:40 +01:00
Will Thames
9e9962bc6c Provide a mechanism to hide fields from output (#629)
Provide a mechanism to hide fields from output

SUMMARY
The k8s and k8s_info modules can be a little noisy in verbose mode, and most of that is due to managedFields.
If we can provide a mechanism to hide managedFields, the output is a lot more useful.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
k8s, k8s_info
ADDITIONAL INFORMATION
Before
ANSIBLE_COLLECTIONS_PATH=../../.. ansible -m k8s_info -a 'kind=ConfigMap name=hide-fields-cm namespace=hide-fields' localhost 
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | SUCCESS => {
    "api_found": true,
    "changed": false,
    "resources": [
        {
            "apiVersion": "v1",
            "data": {
                "another": "value",
                "hello": "world"
            },
            "kind": "ConfigMap",
            "metadata": {
                "annotations": {
                    "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"data\":{\"another\":\"value\",\"hello\":\"world\"},\"kind\":\"ConfigMap\",\"metadata\":{\"annotations\":{},\"name\":\"hide-fields-cm\",\"namespace\":\"hide-fields\"}}\n"
                },
                "creationTimestamp": "2023-06-13T01:47:47Z",
                "managedFields": [
                    {
                        "apiVersion": "v1",
                        "fieldsType": "FieldsV1",
                        "fieldsV1": {
                            "f:data": {
                                ".": {},
                                "f:another": {},
                                "f:hello": {}
                            },
                            "f:metadata": {
                                "f:annotations": {
                                    ".": {},
                                    "f:kubectl.kubernetes.io/last-applied-configuration": {}
                                }
                            }
                        },
                        "manager": "kubectl-client-side-apply",
                        "operation": "Update",
                        "time": "2023-06-13T01:47:47Z"
                    }
                ],
                "name": "hide-fields-cm",
                "namespace": "hide-fields",
                "resourceVersion": "2557394",
                "uid": "f233da63-6374-4079-9825-3562c0ed123c"
            }
        }
    ]
}

After
ANSIBLE_COLLECTIONS_PATH=../../.. ansible -m k8s_info -a 'kind=ConfigMap name=hide-fields-cm namespace=hide-fields hidden_fields=metadata.managedFields' localhost
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | SUCCESS => {
    "api_found": true,
    "changed": false,
    "resources": [
        {
            "apiVersion": "v1",
            "data": {
                "another": "value",
                "hello": "world"
            },
            "kind": "ConfigMap",
            "metadata": {
                "annotations": {
                    "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"data\":{\"another\":\"value\",\"hello\":\"world\"},\"kind\":\"ConfigMap\",\"metadata\":{\"annotations\":{},\"name\":\"hide-fields-cm\",\"namespace\":\"hide-fields\"}}\n"
                },
                "creationTimestamp": "2023-06-13T01:47:47Z",
                "name": "hide-fields-cm",
                "namespace": "hide-fields",
                "resourceVersion": "2557394",
                "uid": "f233da63-6374-4079-9825-3562c0ed123c"
            }
        }
    ]
}

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Will Thames
2023-06-21 07:57:53 +00:00
Bikouo Aubin
6d0a3af311 add ability to filter the list of pods to be drained by a pod label selector (#606)
* add ability to filter the list of pods to be drained by a label selector
2023-05-31 09:12:09 +02:00
GomathiselviS
54d8193972 Add unit and sanity tests to GHA (#614)
* Add unit and sanity tests to GHA

Signed-off-by: GomathiselviS <gomathiselvi@gmail.com>

* Fix sanity issues

* Add sanity non voting

* Add changelog

* Fix typo

* Fix typo

* Use pytest-ansible

* Add support for pytest-ansible

---------

Signed-off-by: GomathiselviS <gomathiselvi@gmail.com>
2023-05-17 18:47:11 +02:00
Paul Voss
2d1ec22405 use post_renderer when checking 'changed' status for a helm release (#588)
use post_renderer when checking 'changed' status for a helm release

SUMMARY

helmdiff_check needs to use --post-renderer if configured in order to detect changes correctly
idempotency still seems to work
ISSUE TYPE


Bugfix Pull Request (50%)
Feature Pull Request (50%)

COMPONENT NAME

kubernetes.core.helm
ADDITIONAL INFORMATION



- /snap/bin/helm diff upgrade myrelease some/chart --version=1.2.3 --reset-values -f=/tmp/tmpnn0rr50h.yml
+ /snap/bin/helm diff upgrade myrelease some/chart --version=1.2.3 --reset-values --post-renderer=/tmp/somescript.sh -f=/tmp/tmpnn0rr50h.yml

Reviewed-by: Mike Graves <mgraves@redhat.com>
2023-04-05 13:50:36 +00:00
Paul Voss
8640c16cd4 fix post_renderer argument breaking the helm deploy_command (#586)
fix post_renderer arguments breaking the helm deploy_command

SUMMARY

The post_renderer setting is broken and resets the deploy_command instead of appending an argument. Diff should be self explanatory.
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

kubernetes.core.helm
ADDITIONAL INFORMATION

Reviewed-by: Mike Graves <mgraves@redhat.com>
2023-04-03 18:46:03 +00:00
Bikouo Aubin
151ed8245f make name optional to delete all resources for the specified resource type (#517)
make name optional to delete all resources for the specified resource type

SUMMARY

closes #504
k8s module should allow deleting all namespace resources for the specified resource type.

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

k8s
ADDITIONAL INFORMATION


Delete all Pods from namespace test

- k8s:
    namespace: test
    kind: Pod
    api_version: v1
    delete_all: true
    state: absent

Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Bikouo Aubin
2023-03-23 15:43:22 +00:00
Bikouo Aubin
09a3c837c3 [helm] add the ability for the module to uninstall pending-install releases (#589)
[helm] add the ability for the module to uninstall pending-install releases

SUMMARY

closes #319

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

helm

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Bikouo Aubin
2023-03-06 17:07:52 +00:00
Bikouo Aubin
031cc7c40d add reuse_values and reset_values support to helm module (#575)
helm - add reuse_values and reset_values support

SUMMARY

closes #394

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

helm
ADDITIONAL INFORMATION

Reviewed-by: Mike Graves <mgraves@redhat.com>
2023-02-16 07:47:33 +00:00
schwadim
22764492d2 Pass right amount of args to ResourceTimeout (#585)
Pass right amount of args to ResourceTimeout

SUMMARY
Pass right amount of args to ResourceTimeout
Fixes #583
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
k8s_scale
ADDITIONAL INFORMATION
ResourceTimeout constuructor does not accept variable argument length.
The passed result dict seems not to be used currently. One could also pass result["result"] or not pass result at all.

Reviewed-by: Mike Graves <mgraves@redhat.com>
2023-02-15 08:38:16 +00:00
Bikouo Aubin
3d313cf837 helm fix with release_values option set (#573)
helm - delete temporary file created when using option release_values

SUMMARY

closes #530

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

helm
2023-02-07 14:55:14 +00:00
Bikouo Aubin
af7c24cba7 helm - add support for -set options when running helm install (#546)
helm - add support for -set options when running helm install

SUMMARY

helm support setting options -set, -set-string, -set-file and -set-json when running helm install

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

helm
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Bikouo Aubin <None>
Reviewed-by: Mike Graves <mgraves@redhat.com>
2023-01-23 16:19:42 +00:00
Bikouo Aubin
804b9ab57c Helm - Fix issue with alternative kubeconfig (#563)
Helm - Fix issue with alternative kubeconfig

SUMMARY

closes #538

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

helm modules

Reviewed-by: Mike Graves <mgraves@redhat.com>
2023-01-12 09:46:42 +00:00
Bikouo Aubin
979b492233 k8s_cp: add support for check_mode, fix doc issue, remove dependency with 'find' when state=from_pod (#512)
k8s_cp: add support for check_mode, fix doc issue, remove dependency with 'find' when state=from_pod

Depends-On: ansible/ansible-zuul-jobs#1635
Depends-On: ansible/ansible-zuul-jobs#1636
Depends-On: #518
Depends-On: #520
SUMMARY

add support for check_mode, closes #380
fix doc issue, closes #485
Remove dependency with 'find' executable when state=from_pod, closes #486

ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request

Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Bikouo Aubin <None>
2022-12-09 16:00:14 +00:00
Bikouo Aubin
b967b55a16 k8s_log - fix issue when required name is not provided, add all_containers support (#528)
k8s_log - fix issue when required name is not provided, add all_containers support

SUMMARY

Fixes issue when the required name is not provided, closes #514
all support for all_containers option

ISSUE TYPE


Bugfix Pull Request
Feature Pull Request

COMPONENT NAME

k8s_log
ADDITIONAL INFORMATION

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Jill R <None>
2022-10-24 23:43:26 +00:00
Fors1
2a3862b67a Added possibility to get all values by helm_info module (#531)
Added possibility to get all values by helm_info module

SUMMARY
Parameter get_all_values has been added, which is passed to function get_values. Default is False. Parameter is not required.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
helm_info
ADDITIONAL INFORMATION
Unfortunately, helm_info module lacks functionality of getting all the values of a helm release, including the default ones. This restricts upgrade and config migration capabilities. Parameter get_all_values has been added. This parameter, if set, adds -a parameter to helm get values call. The parameter is not required and defaults to False, so backwards compability is complied.

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Bikouo Aubin <None>
2022-10-19 15:41:37 +00:00
Bikouo Aubin
2092d921cd helm - new module to perform helm pull (#410)
helm - new module to perform helm pull

Depends-On: ansible/ansible-zuul-jobs#1586
SUMMARY

#355
new module to manage chart downloading helm pull

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

helm_pull

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Bikouo Aubin <None>
2022-10-12 13:34:19 +00:00
Mike Graves
29c75fa1c6 Update for Ansible 2.15 sanity tests (#515)
Update for Ansible 2.15 sanity tests

Depends-On: ansible/ansible-zuul-jobs#1639
SUMMARY

Update for Ansible 2.15 sanity tests

Fixes #519
ISSUE TYPE

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Bikouo Aubin <None>
2022-10-06 09:50:26 +00:00
Mor Cohen
0e86fe0b7b [helm] Add the force_update arg (#509)
[helm] Add the force_update arg

Depends-On: ansible/ansible-zuul-jobs#1648
Depends-On: #522
SUMMARY
Sometimes a Helm repo needs to be updated with a new URL. The helm repo add command allows for this with the --force-update flag:
      --force-update               replace (overwrite) the repo if it already exists


ISSUE TYPE

Feature Pull Request - Closes #491

COMPONENT NAME
kubernetes.core.helm_repository
ADDITIONAL INFORMATION

Reviewed-by: Mor Cohen <morcohen1201@gmail.com>
Reviewed-by: Mike Graves <mgraves@redhat.com>
2022-10-03 15:00:44 +00:00
Mauricio Teixeira
08596fd05b Add example usage of from_yaml_all (#505)
Add example usage of from_yaml_all

Depends-On: #513
SUMMARY
Sometimes one might want to use a single YAML file that contains multiple Kubernetes definitions. This PR updates the documentation to provide a simple example of how to accomplish that.
ISSUE TYPE

Docs Pull Request

COMPONENT NAME
k8s
ADDITIONAL INFORMATION
I have not tested this solution against other modules, simply because I did not have use-case for those.

Reviewed-by: Mike Graves <mgraves@redhat.com>
2022-09-21 13:51:54 +00:00
Bikouo Aubin
a3a5f3cf4b helm - add support for in-memory kubeconfig (#497)
helm - add support for in-memory kubeconfig

SUMMARY

closes #492

ISSUE TYPE


Feature Pull Request

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Bikouo Aubin <None>
2022-09-12 09:13:19 +00:00
Bikouo Aubin
7f7008fecc k8s_log - fix module traceback when resource not found (#493)
k8s_log - fix module traceback when resource not found

Depends-on: #495
SUMMARY

closes #479

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

k8s_log

Reviewed-by: Mike Graves <mgraves@redhat.com>
2022-07-28 14:24:35 +00:00
kurokobo
58cbbf6364 feat: add new tail_lines parameter to k8s_log module (#488) (#489)
feat: add new tail_lines parameter to k8s_log module (#488)

SUMMARY

Add new tail_lines parameter to k8s_log module to limit the number of lines to be retrieved from the end of the logs.
Closes #488.

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

kubernetes.core.k8s_log
ADDITIONAL INFORMATION


Thanks for useful collection 😃
This is the first time to send PR to this collection, so please let me know if I'm on the wrong way.

The version_added is set to 2.4.0, but I'm not aware of the roadmap for this collection, so I'd like to know this is the right version to specify.
Changelog and simple integration test is also added.
It seems that the end of log_lines always contains an empty element, so if tail_lines is set to 5, the length of log_lines will be 6, as noted in the comment in the test. I've considered that truncating the trailing empty element, but decided not to for the following reasons.

It is inconsistent and unnatural to remove trailing empty elements only when tail_lines is specified.
Removing trailing empty elements always with or without tail_lines is a destructive change and should not be done because it would break backward compatibility.




Example tasks in playbook:
  tasks: 
    - name: create a job that has 10 lines of log
      kubernetes.core.k8s:
        state: present
        wait: yes
        wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
        wait_condition:
          type: Complete
          status: 'True'
        definition:
          apiVersion: batch/v1
          kind: Job
          metadata:
            name: multiline-log
            namespace: test
          spec:
            template:
              spec:
                containers:
                  - name: busybox
                    image: busybox
                    command: ['sh']
                    args: ['-c', 'for i in $(seq 0 9); do echo $i; done']
                restartPolicy: Never
            backoffLimit: 4

    - name: retrieve all logs from the job
      kubernetes.core.k8s_log:
        api_version: batch/v1
        kind: Job
        namespace: test
        name: multiline-log
      register: full_log

    - name: retrieve last 5 lines of log from the job
      kubernetes.core.k8s_log:
        api_version: batch/v1
        kind: Job
        namespace: test
        name: multiline-log
        tail_lines: 5
      register: tailed_log

    - ansible.builtin.debug:
        var: full_log.log_lines

    - ansible.builtin.debug:
        var: tailed_log.log_lines
Example output:
TASK [create a job that has 10 lines of log] *****************************************************************************************
ok: [localhost]

TASK [retrieve all logs from the job] ************************************************************************************************
ok: [localhost]

TASK [retrieve last 5 lines of log from the job] *************************************************************************************
ok: [localhost]

TASK [ansible.builtin.debug] *********************************************************************************************************
ok: [localhost] => 
  full_log.log_lines:
  - '0'
  - '1'
  - '2'
  - '3'
  - '4'
  - '5'
  - '6'
  - '7'
  - '8'
  - '9'
  - ''

TASK [ansible.builtin.debug] *********************************************************************************************************
ok: [localhost] => 
  tailed_log.log_lines:
  - '5'
  - '6'
  - '7'
  - '8'
  - '9'
  - ''

PLAY RECAP ***************************************************************************************************************************
localhost                  : ok=5    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Reviewed-by: Bikouo Aubin <None>
Reviewed-by: Mike Graves <mgraves@redhat.com>
2022-07-25 19:03:49 +00:00
Bikouo Aubin
7d0f0449ae Support resource definition using manifest URL (#478)
Support resource definition using manifest URL

SUMMARY

Closes #451

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

k8s
k8s_scale
k8s_service

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: Bikouo Aubin <None>
2022-07-04 12:49:53 +00:00
Mike Graves
adf3503d4e Migrate k8s_taint to refactored code (#477)
Migrate k8s_taint to refactored code

Depends-on: #476
SUMMARY

This changes the k8s_taint module to use the newly refactored code.

ISSUE TYPE

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
2022-06-15 14:41:10 +00:00
Mike Graves
beb53652db Ensure CoreExceptions are handled gracefully (#476)
Ensure CoreExceptions are handled gracefully

SUMMARY

CoreExceptions, when raised, should have a reasonably helpful and
actionable message associated with them. This adds a final check in
module execution to gracefully fail from these exceptions. A new
fail_from_exception method is added both to simplify exiting the module,
and to ensure that any chained exceptions are available when using -vvv.

ISSUE TYPE

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Joseph Torcasso <None>
2022-06-15 13:26:24 +00:00
Mike Graves
92785f58da Port changes from main to refactored branch (#472)
Port changes from main to refactored branch

Depends-on: ansible/ansible-zuul-jobs#1563
SUMMARY

This PR contains several commits that complete the rebase of the 2.x-refactor branch onto main. Most of the changes here had to be manually backported after rebasing as the original changes were to code that will be deprecated. In addition, rather than trying to manually sort out conflicts and changes to the sanity ignores, I rewrote the refresh_ignore_files script to fully automate the management of ignore files. Previously, these files were both manually edited and auto-generated. This should no longer be the case, and these files should never be manually edited going forward.
For the purposes of reviewing and history, I kept all changes in separate commits tied to the original commit being backported.

ISSUE TYPE

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Jill R <None>
2022-06-09 15:20:48 +00:00
Mike Graves
25644ac192 Move diff and wait to perform_action (#375)
This primarily moves the diff and wait logic from the various service
methods to perform_action to eliminate code duplication. I also moved
the diff_objects function out of the service object and moved most of
the find_resource logic to a new resource client method. We ended up
with several modules creating a service object just to use one of these
methods, so it seemed to make sense to make these more accessible.
2022-05-26 08:56:56 -04:00
Alina Buzachis
3bf147580f Migrate k8s (#311)
* Use refactored module_utils

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Fix runner

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Fix runner

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Update runner.py

* black runner

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Fix units

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Fix ResourceTimeout

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Attempt to fix 'Create custom resource'

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Update svc.find_resource(..., fail=True)

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Attempt to fix integration tests

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Fix apiVersion for Job

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Fix crd

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Add exception = None

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Fix apiVersion for definition

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Fix assert

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Fix returned results

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Update runner to return results accordingly

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Fix assert

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Add validate-missing

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Update client.py

* Fix failures

* Fix black formatting

Co-authored-by: Mike Graves <mgraves@redhat.com>
2022-05-26 08:15:45 -04:00
Alina Buzachis
58a0fb1605 Refactor k8s_exec to use new module_utils code (#328)
* Refactor k8s_exec to use new module_utils code

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Fix client

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
2022-05-24 14:58:57 -04:00
Mike Graves
b62ea00ebf Refactor k8s_cluster_info to use new module_utils code (#325)
Refactor k8s_cluster_info to use new module_utils code

SUMMARY

Refactor k8s_cluster_info to use new module_utils code

ISSUE TYPE
COMPONENT NAME

k8s_cluster_info
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
2022-05-24 14:56:59 -04:00
Alina Buzachis
349e9f473a Refactor k8s_service to use new module_utils code (#327)
Refactor k8s_service to use new module_utils code

SUMMARY

Refactor k8s_service to use new module_utils code

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

k8s_service

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
2022-05-24 14:56:57 -04:00
Alina Buzachis
61faa1079e [backport/2.2] Update k8s_scale to use module_utils refactored code 2022-05-24 14:53:37 -04:00
Mike Graves
8171c994df [backport/2.2] Migrate k8s_cp module to new refactored code (#329)
Co-authored-by: Alina Buzachis <abuzachis@redhat.com>
2022-05-24 14:28:27 -04:00
Alina Buzachis
f5a0dd5946 Update k8s_rollback to use refactored module_utils (#338)
Update k8s_rollback to use refactored module_utils

SUMMARY

Update k8s_rollback to use refactored module_utils

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

k8s_rollback

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: None <None>
2022-05-24 13:46:34 -04:00
Alina Buzachis
9aa20f0fbe Migrate k8s_info (#310)
* Use refactored module_utils

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Update k8s_info.py

* Fix assertion

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
2022-05-24 13:31:46 -04:00
Mike Graves
afa6a74178 Migrate json_patch to use new refactored code (#339)
Migrate json_patch to use new refactored code

SUMMARY

Migrate json_patch to use new refactored code

ISSUE TYPE

COMPONENT NAME

k8s_json_patch
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
2022-05-24 13:29:59 -04:00
Mike Graves
e2e3f71ecf [backport/2.2] Migrate k8s_log to new refactored code (#336) 2022-05-24 13:29:57 -04:00
Mike Graves
346e303084 [backport/2.x] Migrate k8s_drain to use refactored code (#330) 2022-05-24 12:17:37 -04:00
Christian von Stebut
95e2add65b Helm template add name and disable hook (#405)
Helm template add name and disable hook

SUMMARY
This PR adds "disable_hook" and "name" (NAME of the release)  as optional arguments to the helm_template module.
It contains the rest of my planned work towards #313.
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

plugins/modules/helm_template.py
changelogs/fragments/313-helm-template-add-support-for-name-and-disablehook.yml
tests/unit/modules/test_helm_template.py
integration/targets/helm/tasks/tests_chart.yml
ADDITIONAL INFORMATION


The PR contains unit tests and an integration test for the new parameters added in this and the previous PR.
I limited the execution of the integration test to the local test chart, because the testing of the "show_only" parameter requires a known chart structure. As I think I do not have to test the workings of "helm template ..." itself, I hope this is sufficient.
Please adjust / comment as necessary.

Reviewed-by: Mike Graves <mgraves@redhat.com>
2022-04-29 13:43:09 +00:00
Joshua Eason
5662fa777c Adding previous container log support (#436)
Adding previous container log support

Signed-off-by: Joshua Eason josh.eason@anchore.com
SUMMARY
Adds support for the previous parameter in kubectl logs. This allows for the retrieval of the previously terminated containers logs which is useful for troubleshooting.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
k8s_log
ADDITIONAL INFORMATION
Adds the previous parameter (bool) to k8s_log module. This matches the documentation for kubectl logs --previous parameter. This parameter allows for retrieving the previously terminated containers logs.
Output of the module is identical with the exception being the logs returned are from the previously terminated container.

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: Joshua Eason <None>
2022-04-26 15:31:44 +00:00
Wissem BEN CHAABANE
4fa1fb966b Add helm dependency update (#208)
Add helm dependency update

SUMMARY

Execute the helm dependency update under the hood when found dependencies block in Chart.yaml file.
Support the execution of:

Standalone dependency update by executing: helm dependency update CHART
Inline dependency update when specifying the helm chart_repo_url by adding --dependency-update to the helm install command.


ISSUE TYPE


Feature Pull Request #191

COMPONENT NAME

helm, helm_template
ADDITIONAL INFORMATION





There is a doc generated for history_max option for the helm module. I think that is not generated in the previous PR #164.


There is others changes affect the docs/ folder when I run the collection_prep_add_docs -p .  command. These changes are added in the last commit  64eab40. I let you decide rather we keep the commit or remove it.


The --dependency-update insertion option is tested used a local helm chart repository create via docker. So here are the tasks that test this feature.  Maybe if we create a GitHub repository for the helm chart, we can add this test code in the CI pipeline.


# Test The update dependency with chart_repo_url
- name: "Test chart without dependencies block and chart_repo_url defined"
  block:
    - name: "Test chart without dependencies block and chart_repo_url defined"
      helm:
        binary_path: "{{ helm_binary }}"
        name: test
        chart_ref: "ingress-nginx"
        chart_repo_url: https://kubernetes.github.io/ingress-nginx
        chart_version: "{{ chart_source_version | default(omit) }}"
        namespace: "{{ helm_namespace }}"
        create_namespace: yes
      register: release

    - assert:
        that:
          - "'--dependency-update' not in release.command"
          - "'upgrade' in release.command"
        success_msg: "Command does not contains '--dependency-update' options"
        fail_msg: "Command contains '--dependency-update' options"

- name: "Test chart with dependencies block and chart_repo_url defined and replace True"
  block:
    - name: "Test chart with dependencies block and chart_repo_url defined and replace True"
      helm:
        binary_path: "{{ helm_binary }}"
        name: test1
        chart_ref: "dep_up"
        chart_repo_url: http://repo:8080/charts
        chart_version: "{{ chart_source_version | default(omit) }}"
        namespace: "{{ helm_namespace }}"
        create_namespace: yes
        replace: true
      register: release
    - debug: var=release
    - assert:
        that:
          - "'--dependency-update' in release.command"
          - "'install' in release.command"
        success_msg: "Command contains '--dependency-update' options with helm install command"
        fail_msg: "Command not contains '--dependency-update' with helm install command"

- name: "Test chart with dependencies block and chart_repo_url defined and replace False fails"
  block:
    - name: "Test chart with dependencies block and chart_repo_url defined and replace False fails"
      helm:
        binary_path: "{{ helm_binary }}"
        name: test2
        chart_ref: "dep_up"
        chart_repo_url: http://repo:8080/charts
        chart_version: "{{ chart_source_version | default(omit) }}"
        namespace: "{{ helm_namespace }}"
        create_namespace: yes
        replace: false
      register: release
      ignore_errors: true

    - assert:
        that:
          - release.failed
          - release.msg == "'--dependency-update' hasn't been supported yet with 'helm upgrade'. Please use 'helm install' instead by adding 'replace' option"
        success_msg: "Command build fail when adding  '--dependency-update' with the helm upgrade command"

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Wissem BEN CHAABANE <benchaaben.wissem@gmail.com>
Reviewed-by: Bikouo Aubin <None>
2022-04-26 11:54:37 +00:00
Abhijeet Kasurde
764e4499b5 k8s_json_patch: Minor typo fix in Example section (#425)
k8s_json_patch: Minor typo fix in Example section

SUMMARY
Fixes: #411
ISSUE TYPE

Docs Pull Request

COMPONENT NAME
changelogs/fragments/411_k8s_json_patch.yml
plugins/modules/k8s_json_patch.py

Reviewed-by: Mike Graves <mgraves@redhat.com>
2022-04-01 00:59:55 +00:00
Mohammed Naser
2c96b70702 Added support for Helm post-renderer (#403)
Added support for Helm post-renderer

SUMMARY

Add support for Helm post renderer
Fixes: #30

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

helm
ADDITIONAL INFORMATION

Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: Mohammed Naser <None>
Reviewed-by: Mike Graves <mgraves@redhat.com>
2022-03-31 18:55:45 +00:00
Abhijeet Kasurde
d311ac718e helm_repository: Silence false no_log warning (#423)
helm_repository: Silence false no_log warning

Depends-On: #424
SUMMARY
Apply no_log=True to pass_credentials to silence
false positive warning.
Fixes: #412
Signed-off-by: Abhijeet Kasurde akasurde@redhat.com
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
changelogs/fragments/412_pass_creds.yml
plugins/modules/helm_repository.py

Reviewed-by: Mike Graves <mgraves@redhat.com>
2022-03-30 17:09:16 +00:00
Mike Graves
7c71436f3b Upgrade black version (#424)
Upgrade black version

SUMMARY

Move off of beta version of black and pin to current calendar year
version.
The only manual changes here are to tox.ini. Everything else is from running the new version of black.

ISSUE TYPE

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Abhijeet Kasurde <None>
2022-03-30 15:02:46 +00:00
Abhijeet Kasurde
0299aa8807 k8s_exec: Update deprecation warning (#419)
k8s_exec: Update deprecation warning

SUMMARY
return_code is deprecated in favor of rc, update the
deprecation warning to tell user about the reason behind
this.
Fixes: #417
Signed-off-by: Abhijeet Kasurde akasurde@redhat.com
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
changelogs/fragments/417_deprecation.yml
plugins/modules/k8s_exec.py

Reviewed-by: Mike Graves <mgraves@redhat.com>
2022-03-23 14:14:37 +00:00
abikouo
074f0a6555 fix issue when using k8s_drain with disable_eviction set to yes (#418)
fix issue when using k8s_drain with disable_eviction set to yes

SUMMARY

fixes #416

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

k8s_drain
ADDITIONAL INFORMATION

Reviewed-by: Abhijeet Kasurde <None>
2022-03-23 09:26:06 +00:00