summaryrefslogtreecommitdiffstats
path: root/roles/openshift_cfme/tasks/create_pvs.yml
blob: 7fa7d3997ef208a807e2be333700088cce175594 (plain)
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
29
30
31
32
33
34
35
36
---
# Check for existance and then conditionally:
# - evaluate templates
# - PVs
#
# These tasks idempotently create required CFME PV objects. Do not
# call this file directly. This file is intended to be ran as an
# include that has a 'with_items' attached to it. Hence the use below
# of variables like "{{ item.pv_label }}"

- name: "Check if the {{ item.pv_label }} template has been created already"
  oc_obj:
    namespace: "{{ openshift_cfme_project }}"
    state: list
    kind: pv
    name: "{{ item.pv_name }}"
  register: miq_pv_check

# Skip all of this if the PV already exists
- block:
    - name: "Ensure the {{ item.pv_label }} template is evaluated"
      template:
        src: "{{ item.pv_template }}.j2"
        dest: "{{ template_dir }}/{{ item.pv_template }}"

    - name: "Ensure {{ item.pv_label }} is created"
      oc_obj:
        namespace: "{{ openshift_cfme_project }}"
        kind: pv
        name: "{{ item.pv_name }}"
        state: present
        delete_after: True
        files:
          - "{{ template_dir }}/{{ item.pv_template }}"
  when:
    - not miq_pv_check.results.results.0