50 Commits

Author SHA1 Message Date
Mike Graves
f54297c2ac Add ansible-lint to tox linters (#258)
* Add ansible-lint to tox linters

* Bump black

* Black formatting

* fix linting
2025-05-19 19:53:38 +00:00
Mike Graves
93746f2392 Remove openshift inventory plugin (#252)
* Remove openshift inventory plugin

This removes the openshift inventory plugin which has been deprecated
since version 3.0.0. The tests have been updated to retain coverage of
the connection plugin, which is still supported.

* Update version in Makefile

* CI fixes

* Update version info in build scripts

* Set ansible remote directory

The security policy on the pod is preventing ansible from writing to /.
Set it to /tmp which should be writable.
2025-05-05 15:55:22 +00:00
Carter Hale
0a266a6716 Fix Failed Token Delete with PEP8 Indent (#242)
Co-authored-by: carter <me@halecarter.com>
2024-08-01 15:59:30 +00:00
Bikouo Aubin
0e884c2341 k8s - Remove support of merge_type=json (#226) 2024-05-28 17:13:25 +00:00
Bikouo Aubin
050e236aa6 Defer removal of inventory/openshift to 5.0.0 (#224)
* Defer removal of inventory/openshift to 5.0.0

* add pull request number
2024-05-28 17:43:38 +02:00
Bikouo Aubin
2c394132aa connection/oc - add option oc_local_env_vars (#225)
* add local env vars for connection/oc plugin

* Fix sanity tests
2024-05-28 13:44:03 +00:00
Bharat Babbar
fcc19da20a Update k8s.py (#218)
docs.ansible.com is managed by Red Hat and I found that the example to create the OCP/OKD project was missing in this hence I have added the below snippet:

    - name: Create an OCP project
      community.okd.k8s:
        state: present
        resource_definition:
          apiVersion: project.openshift.io/v1
          kind: Project
          metadata:
            name: testing

Please add this to the man pages also.
2024-01-18 15:22:39 +00:00
Bikouo Aubin
a63e5b7b36 Update CI - Continue work from #195 (#202)
* Upgrade Ansible and OKD versions for CI

* Use ubi9 and fix sanity

* Use correct pip install

* Try using quotes

* Ensure python3.9

* Upgrade ansible and molecule versions

* Remove DeploymentConfig

DeploymentConfigs are deprecated and seem to now be causing idempotence
problems. Replacing them with Deployments fixes it.

* Attempt to fix ldap integration tests

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

* Move sanity and unit tests to GH actions

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

* Firt round of sanity fixes

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

* Add kubernetes.core collection as sanity requirement

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

* Add ignore-2.16.txt

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

* Attempt to fix units

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

* Add ignore-2.17

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

* Attempt to fix unit tests

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

* Add pytest-ansible to test-requirements.txt

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

* Add changelog fragment

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

* Add workflow for ansible-lint

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

* Apply black

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

* Fix linters

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

* Add # fmt: skip

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

* Yet another round of linting

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

* Yet another round of linting

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

* Remove setup.cfg

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

* Revert #fmt

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

* Use ansible-core 2.14

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

* Cleanup ansible-lint ignores

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

* Try using service instead of pod IP

* Fix typo

* Actually use the correct port

* See if NetworkPolicy is preventing connection

* using Pod internal IP

* fix adm prune auth roles syntax

* adding some retry steps

* fix: openshift_builds target

* add flag --force-with-deps when building downstream collection

* Remove yamllint from tox linters, bump minimum python supported version to 3.9, Remove support for ansible-core < 2.14

---------

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
Co-authored-by: Mike Graves <mgraves@redhat.com>
Co-authored-by: Alina Buzachis <abuzachis@redhat.com>
2023-11-15 17:00:38 +00:00
Alina Buzachis
e9c891c5c2 Deprecate the openshift inventory plugin (#186)
* Deprecate the openshift inventory plugin

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

* Fix indentation

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

* Update docs

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

---------

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
2023-02-07 10:20:58 -05:00
Bikouo Aubin
f94eabffa1 update collection with latest feature from kubernetes.core (#181)
* Rebase code with kubernetes.core stable-2.4
2023-02-03 07:57:24 +01:00
Mike Graves
499863fa27 Fix example docs for openshift_auth (#182) 2023-01-26 10:20:49 -05:00
Mike Graves
5834e32c73 Add missing default values in docstrings (#180)
* Add missing default values in docstrings

These are needed for milestone (2.15) sanity tests.

* Add changelog fragment
2023-01-24 11:42:15 -05:00
Bikouo Aubin
5aa63e1b07 openshift_auth - fix discard token (#178)
* openshift_auth: when revoking token, compute the right name of the openshift resource to delete from token name

* conditional check to revoke token
2023-01-12 10:53:42 -05:00
Mike Graves
1691951788 Update for Ansible 2.15 sanity tests (#173) 2022-09-22 15:38:20 +02:00
Bikouo Aubin
ed9fb196f9 Openshift Build modules (#134)
* Openshift Build modules: Start, Prune

* add openshift adm prune builds to ansible-test

* fix sanity for downstream

* sanity ignore

* Remove 2.6 sanity ignores for ansible 2.13 and 2.14

* update code review

* update 2 - code review
2022-08-12 13:56:19 +00:00
Mike Graves
01c257ce76 Fix sanity failures for docs on Ansible 2.13 (#167) 2022-05-13 15:59:25 +02:00
Mike Graves
5545c0f9ae Initialize OpenshiftGroupsSync attributes early (#165)
* Initialize OpenshiftGroupsSync attributes early

The fail_json() method calls close_connection(), but this can fail when
the python-ldap library is not installed as close_connection() gets
called before the __ldap_connection attribute has been defined.

* Use already defined virtualenv_command

* Fix tests

* Add changelog fragment
2022-05-12 21:13:59 +00:00
Bikouo Aubin
b2d9e78b8e add step to prepare downstream collection (#154)
* add step to prepare downstream collection

* fix header generation

* update downstream_fragments.py
2022-04-29 09:22:46 -04:00
jbpratt
80e2692db2 fix kubeconfig flag for newer versions (#142)
backwards compatible change:

```
> podman run -it --rm openshift/origin-cli:v3.11.0 oc --kubeconfig
Error: flag needs an argument: --kubeconfig
```

Signed-off-by: Brady Pratt <bpratt@redhat.com>
2022-03-04 11:21:54 -05:00
Paul Czarkowski
8aeffa3872 fix ocp auth adding / to oauth discovery url (#140)
* fix ocp auth adding / to oauth discovery url

* fix space after comma

* add changelog fragment

* Convert line endings

Co-authored-by: Mike Graves <mgraves@redhat.com>
2022-02-22 13:28:51 -05:00
abikouo
fc4a979762 openshift adm prune images (#133) 2022-01-24 09:46:23 -05:00
abikouo
0a1a647e37 openshift adm group sync/prune (#125) 2022-01-20 11:23:30 -05:00
abikouo
39cb9a0981 openshift admin prune deployments (#129)
* openshift admin prune deployments

* update test

* update
2021-11-30 16:39:37 +01:00
abikouo
496cdba4e8 openshift admin prune auth (#130)
* openshift admin prune auth

* update change scope
2021-11-30 14:16:22 +01:00
Alina Buzachis
6b2efa180f openshift_adm_migrate_template_instances - new module (#126)
* openshift_adm_migrate_template_instances -  new module to update TemplateInstances to point to the latest group-version-kinds.

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

* update

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

* Add unit tests

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

* Address comments

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
2021-11-17 12:28:35 +01:00
Gonéri Le Bouder
c737d44413 improve turbo mode support (#117)
- delay the loading of external modules when possible
- delay the loading of OKDRawModule and OpenShiftProcess classes
- k8s reuse the design of the kubernetes.core modules

We've got a chicken/egg problem that prevent us from properly
reporting if kubernetes.core is missing. We need args_common to create
the module object. And we need the module object to report the missing
dependency. The dependency is declared in the galaxy.yml file anyway,
the problem should not happen.
2021-09-23 11:09:42 -04:00
Gonéri Le Bouder
c340ff6582 pylint: ignore a use-a-generator message (#118)
Follow up to the recent upgrade of pylint in the devel branch, we've
got a new use-a-generator error in k8s.py:

Use a generator instead 'all(desired.get(key, True) == item.get(key, False) for key in keys)'

This commit disables the error until we've got time to rewrite this
part.
Also, since the older branches still use an ancient version of pylint,
we've got another message saying the error does not exist (yet!).
This commit also adds the right entries in the ignore files.
2021-09-23 01:55:47 -04:00
Mike Graves
bfb2c8904f Fix sanity test errors (#107)
The empty test-requirements.txt file is needed to get Zuul's sanity job
to run.
2021-09-20 11:53:44 -04:00
Mike Graves
0838ee48d2 Enable turbo mode (#102)
* Enable turbo mode

This enables turbo mode (default is off) for the modules in this
collection that use the client from the kubernetes.core collection.

* Add changelog fragment
2021-08-25 10:37:56 -04:00
abikouo
faba4a0812 openshift_route - add support for annotations (#99)
* add support for annotations
2021-07-29 14:36:52 +02:00
Mike Graves
f60ded17b0 Update to work with k8s 2.0 (#93)
* Update to work with k8s 2.0

This makes the necessary changes to get the collection working with
kubernetes.core 2.0. The biggest changes here will be switching from the
openshift client to the kubernetes client, and dropping Python 2
support.

* Install kubernetes not openshift

* Add changelog fragment
2021-06-21 14:41:56 -04:00
abikouo
4609c20a91 openshift_process fails with template does not contains message (#87)
* fix unexpected value

* changelog

* Update pod-template.yaml

* Update openshift_process.py

* Update openshift_process.py

* Update molecule/default/tasks/openshift_process.yml

Co-authored-by: Fabian von Feilitzsch <fabian@fabianism.us>

* Update pod-template.yaml

Co-authored-by: Fabian von Feilitzsch <fabian@fabianism.us>
2021-05-26 10:48:47 -04:00
Abhijeet Kasurde
7e653aee65 k8s: Remove KubernetesRawModule dependency (#74) 2021-04-20 12:02:14 +05:30
Abhijeet Kasurde
dd2ed851ab Support FQCN in openshift inventory (#85)
* Added support FQCN ``redhat.openshift`` support for inventory
  plugin

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-04-14 09:18:10 +05:30
Abhijeet Kasurde
921c451f0d k8s_auth: Redirect using meta/runtime.yml (#73)
Fixes: #57

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-04-05 18:39:15 +02:00
Mike Graves
e7e114743c Fix sanity failure (#77)
* Fix sanity failure

This fixes a sanity test failure for newer versions of ansible-test. It
was falsely flagging the key parameter for TLS configuration as
sensitive. This parameter is just the path to a key file.

* Restrict molecule version

This is needed to address a breaking change in molecule 3.3.0.

* Add changelog fragment
2021-04-05 17:15:15 +02:00
Eric Gustavsson
d76430d879 typo: conig -> config (#69) 2021-02-22 11:15:15 -05:00
Mike Graves
6c1dc79c7f Fix doc string (#67)
* Fix doc string

The sanity tests fail due to missing default values on a few options in
the doc string. This change puts the doc string in alignment with the
argument spec.

* Fix case
2021-02-18 08:01:49 -05:00
Adam Miller
2d71c469bd doc fragments workaround for downstream (#59)
* doc fragments workaround for downstream

Signed-off-by: Adam Miller <admiller@redhat.com>

* make shellcheck happy

Signed-off-by: Adam Miller <admiller@redhat.com>

* fix collection location for downstream doc fragment resolution

Signed-off-by: Adam Miller <admiller@redhat.com>

* do things in the correct order

Signed-off-by: Adam Miller <admiller@redhat.com>

* add ANSIBLE_COLLECTIONS_PATH to ansible-doc for downstream

Signed-off-by: Adam Miller <admiller@redhat.com>

* remove elements of the json dump that aren't valid for DOCUMENTATION

Signed-off-by: Adam Miller <admiller@redhat.com>

* Add fix for Ansible 2.9

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>

* Update ci/downstream.sh

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
Co-authored-by: Jeff Geerling <geerlingguy@mac.com>
2020-11-17 18:03:00 +01:00
Jeff Geerling
87cd174b96 Issue #57: Switch dependency from community.kubernetes to kubernetes.core. (#58)
* Issue #57: Switch dependency from community.kubernetes to kubernetes.core.

* Issue #57: Rely on kubernetes.core install directly.

* Issue #57: Don't install kubernetes.core from source anymore.
2020-11-16 13:35:18 -06:00
Fabian von Feilitzsch
74ac82e76d Add openshift_process module (#44)
* Initial pass at openshift_process module. Render-only

* fix sanity test

* Add ability to create/delete resources rendered by template

* fix sanity tests

* add more tests and fix .env parser

* Add more tests

* Make multiline parsing work properly

* Add test for creating templates

* Template APIs require namespace to be provided whether or not the template exists

* add docs

* Update plugins/modules/openshift_process.py

Co-authored-by: Timothy Appnel <tima@ansible.com>

Co-authored-by: Timothy Appnel <tima@ansible.com>
2020-10-12 13:36:39 -04:00
Timothy Appnel
308235e032 Fixes #45 with correct version_added in openshift_route (#46) 2020-10-09 19:32:44 -04:00
Fabian von Feilitzsch
e7c3351309 Add openshift_route module for route creation (#40)
* first draft of interface

* Add basic implementation

* Add validation

* rename to openshift_route and add some test tasks

* Fix sanity checks

* Add checks for missing dependencies

* Add port processing like the oc command

* Add real tests

* Fix waiting

* add some more waiting to test

* add state parameters and fix RETURN docs

* try to fix odd sanity issue

* import tests passing

* Fix all sanity tests

* Do less work when state is absent, and add explicit removal values

* insecure_policy disable -> disallow

* add proper default for insecure_policy
2020-10-05 21:03:03 +02:00
Jeff Geerling
6942cd6756 Prepare to publish 0.2.0 release to Galaxy (#39)
* Issue #38: Add version_added to new openshift_auth module.

* Fixes #38: Prepare for 0.2.0 release on Galaxy.
2020-09-24 20:56:18 +00:00
Fabian von Feilitzsch
037f8b1f4f Move k8s_auth library from community.kubernetes to openshift_auth (#33)
* Add openshift_auth module

* add task to print out config

* Attempt to configure auth

* Update molecule/default/tasks/openshift_auth.yml

* fix sanity test and use incluster address for now

* Get integration tests passing locally

* Give test user cluster-level admin permissions

* Use a less verbose resource for testing

* Add alias to k8s_auth for backwards compatibility
2020-09-21 18:15:53 -04:00
Fabian von Feilitzsch
f52d63c83f Don't update image field when we can't manage it (#29)
* If deploymentconfigs are configured to trigger on image stream updates don't try to replace image field

* First pass at parsing the trigger annotation

* First draft of IS idempotence tests

* Found even more not idempotent stuff

* Separate handling of annotation and dc spec

* handle malformed annotations

* refactor incluster integration test to catch last flake

* Add proper DNS01 regex for container names

* fix broken conditional for trigger annotations

* Handle namespace field that is added to trigger

* deduplicate shared code

* Set namespace in incluster script

* Give high permissions to test pod

* Still working on permissions issues in prow

* Fix inventory test

* add namespace to watch

* run in default namespace

* fix recursive call

* Fix ansible collection path for downstream test

* Clone the proper ansible collection
2020-09-17 13:21:00 -04:00
Andrew Block
80ae2e6b1e Route API Group (#27) 2020-09-08 11:56:19 -04:00
Fabian von Feilitzsch
5a1396e54e Add openshift connection plugin, update inventory plugin to use it (#18) 2020-08-28 14:18:25 -04:00
Fabian von Feilitzsch
ee21083985 Add Molecule tests (#7)
* Initial port to molecule

* Get molecule tests to run

* Draw the rest of the owl

* use local dir for storing collection during CI run

* Add dockerfile, install community.kubernetes collection before sanity check

* Add clean step to Makefile

* Get sanity tests working

* Update sanity test to use makefile

* Add ignores for 2.11 so devel passes

* Update description

* Code review

* Add OWNERS file for prow
2020-08-17 15:41:37 -04:00
Jeff Geerling
3db69dea2b Issue #1: Initial effort to lift some content out of the Kubernetes collection. (#3)
* Issue #1: Initial effort to lift some content out of the Kubernetes collection.

* Issue #1: Disable integration tests for now, as they're not relevant.
2020-08-05 16:00:19 -05:00