Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
update deprovision task to use jinja2 template (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcritch authored and Ryan Hallisey committed Jun 15, 2018
1 parent b9ea4d9 commit 4ca081b
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions roles/kubevirt/tasks/deprovision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,31 @@
and admin_user is defined
and admin_password is defined

- name: Check for kubevirt.yml template in {{ kubevirt_template_dir }}
- name: Check that kubevirt.yaml still exists in /tmp
stat:
path: "{{ kubevirt_template_dir }}/kubevirt.yml"
register: byo_template

- name: Render BYO template
template:
src: "{{ kubevirt_template_dir }}/kubevirt.yml"
dest: /tmp/kubevirt.yml
when: byo_template.stat.exists == True
path: "/tmp/kubevirt.yaml"
register: kubevirt_template

- name: Check that kubevirt.yml still exists in /tmp
- name: Check for kubevirt.yml.j2 template in {{ kubevirt_template_dir }}
stat:
path: "/tmp/kubevirt.yml"
register: kubevirt_template
path: "{{ kubevirt_template_dir }}/kubevirt.yaml.j2"
register: byo_template
when: kubevirt_template.stat.exists == False

- name: Download KubeVirt Template
get_url:
url: "{{ release_manifest_url }}/v{{ version }}/kubevirt.yaml"
dest: "/tmp/kubevirt.yml"
when: kubevirt_template.stat.exists == False
url: "{{ release_manifest_url }}/v{{ version }}/kubevirt.yaml.j2"
dest: "{{ kubevirt_template_dir }}/kubevirt.yaml.j2"
when: (kubevirt_template.stat.exists == False) and (byo_template.stat.exists == False)

- name: Render KubeVirt Yml
replace:
path: "/tmp/kubevirt.yml"
regexp: "namespace: kube-system"
replace: "namespace: {{ namespace }}"
- name: Render KubeVirt template
template:
src: "kubevirt.yaml.j2"
dest: "/tmp/kubevirt.yaml"
when: kubevirt_template.stat.exists == False

- name: Delete KubeVirt Resources
command: kubectl delete -f /tmp/kubevirt.yml --ignore-not-found=true
command: kubectl delete -f /tmp/kubevirt.yaml --ignore-not-found=true

- name: Delete Privileged Policy
command: "oc adm policy remove-scc-from-user privileged -z {{ item }} -n {{ namespace }}"
Expand Down

0 comments on commit 4ca081b

Please sign in to comment.