Skip to content

Commit

Permalink
change to local operation for PV creation, and not through delegated …
Browse files Browse the repository at this point in the history
…task on storage, in case we don't have access

Signed-off-by: Fabian Arrotin <[email protected]>
  • Loading branch information
arrfab committed Jun 11, 2020
1 parent e0149a7 commit 48effc8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
46 changes: 32 additions & 14 deletions adhoc-openshift-pv.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
---
# This playbook is to create a persistent volume for openshift CI namespace
# Example to run the playbook
# `ansible-playbook -e "env_prefix=ocp-prod" -e "pv_size=10Gi" -e
# "cico_project_name=new_fancy_project" adhoc-openshift-pv.yml -i inventory`
# ansible-playbook-ci playbooks/adhoc-openshift-pv.yml -e "env_prefix=ocp-stg" -e "host=n4-136.cloud.ci.centos.org" -e "pv_size=10Gi" -e "cico_project_name=test"
# The node on which we'll run this should have the exported NFS volume mounted locally
# using variables from inventory:
# ocp_nfs_server: (like node.domain)
# ocp_nfs_export: ocp-staging


- hosts: "{{ ocp_management_group }}"
- hosts: "{{ host }}"
become: true
become_user: "{{ ocp_service_account }}"
vars:
ocp_management_group:
- "{{ ocp_ci_management }}"

tasks:
- name: Generate a UUID
set_fact:
pv_uuid: "{{ (cico_project_name + pv_claimref|default('noclaimref', true)) | to_uuid }}"
tags:
- pv
- nfs

- name: UUID Generated
debug:
var: pv_uuid
tags:
- pv
- nfs

- name: Make a pv name
set_fact:
pv_name: "pv-{{ pv_size | lower }}-{{ pv_uuid }}"
tags:
- pv
- nfs

- name: UUID Generated
debug:
var: pv_name
tags:
- pv
- nfs

- name: See if the PV already exists
command: "/home/{{ ocp_service_account }}/bin/oc get pv/{{ pv_name }}"
Expand All @@ -45,17 +49,31 @@
- results.rc == 0
tags:
- pv

- block:
- name: Ensuring we have local mount point
file:
path: /mnt/ocp_store
state: directory

- name: make directories for each PV
file:
path: "/exports/{{ env_prefix }}/{{ pv_name }}"
owner: nfsnobody
group: nfsnobody
mode: 0777
state: directory
delegate_to: {{ storage_server }}
- name: Ensuring nfs export is mounted on mgmt station
mount:
fstype: nfs
src: "{{ ocp_nfs_server }}:{{ ocp_nfs_export }}"
path: /mnt/ocp_store
state: mounted

- name: make directories for each PV
file:
path: "/mnt/ocp_store/{{ pv_name }}"
owner: nobody
group: nobody
mode: 0777
state: directory
become_user: root
tags:
- pv
- nfs

- name: create json files for PV
template:
Expand Down
4 changes: 2 additions & 2 deletions templates/openshift-pv-storage/persistent-volume.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
},
{% endif %}
"nfs": {
"server": "{{ storage_server }}",
"path": "/exports/{{ env_prefix }}/{{ pv_name }}"
"server": "{{ ocp_nfs_server }}",
"path": "/{{ ocp_nfs_export }}/{{ pv_name }}"
}
}
}

0 comments on commit 48effc8

Please sign in to comment.