Add Shared Storage as optional
[infra/stack/kubernetes.git] / apps / ceph / kubespray / playbooks / roles / install / tasks / main.yaml
1 ---
2 # ============LICENSE_START=======================================================
3 #  Copyright (C) 2019 The Nordix Foundation. All rights reserved.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
19
20 - name: Load execution mode variables
21   include_vars: "{{ execution_mode }}.yaml"
22
23 - name: Delete existing rook cluster if any
24   k8s:
25     definition: "{{ lookup('template', config_file) }}"
26     state: absent
27   with_items:
28     - external-dashboard-https.yaml.j2
29     - pool.yaml.j2
30     - storageclass.yaml.j2
31     - toolbox.yaml.j2
32     - cluster.yaml.j2
33   loop_control:
34     loop_var: config_file
35   ignore_errors: true
36   tags: reset
37
38 - name: Delete existing rook cluster CRD if any
39   k8s:
40     api_version: apiextensions.k8s.io/v1beta1
41     state: absent
42     kind: CustomResourceDefinition
43     name: cephclusters.ceph.rook.io
44   ignore_errors: true
45   tags: reset
46
47 - name: Delete existing rook operator if any
48   k8s:
49     definition: "{{ lookup('template', config_file) }}"
50     state: absent
51   with_items:
52     - operator.yaml.j2
53     - common.yaml.j2
54   loop_control:
55     loop_var: config_file
56   ignore_errors: true
57   tags: reset
58
59 - name: Wait until rook namespace is deleted
60   k8s_facts:
61     kind: Namespace
62     name: "{{ rook_namespace }}"
63   register: result
64   until: not result.resources
65   retries: 10
66   delay: 5
67   tags: reset
68
69 - name: Create rook operator
70   k8s:
71     state: present
72     definition: "{{ lookup('template', config_file) }}"
73   with_items:
74     - common.yaml.j2
75     - operator.yaml.j2
76   loop_control:
77     loop_var: config_file
78
79 - name: Wait until OPERATOR pod is available
80   k8s_facts:
81     kind: Pod
82     namespace: "{{ rook_namespace }}"
83     label_selectors:
84       - app = rook-ceph-operator
85     field_selectors:
86       - status.phase=Running
87   register: rook_mgr_status
88   until:
89     - rook_mgr_status.resources is defined
90     - rook_mgr_status.resources
91   retries: 20
92   delay: 5
93
94 - name: Create rook cluster
95   k8s:
96     state: present
97     definition: "{{ lookup('template', config_file) }}"
98   with_items:
99     - cluster.yaml.j2
100     - toolbox.yaml.j2
101   loop_control:
102     loop_var: config_file
103
104 - name: Wait until rook cluster deployment is complete
105   k8s_facts:
106     kind: CephCluster
107     name: rook-ceph
108     namespace: "{{ rook_namespace }}"
109     field_selectors:
110       - status.state = "Created"
111   register: rook_cluster_status
112   until:
113     - rook_cluster_status.resources
114   retries: 10
115   delay: 5
116
117 - name: Wait until MGR pods are available
118   k8s_facts:
119     kind: Pod
120     namespace: "{{ rook_namespace }}"
121     label_selectors:
122       - app = rook-ceph-mgr
123     field_selectors:
124       - status.phase=Running
125   register: rook_mgr_status
126   until:
127     - rook_mgr_status.resources is defined
128     - rook_mgr_status.resources
129   retries: 30
130   delay: 10
131
132 - name: Wait until OSD pods are available
133   k8s_facts:
134     kind: Pod
135     namespace: "{{ rook_namespace }}"
136     label_selectors:
137       - app = rook-ceph-osd
138     field_selectors:
139       - status.phase=Running
140   register: rook_osd_status
141   until:
142     - rook_osd_status.resources is defined
143     - rook_osd_status.resources
144   retries: 30
145   delay: 10
146
147 - name: Create rook block storage
148   k8s:
149     state: present
150     definition: "{{ lookup('template', config_file) }}"
151   with_items:
152     - pool.yaml.j2
153     - storageclass.yaml.j2
154   loop_control:
155     loop_var: config_file
156
157 - name: Create rook file system
158   k8s:
159     state: present
160     definition: "{{ lookup('template', config_file) }}"
161   with_items:
162     - filesystem.yaml.j2
163     - filesystem-storageclass.yaml.j2
164   loop_control:
165     loop_var: config_file
166   when: rook_filesystem|bool
167
168 - name: Create rook external dashboard
169   k8s:
170     state: present
171     definition: "{{ lookup('template', 'external-dashboard-https.yaml.j2') }}"
172
173 # vim: set ts=2 sw=2 expandtab: