-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OpenShift object removal role and playbooks.
- Loading branch information
Showing
14 changed files
with
153 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
|
||
ansible_connection: local | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[openshift_api] | ||
localhost | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
|
||
- hosts: openshift_api | ||
roles: | ||
- role: openshift/remove-object-via-api | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
|
||
- hosts: openshift_api | ||
roles: | ||
- role: openshift/remove-object-via-oc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
{ | ||
"rrule": "{{ schedule.rrule }}", | ||
"name": "{{ schedule.name }}", | ||
"description": "{{ schedule.description | default('') }}", | ||
"extra_data": {{ schedule.extra_data | default("{}") | to_json }}, | ||
"inventory": "{{ schedule.inventory | default() }}", | ||
"scm_branch": "{{ schedule.scm_branch | default('') }}", | ||
"description": "{{ schedule.description }}", | ||
"extra_data": {{ schedule.extra_data | to_json }}, | ||
"inventory": "{{ schedule.inventory }}", | ||
"scm_branch": "{{ schedule.scm_branch }}", | ||
"job_type": null, | ||
"job_tags": "", | ||
"skip_tags": "", | ||
"limit": "{{ schedule.limit | default('') }}", | ||
"limit": "{{ schedule.limit }}", | ||
"diff_mode": null, | ||
"verbosity": null, | ||
"unified_job_template": "{{ unified_job_template_id | default('') }}", | ||
"enabled": {{ schedule.enabled | default(true)| bool | lower }} | ||
"unified_job_template": "{{ unified_job_template_id }}", | ||
"enabled": {{ schedule.enabled | default(false) | bool | lower }} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
|
||
- import_tasks: remove_object.yml |
9 changes: 9 additions & 0 deletions
9
roles/openshift/remove-object-via-api/tasks/remove_object.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- name: Remove OpenShift object via OpenShift API | ||
k8s: | ||
state: absent | ||
name: "{{ item.name }}" | ||
api_version: "{{ item.api_version }}" | ||
kind: "{{ item.kind }}" | ||
namespace: "{{ item.namespace }}" | ||
loop: "{{ openshift_remove_objects }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
remove-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 | ||
|
||
## Requirements | ||
|
||
- 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|| | ||
|
||
|
||
## 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
|
||
- import_tasks: remove_object.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: Remove OpenShift object with OC | ||
shell: | ||
cmd: "oc delete {{ item.kind }}/{{ item.name }} -n {{ item.namespace }}" | ||
loop: "{{ openshift_remove_objects }}" |