Kaynağa Gözat

Parametrize the path for local storage

Diego Abelenda 7 yıl önce
ebeveyn
işleme
3b3cb8f8b6

+ 2 - 1
playbooks/openshift-hosted/private/create_persistent_volumes.yml

@@ -9,6 +9,7 @@
   vars:
     persistentlocalstorage_project: "{{ openshift_persistentlocalstorage_project | default('local-storage') }}"
     persistentlocalstorage_classes: "{{ openshift_persistentlocalstorage_classes | default([]) }}"
+    persistentlocalstorage_path: "{{ openshift_persistentlocalstorage_path | default('/mnt/local-storage') }}/{{ item }}"
   roles:
   - role: openshift_persistentlocalstorage
     when: openshift_persistentlocalstorage_enabled | default(False) | bool
@@ -18,7 +19,7 @@
   tasks:
   - name: Create Persistent Local Storage Classes Directories
     file:
-      path: "/mnt/local-storage/{{ item }}"
+      path: "{{ openshift_persistentlocalstorage_path | default('/mnt/local-storage') }}/{{ item }}"
       owner: root
       group: root
       mode: 0770

+ 5 - 4
roles/openshift_persistentlocalstorage/README.md

@@ -9,10 +9,11 @@ Requirements
 Role Variables
 --------------
 
-| Name                           | Default value |                                                                           |
-|--------------------------------|---------------|---------------------------------------------------------------------------|
-| persistentlocalstorage_project | local-storage | The namespace where the Persistent Local Volume Provider will be deployed |
-| persistentlocalstorage_classes | []            | Storage classes that will be created                                      |
+| Name                           | Default value      |                                                                           |
+|--------------------------------|--------------------|---------------------------------------------------------------------------|
+| persistentlocalstorage_project | local-storage      | The namespace where the Persistent Local Volume Provider will be deployed |
+| persistentlocalstorage_classes | []                 | Storage classes that will be created                                      |
+| persistentlocalstorage_path    | /mnt/local-storage | Path on the hosts that will be used as base for the local storage classes |
 
 Dependencies
 ------------

+ 2 - 2
roles/openshift_persistentlocalstorage/tasks/main.yml

@@ -120,10 +120,10 @@
                 securityContext:
                   runAsUser: 0
                 volumeMounts:
-                - mountPath: /mnt/local-storage
+                - mountPath: "{{ persistentlocalstorage_path }}"
                   name: local-storage
               serviceAccountName: local-volume-provisioner
               volumes:
               - hostPath:
-                  path: /mnt/local-storage
+                  path: "{{ persistentlocalstorage_path }}"
                 name: local-storage

+ 1 - 1
roles/openshift_persistentlocalstorage/templates/local-persistent-volume-config.j2

@@ -2,7 +2,7 @@
 apiVersion: v1
 data:
 {% for class in persistentlocalstorage_classes %}
-  {{class}}: '{ "hostDir": "/mnt/local-storage/{{ class }}", "mountDir" : "/mnt/local-storage/{{ class }}" }'
+  {{class}}: '{ "hostDir": "{{ openshift_persistentlocalstorage_path | default('/mnt/local-storage') }}/{{ class }}", "mountDir" : "{{ openshift_persistentlocalstorage_path | default('/mnt/local-storage') }}/{{ class }}" }'
 {% endfor %}
 kind: ConfigMap
 metadata: