summaryrefslogtreecommitdiffstats
path: root/roles/openshift_persistent_volumes
diff options
context:
space:
mode:
authorAndrew Butcher <abutcher@redhat.com>2016-01-19 14:50:55 -0500
committerAndrew Butcher <abutcher@redhat.com>2016-02-01 17:05:55 -0500
commit44e5ddc20e7069e5345f48426a69e725aa8ea1d4 (patch)
tree638eb0ffb58c3482e2fd44766e867d6e68fac0f4 /roles/openshift_persistent_volumes
parent3d3053062ee3bca175df6eb4dd66ff56237234ca (diff)
downloadopenshift-44e5ddc20e7069e5345f48426a69e725aa8ea1d4.tar.gz
openshift-44e5ddc20e7069e5345f48426a69e725aa8ea1d4.tar.bz2
openshift-44e5ddc20e7069e5345f48426a69e725aa8ea1d4.tar.xz
openshift-44e5ddc20e7069e5345f48426a69e725aa8ea1d4.zip
Refactor registry storage options.
Diffstat (limited to 'roles/openshift_persistent_volumes')
-rw-r--r--roles/openshift_persistent_volumes/README.md60
-rw-r--r--roles/openshift_persistent_volumes/meta/main.yml13
-rw-r--r--roles/openshift_persistent_volumes/tasks/main.yml50
-rw-r--r--roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j214
-rw-r--r--roles/openshift_persistent_volumes/templates/persistent-volume.yml.j214
-rw-r--r--roles/openshift_persistent_volumes/vars/main.yml2
6 files changed, 153 insertions, 0 deletions
diff --git a/roles/openshift_persistent_volumes/README.md b/roles/openshift_persistent_volumes/README.md
new file mode 100644
index 000000000..34ae89536
--- /dev/null
+++ b/roles/openshift_persistent_volumes/README.md
@@ -0,0 +1,60 @@
+OpenShift NFS Server
+====================
+
+OpenShift Persistent Volumes
+
+Requirements
+------------
+
+Role Variables
+--------------
+
+From this role:
+| Name | Default value | |
+|--------------------------|---------------|-------------------------------------------------------------------------------------|
+| persistent_volumes | [] | List of persistent volume dictionaries, keys: name, capacity, access_modes, storage |
+| persistent_volume_claims | [] | List of persistent volume claim dictionaries, keys: name, capacity, access_modes |
+
+
+From openshift_common:
+| Name | Default Value | |
+|-------------------------------|----------------|----------------------------------------|
+| openshift_debug_level | 2 | Global openshift debug log verbosity |
+
+
+Dependencies
+------------
+
+
+Example Playbook
+----------------
+
+- name: Create persistent volumes/claims
+ hosts: oo_first_master
+ vars:
+ persistent_volumes:
+ - name: "registry-volume"
+ capacity: "5Gi"
+ access_modes:
+ - "ReadWriteMany"
+ storage:
+ nfs:
+ server: "nfs.example.com"
+ path: "/var/exports/registry"
+ persistent_volume_claims:
+ - name: "registry-claim"
+ capacity: "5Gi"
+ access_modes:
+ - "ReadWriteMany"
+ roles:
+ - role: openshift_persistent_volumes
+
+License
+-------
+
+Apache License, Version 2.0
+
+Author Information
+------------------
+
+Andrew Butcher (abutcher@redhat.com)
diff --git a/roles/openshift_persistent_volumes/meta/main.yml b/roles/openshift_persistent_volumes/meta/main.yml
new file mode 100644
index 000000000..d9f6fc01a
--- /dev/null
+++ b/roles/openshift_persistent_volumes/meta/main.yml
@@ -0,0 +1,13 @@
+---
+galaxy_info:
+ author: Andrew Butcher
+ description: OpenShift Persistent Volumes
+ company: Red Hat, Inc.
+ license: Apache License, Version 2.0
+ min_ansible_version: 1.9
+ platforms:
+ - name: EL
+ versions:
+ - 7
+dependencies:
+- { role: openshift_common }
diff --git a/roles/openshift_persistent_volumes/tasks/main.yml b/roles/openshift_persistent_volumes/tasks/main.yml
new file mode 100644
index 000000000..2455fc792
--- /dev/null
+++ b/roles/openshift_persistent_volumes/tasks/main.yml
@@ -0,0 +1,50 @@
+---
+- name: Create temp directory for volume definitions
+ command: mktemp -d /tmp/openshift-ansible-XXXXXXX
+ register: mktemp
+ changed_when: False
+
+- name: Copy the admin client config(s)
+ command: >
+ cp {{ openshift_master_config_dir }}/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
+ changed_when: False
+
+- name: Deploy PersistentVolume definitions
+ template:
+ dest: "{{ mktemp.stdout }}/persistent-volumes.yml"
+ src: persistent-volume.yml.j2
+ when: persistent_volumes | length > 0
+ changed_when: False
+
+- name: Create PersistentVolumes
+ command: >
+ {{ openshift.common.client_binary }} create
+ -f {{ mktemp.stdout }}/persistent-volumes.yml
+ --config={{ mktemp.stdout }}/admin.kubeconfig
+ register: pv_create_output
+ when: persistent_volumes | length > 0
+ failed_when: ('already exists' not in pv_create_output.stderr if pv_create_output.stderr else False) or ('created' not in pv_create_output.stdout if pv_create_output.stdout else False)
+ changed_when: ('created' in pv_create_output.stdout)
+
+- name: Deploy PersistentVolumeClaim definitions
+ template:
+ dest: "{{ mktemp.stdout }}/persistent-volume-claims.yml"
+ src: persistent-volume-claim.yml.j2
+ when: persistent_volume_claims | length > 0
+ changed_when: False
+
+- name: Create PersistentVolumeClaims
+ command: >
+ {{ openshift.common.client_binary }} create
+ -f {{ mktemp.stdout }}/persistent-volume-claims.yml
+ --config={{ mktemp.stdout }}/admin.kubeconfig
+ register: pvc_create_output
+ when: persistent_volume_claims | length > 0
+ failed_when: ('already exists' not in pvc_create_output.stderr if pvc_create_output.stderr else False) or ('created' not in pvc_create_output.stdout if pvc_create_output.stdout else False)
+ changed_when: ('created' in pvc_create_output.stdout)
+
+- name: Delete temp directory
+ file:
+ name: "{{ mktemp.stdout }}"
+ state: absent
+ changed_when: False
diff --git a/roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2 b/roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2
new file mode 100644
index 000000000..58b3e1c67
--- /dev/null
+++ b/roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2
@@ -0,0 +1,14 @@
+---
+apiVersion: "v1"
+kind: "List"
+items:
+{% for claim in persistent_volume_claims %}
+- kind: "PersistentVolumeClaim"
+ metadata:
+ name: "{{ claim.name }}"
+ spec:
+ accessModes: {{ claim.access_modes | to_padded_yaml(2, 2) }}
+ resources:
+ requests:
+ storage: "{{ claim.capacity }}"
+{% endfor %}
diff --git a/roles/openshift_persistent_volumes/templates/persistent-volume.yml.j2 b/roles/openshift_persistent_volumes/templates/persistent-volume.yml.j2
new file mode 100644
index 000000000..5714b6b0d
--- /dev/null
+++ b/roles/openshift_persistent_volumes/templates/persistent-volume.yml.j2
@@ -0,0 +1,14 @@
+---
+apiVersion: v1
+kind: List
+items:
+{% for volume in persistent_volumes %}
+- kind: PersistentVolume
+ metadata:
+ name: "{{ volume.name }}"
+ spec:
+ capacity:
+ storage: "{{ volume.capacity }}"
+ accessModes: {{ volume.access_modes | to_padded_yaml(2, 2) }}
+ {{ volume.storage.keys()[0] }}: {{ volume.storage[volume.storage.keys()[0]] | to_padded_yaml(3, 2) }}
+{% endfor %}
diff --git a/roles/openshift_persistent_volumes/vars/main.yml b/roles/openshift_persistent_volumes/vars/main.yml
new file mode 100644
index 000000000..9967e26f4
--- /dev/null
+++ b/roles/openshift_persistent_volumes/vars/main.yml
@@ -0,0 +1,2 @@
+---
+openshift_master_config_dir: "{{ openshift.common.config_base }}/master"