Skip to content

Commit

Permalink
Changed Removal to Manage
Browse files Browse the repository at this point in the history
  • Loading branch information
jfilipcz committed Oct 20, 2021
1 parent 12a666b commit f58e147
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 78 deletions.
5 changes: 5 additions & 0 deletions playbooks/openshift-manage-objects-via-oc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

- hosts: openshift_api
roles:
- role: openshift/manage-objects-via-oc
6 changes: 0 additions & 6 deletions playbooks/openshift-remove-object-via-oc.yml

This file was deleted.

54 changes: 54 additions & 0 deletions roles/openshift/manage-objects-via-api/README.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions roles/openshift/manage-objects-via-api/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

- import_tasks: manage_objects.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
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


| 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
Expand All @@ -37,7 +39,7 @@ openshift_remove_objects:

- hosts: openshift-api
roles:
- role: remove-openshift-object
- role: manage-openshift-objects-via-oc
```
License
Expand Down
3 changes: 3 additions & 0 deletions roles/openshift/manage-objects-via-oc/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

- import_tasks: manage_objects.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
52 changes: 0 additions & 52 deletions roles/openshift/remove-object-via-api/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions roles/openshift/remove-object-via-api/tasks/main.yml

This file was deleted.

3 changes: 0 additions & 3 deletions roles/openshift/remove-object-via-oc/tasks/main.yml

This file was deleted.

5 changes: 0 additions & 5 deletions roles/openshift/remove-object-via-oc/tasks/remove_object.yml

This file was deleted.

0 comments on commit f58e147

Please sign in to comment.