blob: 61ebf75f18f6c13f11bc726070246f9b4c50596e [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
Mohammed Naser6080c9b2024-07-18 10:43:09 -040024 changed_when: true
25 ansible.builtin.command:
Mohammed Naserafcf0a12024-05-19 00:13:27 +020026 cmd: iscsi-iname
27 register: portworx_iscsi_iname
28
29 - name: Write the new InitiatorName
30 ansible.builtin.copy:
31 content: "InitiatorName={{ portworx_iscsi_iname.stdout }}"
32 dest: /etc/iscsi/initiatorname.iscsi
33 owner: root
34 group: root
35 mode: "0644"
36
Mohammed Naserab360042024-06-21 13:45:10 -040037- name: Create namespace
38 kubernetes.core.k8s:
39 state: present
40 definition:
41 apiVersion: v1
42 kind: Namespace
43 metadata:
44 name: portworx
45
Mohammed Naserafcf0a12024-05-19 00:13:27 +020046- name: Install Portworx
47 run_once: true
48 kubernetes.core.k8s:
49 state: present
50 template:
51 - portworx.yml
52 - config.yml
53
54- name: Wait till the CRDs are created
55 run_once: true
56 kubernetes.core.k8s_info:
57 api_version: apiextensions.k8s.io/v1
58 kind: CustomResourceDefinition
59 name: storageclusters.core.libopenstorage.org
60 # NOTE(mnaser): Portworx operator creates the CRDs for the cluster
61 # so we need to make sure they're created before we proceed.
62 retries: 60
63 delay: 5
64 register: _result
65 until: _result.resources | length > 0
66
67- name: Create Portworx Storage Cluster
68 run_once: true
69 kubernetes.core.k8s:
70 state: present
71 template:
72 - storage_cluster.yml
73 - storage_class.yml