blob: 3b3138aa4e16295767411104fb97d327c84c590b [file] [log] [blame]
Mohammed Naserafcf0a12024-05-19 00:13:27 +02001# Copyright (c) 2024 VEXXHOST, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15- name: Detect if InitiatorName is set
16 ansible.builtin.slurp:
17 src: /etc/iscsi/initiatorname.iscsi
18 register: portworx_iscsi_initiatorname
19
20- name: Configure InitiatorName
21 when: "'InitiatorName' not in portworx_iscsi_initiatorname.content | b64decode"
22 block:
23 - name: Generate a new InitiatorName
24 ansible.builtin.shell:
25 cmd: iscsi-iname
26 register: portworx_iscsi_iname
27
28 - name: Write the new InitiatorName
29 ansible.builtin.copy:
30 content: "InitiatorName={{ portworx_iscsi_iname.stdout }}"
31 dest: /etc/iscsi/initiatorname.iscsi
32 owner: root
33 group: root
34 mode: "0644"
35
36- name: Install Portworx
37 run_once: true
38 kubernetes.core.k8s:
39 state: present
40 template:
41 - portworx.yml
42 - config.yml
43
44- name: Wait till the CRDs are created
45 run_once: true
46 kubernetes.core.k8s_info:
47 api_version: apiextensions.k8s.io/v1
48 kind: CustomResourceDefinition
49 name: storageclusters.core.libopenstorage.org
50 # NOTE(mnaser): Portworx operator creates the CRDs for the cluster
51 # so we need to make sure they're created before we proceed.
52 retries: 60
53 delay: 5
54 register: _result
55 until: _result.resources | length > 0
56
57- name: Create Portworx Storage Cluster
58 run_once: true
59 kubernetes.core.k8s:
60 state: present
61 template:
62 - storage_cluster.yml
63 - storage_class.yml