Browse Source

Improve the hostpath provisioner playbook

master
Nicolas Massé 9 years ago
parent
commit
045887a81e
  1. 11
      roles/hostpath-provisioner/files/registry-storage-pvc.yaml
  2. 21
      roles/hostpath-provisioner/tasks/main.yml
  3. 3
      roles/hostpath-provisioner/vars/main.yml

11
roles/hostpath-provisioner/files/registry-storage-pvc.yaml

@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: registry-storage
namespace: default
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi

21
roles/hostpath-provisioner/tasks/main.yml

@ -14,17 +14,14 @@
- name: Create a directory for the hostpath-provisioner - name: Create a directory for the hostpath-provisioner
file: state=directory path={{ hostpath_provisioner_options.path }} owner=root group=root mode=0777 setype=svirt_sandbox_file_t file: state=directory path={{ hostpath_provisioner_options.path }} owner=root group=root mode=0777 setype=svirt_sandbox_file_t
- name: Checkout the hostpath-provisioner GIT Repository - name: Process the OpenShift Template and create the OpenShift objects for the hostpath-provisioner
git: dest={{ hostpath_provisioner_options.git_checkout_path }} repo={{ hostpath_provisioner_options.git_repo_url }} shell: oc process -f "{{ hostpath_provisioner_options.template }}" -p "HOSTPATH_TO_USE={{ hostpath_provisioner_options.path }}" -p "TARGET_NAMESPACE={{ hostpath_provisioner_options.target_namespace }}" -p "HOSTPATH_PROVISIONER_IMAGE={{ hostpath_provisioner_options.docker_image }}" | oc create -f -
become: no
- name: Process the OpenShift Template - name: Copy the PersistentVolumeClaim object definition
shell: oc process -f setup/hostpath-provisioner-template.yaml -p "HOSTPATH_TO_USE={{ hostpath_provisioner_options.path }}" -p "TARGET_NAMESPACE={{ hostpath_provisioner_options.target_namespace }}" -p "HOSTPATH_PROVISIONER_IMAGE={{ hostpath_provisioner_options.docker_image }}" > objects.json copy: src=registry-storage-pvc.yaml dest=/tmp/registry-storage-pvc.yaml
args:
chdir: "{{ hostpath_provisioner_options.git_checkout_path }}"
become: no
- name: Create the OpenShift objects for the hostpath-provisioner - name: Create a PersistentVolumeClaim for the docker-registry
command: oc create -f objects.json command: oc create -n default -f /tmp/registry-storage-pvc.yaml
args:
chdir: "{{ hostpath_provisioner_git_checkout_path }}" - name: Add the new volume to docker-registry
command: oc volume dc docker-registry -n default --add=true --overwrite=true --type=persistentVolumeClaim --name=registry-storage --claim-name=registry-storage

3
roles/hostpath-provisioner/vars/main.yml

@ -2,7 +2,6 @@
hostpath_provisioner_default_options: hostpath_provisioner_default_options:
path: /var/openshift path: /var/openshift
git_checkout_path: /home/{{ ansible_user }}/OpenShift-HostPath-Provisioner
git_repo_url: https://github.com/nmasse-itix/OpenShift-HostPath-Provisioner.git
target_namespace: default target_namespace: default
docker_image: nmasse/openshift-hostpath-provisioner:latest docker_image: nmasse/openshift-hostpath-provisioner:latest
template: https://raw.githubusercontent.com/nmasse-itix/OpenShift-HostPath-Provisioner/master/setup/hostpath-provisioner-template.yaml

Loading…
Cancel
Save