diff --git a/playbooks/openshift-remove-object-via-api.yml b/playbooks/openshift-manage-objects-via-api.yml similarity index 100% rename from playbooks/openshift-remove-object-via-api.yml rename to playbooks/openshift-manage-objects-via-api.yml diff --git a/playbooks/openshift-manage-objects-via-oc.yml b/playbooks/openshift-manage-objects-via-oc.yml new file mode 100644 index 000000000..b090468c2 --- /dev/null +++ b/playbooks/openshift-manage-objects-via-oc.yml @@ -0,0 +1,5 @@ +--- + +- hosts: openshift_api + roles: + - role: openshift/manage-objects-via-oc diff --git a/playbooks/openshift-remove-object-via-oc.yml b/playbooks/openshift-remove-object-via-oc.yml deleted file mode 100644 index 1a14dc05d..000000000 --- a/playbooks/openshift-remove-object-via-oc.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -- hosts: openshift_api - roles: - - role: openshift/remove-object-via-oc - diff --git a/roles/openshift/manage-objects-via-api/README.md b/roles/openshift/manage-objects-via-api/README.md new file mode 100644 index 000000000..6d3d96d0e --- /dev/null +++ b/roles/openshift/manage-objects-via-api/README.md @@ -0,0 +1,54 @@ +manage-objects-via-api +======================== + +This role is used to manage OpenShift objects via OpenShift API. Role is expected to be run on Ansible Host running within OpenShift cluster, that's a target for object management + +## Requirements + + - Ansible Host running within targetted OpenShift cluster + + +## Role Variables + + +| Variable | Description | Required | Defaults | +|:---------|:------------|:---------|:---------| +|openshift_manage_objects.name|Name of OpenShift object to be processed|yes|| +|openshift_manage_objects.kind|Kind of object to be processed|yes|| +|openshift_manage_objects.namespace|OpenShift Namespace in which object to be processed resides|yes|| +|openshift_manage_objects.api_version|API version used for object|yes|| +|openshift_manage_objects.state|Desired state of OpenShift object|no|"present"| + + +## Example Inventory + +```yaml +--- +openshift_manage_objects: + - name: argo-app-abc + kind: Application + namespace: argocd-apps + api_version: argoproj.io/v1alpha1 + state: absent +``` + +## Example Playbook + +```yaml +--- + +- hosts: openshift-api + roles: + - role: manage-openshift-objects-via-api +``` + +License +------- + +Apache License 2.0 + + +Author Information +------------------ + +Red Hat Community of Practice & staff of the Red Hat Open Innovation Labs. diff --git a/roles/openshift/remove-object-via-api/defaults/main.yml b/roles/openshift/manage-objects-via-api/defaults/main.yml similarity index 100% rename from roles/openshift/remove-object-via-api/defaults/main.yml rename to roles/openshift/manage-objects-via-api/defaults/main.yml diff --git a/roles/openshift/manage-objects-via-api/tasks/main.yml b/roles/openshift/manage-objects-via-api/tasks/main.yml new file mode 100644 index 000000000..d56b9a6e2 --- /dev/null +++ b/roles/openshift/manage-objects-via-api/tasks/main.yml @@ -0,0 +1,3 @@ +--- + +- import_tasks: manage_objects.yml diff --git a/roles/openshift/remove-object-via-api/tasks/remove_object.yml b/roles/openshift/manage-objects-via-api/tasks/manage_objects.yml similarity index 100% rename from roles/openshift/remove-object-via-api/tasks/remove_object.yml rename to roles/openshift/manage-objects-via-api/tasks/manage_objects.yml diff --git a/roles/openshift/remove-object-via-oc/README.md b/roles/openshift/manage-objects-via-oc/README.md similarity index 51% rename from roles/openshift/remove-object-via-oc/README.md rename to roles/openshift/manage-objects-via-oc/README.md index fbc740cbc..7bccaa482 100644 --- a/roles/openshift/remove-object-via-oc/README.md +++ b/roles/openshift/manage-objects-via-oc/README.md @@ -1,11 +1,11 @@ -remove-openshift-object-via-oc +manage-openshift-object-via-oc ======================== -This role is used to remove OpenShift object with a help of oc. Role is expected to be run on Ansible Host running within OpenShift cluster, that's a target for object removal +This role is used to manage OpenShift object with a help of oc. Role is expected to be run on Ansible Host running within OpenShift cluster, that's a target for object action ## Requirements - - Ansible Host running within targetted OpenShift cluster + - Ansible Host running within targetted OpenShift cluster - OC installed on Ansible Host ## Role Variables @@ -13,21 +13,23 @@ This role is used to remove OpenShift object with a help of oc. Role is expected | Variable | Description | Required | Defaults | |:---------|:------------|:---------|:---------| -|openshift_remove_object.name|Name of OpenShift object to be removed|yes|| -|openshift_remove_objects.kind|Kind of object to be removed|yes|| -|openshift_remove_objects.namespace|OpenShift Namespace in which object to be removed resides|yes|| -|openshift_remove_objects.api_version|API version used for object|yes|| +|openshift_manage_objects.name|Name of OpenShift object to be removed|yes|| +|openshift_manage_objects.kind|Kind of object to be removed|yes|| +|openshift_manage_objects.namespace|OpenShift Namespace in which object to be removed resides|yes|| +|openshift_manage_objects.api_version|API version used for object|yes|| +|openshift_manage_objects.action| OC action to be executed on specified object|yes|| ## Example Inventory ```yaml --- -openshift_remove_objects: +openshift_manage_objects: - name: argo-app-abc kind: Application namespace: argocd-apps api_version: argoproj.io/v1alpha1 + action: delete ``` ## Example Playbook @@ -37,7 +39,7 @@ openshift_remove_objects: - hosts: openshift-api roles: - - role: remove-openshift-object + - role: manage-openshift-objects-via-oc ``` License diff --git a/roles/openshift/remove-object-via-oc/defaults/main.yml b/roles/openshift/manage-objects-via-oc/defaults/main.yml similarity index 100% rename from roles/openshift/remove-object-via-oc/defaults/main.yml rename to roles/openshift/manage-objects-via-oc/defaults/main.yml diff --git a/roles/openshift/manage-objects-via-oc/tasks/main.yml b/roles/openshift/manage-objects-via-oc/tasks/main.yml new file mode 100644 index 000000000..d56b9a6e2 --- /dev/null +++ b/roles/openshift/manage-objects-via-oc/tasks/main.yml @@ -0,0 +1,3 @@ +--- + +- import_tasks: manage_objects.yml diff --git a/roles/openshift/manage-objects-via-oc/tasks/manage_objects.yml b/roles/openshift/manage-objects-via-oc/tasks/manage_objects.yml new file mode 100644 index 000000000..d26f7642b --- /dev/null +++ b/roles/openshift/manage-objects-via-oc/tasks/manage_objects.yml @@ -0,0 +1,5 @@ +--- +- name: Manage OpenShift objects with OC + shell: + cmd: "oc {{ item.action }} {{ item.kind }}/{{ item.name }} -n {{ item.namespace }}" + loop: "{{ openshift_manage_objects }}" diff --git a/roles/openshift/remove-object-via-api/README.md b/roles/openshift/remove-object-via-api/README.md deleted file mode 100644 index 4c904c56d..000000000 --- a/roles/openshift/remove-object-via-api/README.md +++ /dev/null @@ -1,52 +0,0 @@ -remove-openshift-object-via-api -======================== - -This role is used to remove OpenShift object via OpenShift API. Role is expected to be run on Ansible Host running within OpenShift cluster, that's a target for object removal - -## Requirements - - - Ansible Host running within targetted OpenShift cluster - - -## Role Variables - - -| Variable | Description | Required | Defaults | -|:---------|:------------|:---------|:---------| -|openshift_remove_object.name|Name of OpenShift object to be removed|yes|| -|openshift_remove_objects.kind|Kind of object to be removed|yes|| -|openshift_remove_objects.namespace|OpenShift Namespace in which object to be removed resides|yes|| -|openshift_remove_objects.api_version|API version used for object|yes|| - - -## Example Inventory - -```yaml ---- -openshift_remove_objects: - - name: argo-app-abc - kind: Application - namespace: argocd-apps - api_version: argoproj.io/v1alpha1 -``` - -## Example Playbook - -```yaml ---- - -- hosts: openshift-api - roles: - - role: remove-openshift-object -``` - -License -------- - -Apache License 2.0 - - -Author Information ------------------- - -Red Hat Community of Practice & staff of the Red Hat Open Innovation Labs. diff --git a/roles/openshift/remove-object-via-api/tasks/main.yml b/roles/openshift/remove-object-via-api/tasks/main.yml deleted file mode 100644 index 2b7d24c74..000000000 --- a/roles/openshift/remove-object-via-api/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- - -- import_tasks: remove_object.yml diff --git a/roles/openshift/remove-object-via-oc/tasks/main.yml b/roles/openshift/remove-object-via-oc/tasks/main.yml deleted file mode 100644 index 2b7d24c74..000000000 --- a/roles/openshift/remove-object-via-oc/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- - -- import_tasks: remove_object.yml diff --git a/roles/openshift/remove-object-via-oc/tasks/remove_object.yml b/roles/openshift/remove-object-via-oc/tasks/remove_object.yml deleted file mode 100644 index 9a3161ede..000000000 --- a/roles/openshift/remove-object-via-oc/tasks/remove_object.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: Remove OpenShift object with OC - shell: - cmd: "oc delete {{ item.kind }}/{{ item.name }} -n {{ item.namespace }}" - loop: "{{ openshift_remove_objects }}"