-
Notifications
You must be signed in to change notification settings - Fork 25
/
cleanup.yml
28 lines (24 loc) · 943 Bytes
/
cleanup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT
---
- name: Clean up a project
hosts: all
vars:
service: "{{ lookup('env', 'SERVICE') | default('packit', True) }}"
deployment: "{{ lookup('env', 'DEPLOYMENT') }}"
tasks:
- name: Include variables
ansible.builtin.include_vars: ../vars/{{ service }}/{{ deployment }}.yml
- name: Login
ansible.builtin.command: oc login {{ host }} --token={{ api_key }} --insecure-skip-tls-verify
# it doesn't change anything, so don't report 'changed'
changed_when: false
- name: Switch to project
ansible.builtin.command: oc project {{ project }}
# it doesn't change anything, so don't report 'changed'
changed_when: false
- name: Delete all
ansible.builtin.command: oc delete all,cm,pvc --all
when: deployment != "prod"
# on stage this always changes something
changed_when: true