Skip to content

Instantly share code, notes, and snippets.

@rvanbutselaar
Last active March 25, 2019 14:17
Show Gist options
  • Save rvanbutselaar/dd03e1830d63d7b5e76e90474c66aaa5 to your computer and use it in GitHub Desktop.
Save rvanbutselaar/dd03e1830d63d7b5e76e90474c66aaa5 to your computer and use it in GitHub Desktop.
- name: 3.6 - Get list of all PersistentVolumeClaim's
k8s_facts:
api_version: v1
kind: PersistentVolumeClaim
namespace: "{{ env }}"
label_selectors:
- orig != glusterfs-gluster01
host: "{{ openshift_api_url }}"
api_key: "{{ src_api_key }}"
verify_ssl: false
delegate_to: localhost
register: all_pvcs
- fail:
msg: "More then 8 volumes found: {{item}}"
when: item != '8'
with_items:
- "{{all_pvcs.resources|length}}"
- name: 3.6 - Get list of Cinder PersistentVolumeClaim's
k8s_facts:
api_version: v1
kind: PersistentVolumeClaim
namespace: "{{ env }}"
name: "{{ item }}"
host: "{{ openshift_api_url }}"
api_key: "{{ src_api_key }}"
verify_ssl: false
delegate_to: localhost
with_items:
- a
- b
- c
- d
register: cinder_pvcs
- name: 3.6 - Get list of GlusterFS PersistentVolumeClaim's
k8s_facts:
api_version: v1
kind: PersistentVolumeClaim
namespace: "{{ env }}"
name: "{{ item }}"
host: "{{ openshift_api_url }}"
api_key: "{{ src_api_key }}"
verify_ssl: false
delegate_to: localhost
with_items:
- 1
- 2
- 3
- 4
register: gluster_pvcs
- debug: msg="{{item.1.metadata.name}} -{{item.1.spec.volumeName}} - {{item.1.spec.resources.requests.storage}}"
with_subelements:
- "{{cinder_pvcs.results}}"
- resources
loop_control:
label: PersistentVolumeClaim
- debug: msg="{{item.1.metadata.name}} -{{item.1.spec.volumeName}} - {{item.1.spec.resources.requests.storage}}"
with_subelements:
- "{{gluster_pvcs.results}}"
- resources
loop_control:
label: PersistentVolumeClaim
- name: 3.6 - Set fact so we can use them on the destination server
set_fact:
cinder_pvcs: "{{ cinder_pvcs }}"
gluster_pvcs: "{{ gluster_pvcs }}"
cinder_pvs: "{{ cinder_pvs }}"
gluster_pvs: "{{ gluster_pvs }}"
gluster_temp_pvcs: "{{ gluster_temp_pvcs }}"
gluster_temp_pvs: "{{ gluster_temp_pvs }}"
delegate_to: "{{ dst_server }}"
delegate_facts: yes
tags:
- pvcs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment