diff options
14 files changed, 270 insertions, 111 deletions
diff --git a/playbooks/common/openshift-cluster/upgrades/docker/docker_upgrade.yml b/playbooks/common/openshift-cluster/upgrades/docker/docker_upgrade.yml index 8392e21ee..094c70b46 100644 --- a/playbooks/common/openshift-cluster/upgrades/docker/docker_upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/docker/docker_upgrade.yml @@ -19,7 +19,7 @@ - import_role: name: container_runtime tasks_from: docker_upgrade_check.yml - when: docker_upgrade is not defined or docker_upgrade | bool + when: docker_upgrade | default(True) | bool # If a node fails, halt everything, the admin will need to clean up and we diff --git a/playbooks/common/openshift-cluster/upgrades/pre/config.yml b/playbooks/common/openshift-cluster/upgrades/pre/config.yml index 44af37b2d..c027fc8f5 100644 --- a/playbooks/common/openshift-cluster/upgrades/pre/config.yml +++ b/playbooks/common/openshift-cluster/upgrades/pre/config.yml @@ -79,3 +79,4 @@ - import_role: name: container_runtime tasks_from: docker_upgrade_check.yml + when: docker_upgrade | default(True) | bool diff --git a/playbooks/openshift-glusterfs/private/uninstall.yml b/playbooks/openshift-glusterfs/private/uninstall.yml new file mode 100644 index 000000000..40f178f4c --- /dev/null +++ b/playbooks/openshift-glusterfs/private/uninstall.yml @@ -0,0 +1,8 @@ +--- +- name: Uninstall GlusterFS + hosts: oo_first_master + tasks: + - name: Run glusterfs uninstall role + include_role: + name: openshift_storage_glusterfs + tasks_from: uninstall.yml diff --git a/playbooks/openshift-glusterfs/uninstall.yml b/playbooks/openshift-glusterfs/uninstall.yml new file mode 100644 index 000000000..77bf75c23 --- /dev/null +++ b/playbooks/openshift-glusterfs/uninstall.yml @@ -0,0 +1,4 @@ +--- +- import_playbook: ../init/main.yml + +- import_playbook: private/uninstall.yml diff --git a/roles/container_runtime/defaults/main.yml b/roles/container_runtime/defaults/main.yml index 01540776f..77cf86b0a 100644 --- a/roles/container_runtime/defaults/main.yml +++ b/roles/container_runtime/defaults/main.yml @@ -87,6 +87,8 @@ openshift_use_crio_only: False l_openshift_image_tag_default: "{{ openshift_release | default('latest') }}" l_openshift_image_tag: "{{ openshift_image_tag | default(l_openshift_image_tag_default) | string}}" +l_required_docker_version: '1.12' + # --------------------- # # systemcontainers_crio # # --------------------- # diff --git a/roles/container_runtime/tasks/docker_upgrade_check.yml b/roles/container_runtime/tasks/docker_upgrade_check.yml index 8dd916e79..4a341b744 100644 --- a/roles/container_runtime/tasks/docker_upgrade_check.yml +++ b/roles/container_runtime/tasks/docker_upgrade_check.yml @@ -36,14 +36,16 @@ failed_when: false changed_when: false -- fail: - msg: This playbook requires access to Docker 1.12 or later +- name: Required docker version not available (non-atomic) + fail: + msg: "This playbook requires access to Docker {{ l_required_docker_version }} or later" # Disable the 1.12 requirement if the user set a specific Docker version when: - not openshift_is_atomic | bool - docker_version is not defined - - docker_upgrade is not defined or docker_upgrade | bool == True - - (pkg_check.rc == 0 and (avail_docker_version.stdout == "" or avail_docker_version.stdout is version_compare('1.12','<'))) + - docker_upgrade | bool + - pkg_check.rc == 0 + - avail_docker_version.stdout == "" or avail_docker_version.stdout is version_compare(l_required_docker_version,'<') # Default l_docker_upgrade to False, we'll set to True if an upgrade is required: - set_fact: @@ -54,7 +56,8 @@ docker_version: "{{ avail_docker_version.stdout }}" when: - not openshift_is_atomic | bool - - pkg_check.rc == 0 and docker_version is not defined + - pkg_check.rc == 0 + - docker_version is not defined - name: Flag for Docker upgrade if necessary set_fact: @@ -74,8 +77,9 @@ l_docker_version: "{{ g_atomic_docker_version_result.stdout | from_yaml }}" when: openshift_is_atomic | bool -- fail: - msg: This playbook requires access to Docker 1.12 or later +- name: Required docker version is unavailable (atomic) + fail: + msg: "This playbook requires access to Docker {{ l_required_docker_version }} or later" when: - openshift_is_atomic | bool - - l_docker_version.avail_version | default(l_docker_version.curr_version, true) is version_compare('1.12','<') + - l_docker_version.avail_version | default(l_docker_version.curr_version, true) is version_compare(l_required_docker_version,'<') diff --git a/roles/lib_utils/action_plugins/generate_pv_pvcs_list.py b/roles/lib_utils/action_plugins/generate_pv_pvcs_list.py index eb13a58ba..c60742dd3 100644 --- a/roles/lib_utils/action_plugins/generate_pv_pvcs_list.py +++ b/roles/lib_utils/action_plugins/generate_pv_pvcs_list.py @@ -118,10 +118,16 @@ class ActionModule(ActionBase): create_pvc = self._templar.template(create_pvc) if kind != 'object' and create_pv and create_pvc: volume, size, _, access_modes = self.build_common(varname=varname) + storageclass = self.task_vars.get(str(varname) + '_storageclass') + if storageclass: + storageclass = self._templar.template(storageclass) + elif storageclass is None and kind != 'dynamic': + storageclass = '' return dict( name="{0}-claim".format(volume), capacity=size, - access_modes=access_modes) + access_modes=access_modes, + storageclass=storageclass) return None def run(self, tmp=None, task_vars=None): diff --git a/roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2 b/roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2 index fac589a92..ca8b747ee 100644 --- a/roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2 +++ b/roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2 @@ -12,4 +12,7 @@ items: resources: requests: storage: "{{ claim.capacity }}" +{% if claim.storageclass is not None %} + storageClassName: "{{ claim.storageclass }}" +{% endif %} {% endfor %} diff --git a/roles/openshift_storage_glusterfs/tasks/glusterfs_config.yml b/roles/openshift_storage_glusterfs/tasks/glusterfs_config.yml index 92de1b64d..b50050956 100644 --- a/roles/openshift_storage_glusterfs/tasks/glusterfs_config.yml +++ b/roles/openshift_storage_glusterfs/tasks/glusterfs_config.yml @@ -1,53 +1,3 @@ --- -- set_fact: - glusterfs_timeout: "{{ openshift_storage_glusterfs_timeout }}" - glusterfs_namespace: "{{ openshift_storage_glusterfs_namespace }}" - glusterfs_is_native: "{{ openshift_storage_glusterfs_is_native | bool }}" - glusterfs_name: "{{ openshift_storage_glusterfs_name }}" - # map_from_pairs is a custom filter plugin in role lib_utils - glusterfs_nodeselector: "{{ openshift_storage_glusterfs_nodeselector | default(['storagenode', openshift_storage_glusterfs_name] | join('=')) | map_from_pairs }}" - glusterfs_use_default_selector: "{{ openshift_storage_glusterfs_use_default_selector }}" - glusterfs_storageclass: "{{ openshift_storage_glusterfs_storageclass }}" - glusterfs_storageclass_default: "{{ openshift_storage_glusterfs_storageclass_default | bool }}" - glusterfs_image: "{{ openshift_storage_glusterfs_image }}" - glusterfs_version: "{{ openshift_storage_glusterfs_version }}" - glusterfs_block_deploy: "{{ openshift_storage_glusterfs_block_deploy | bool }}" - glusterfs_block_image: "{{ openshift_storage_glusterfs_block_image }}" - glusterfs_block_version: "{{ openshift_storage_glusterfs_block_version }}" - glusterfs_block_host_vol_create: "{{ openshift_storage_glusterfs_block_host_vol_create }}" - glusterfs_block_host_vol_size: "{{ openshift_storage_glusterfs_block_host_vol_size }}" - glusterfs_block_host_vol_max: "{{ openshift_storage_glusterfs_block_host_vol_max }}" - glusterfs_block_storageclass: "{{ openshift_storage_glusterfs_block_storageclass | bool }}" - glusterfs_block_storageclass_default: "{{ openshift_storage_glusterfs_block_storageclass_default | bool }}" - glusterfs_s3_deploy: "{{ openshift_storage_glusterfs_s3_deploy | bool }}" - glusterfs_s3_image: "{{ openshift_storage_glusterfs_s3_image }}" - glusterfs_s3_version: "{{ openshift_storage_glusterfs_s3_version }}" - glusterfs_s3_account: "{{ openshift_storage_glusterfs_s3_account }}" - glusterfs_s3_user: "{{ openshift_storage_glusterfs_s3_user }}" - glusterfs_s3_password: "{{ openshift_storage_glusterfs_s3_password }}" - glusterfs_s3_pvc: "{{ openshift_storage_glusterfs_s3_pvc }}" - glusterfs_s3_pvc_size: "{{ openshift_storage_glusterfs_s3_pvc_size }}" - glusterfs_s3_meta_pvc: "{{ openshift_storage_glusterfs_s3_meta_pvc }}" - glusterfs_s3_meta_pvc_size: "{{ openshift_storage_glusterfs_s3_meta_pvc_size }}" - glusterfs_wipe: "{{ openshift_storage_glusterfs_wipe | bool }}" - glusterfs_heketi_is_native: "{{ openshift_storage_glusterfs_heketi_is_native | bool }}" - glusterfs_heketi_is_missing: "{{ openshift_storage_glusterfs_heketi_is_missing | bool }}" - glusterfs_heketi_deploy_is_missing: "{{ openshift_storage_glusterfs_heketi_deploy_is_missing | bool }}" - glusterfs_heketi_cli: "{{ openshift_storage_glusterfs_heketi_cli }}" - glusterfs_heketi_image: "{{ openshift_storage_glusterfs_heketi_image }}" - glusterfs_heketi_version: "{{ openshift_storage_glusterfs_heketi_version }}" - glusterfs_heketi_admin_key: "{{ openshift_storage_glusterfs_heketi_admin_key }}" - glusterfs_heketi_user_key: "{{ openshift_storage_glusterfs_heketi_user_key }}" - glusterfs_heketi_topology_load: "{{ openshift_storage_glusterfs_heketi_topology_load | bool }}" - glusterfs_heketi_wipe: "{{ openshift_storage_glusterfs_heketi_wipe | bool }}" - glusterfs_heketi_url: "{{ openshift_storage_glusterfs_heketi_url }}" - glusterfs_heketi_port: "{{ openshift_storage_glusterfs_heketi_port }}" - glusterfs_heketi_executor: "{{ openshift_storage_glusterfs_heketi_executor }}" - glusterfs_heketi_ssh_port: "{{ openshift_storage_glusterfs_heketi_ssh_port }}" - glusterfs_heketi_ssh_user: "{{ openshift_storage_glusterfs_heketi_ssh_user }}" - glusterfs_heketi_ssh_sudo: "{{ openshift_storage_glusterfs_heketi_ssh_sudo | bool }}" - glusterfs_heketi_ssh_keyfile: "{{ openshift_storage_glusterfs_heketi_ssh_keyfile }}" - glusterfs_heketi_fstab: "{{ openshift_storage_glusterfs_heketi_fstab }}" - glusterfs_nodes: "{{ groups.glusterfs | default([]) }}" - +- include_tasks: glusterfs_config_facts.yml - include_tasks: glusterfs_common.yml diff --git a/roles/openshift_storage_glusterfs/tasks/glusterfs_config_facts.yml b/roles/openshift_storage_glusterfs/tasks/glusterfs_config_facts.yml new file mode 100644 index 000000000..67d30bf25 --- /dev/null +++ b/roles/openshift_storage_glusterfs/tasks/glusterfs_config_facts.yml @@ -0,0 +1,51 @@ +--- +- set_fact: + glusterfs_timeout: "{{ openshift_storage_glusterfs_timeout }}" + glusterfs_namespace: "{{ openshift_storage_glusterfs_namespace }}" + glusterfs_is_native: "{{ openshift_storage_glusterfs_is_native | bool }}" + glusterfs_name: "{{ openshift_storage_glusterfs_name }}" + # map_from_pairs is a custom filter plugin in role lib_utils + glusterfs_nodeselector: "{{ openshift_storage_glusterfs_nodeselector | default(['storagenode', openshift_storage_glusterfs_name] | join('=')) | map_from_pairs }}" + glusterfs_use_default_selector: "{{ openshift_storage_glusterfs_use_default_selector }}" + glusterfs_storageclass: "{{ openshift_storage_glusterfs_storageclass }}" + glusterfs_storageclass_default: "{{ openshift_storage_glusterfs_storageclass_default | bool }}" + glusterfs_image: "{{ openshift_storage_glusterfs_image }}" + glusterfs_version: "{{ openshift_storage_glusterfs_version }}" + glusterfs_block_deploy: "{{ openshift_storage_glusterfs_block_deploy | bool }}" + glusterfs_block_image: "{{ openshift_storage_glusterfs_block_image }}" + glusterfs_block_version: "{{ openshift_storage_glusterfs_block_version }}" + glusterfs_block_host_vol_create: "{{ openshift_storage_glusterfs_block_host_vol_create }}" + glusterfs_block_host_vol_size: "{{ openshift_storage_glusterfs_block_host_vol_size }}" + glusterfs_block_host_vol_max: "{{ openshift_storage_glusterfs_block_host_vol_max }}" + glusterfs_block_storageclass: "{{ openshift_storage_glusterfs_block_storageclass | bool }}" + glusterfs_block_storageclass_default: "{{ openshift_storage_glusterfs_block_storageclass_default | bool }}" + glusterfs_s3_deploy: "{{ openshift_storage_glusterfs_s3_deploy | bool }}" + glusterfs_s3_image: "{{ openshift_storage_glusterfs_s3_image }}" + glusterfs_s3_version: "{{ openshift_storage_glusterfs_s3_version }}" + glusterfs_s3_account: "{{ openshift_storage_glusterfs_s3_account }}" + glusterfs_s3_user: "{{ openshift_storage_glusterfs_s3_user }}" + glusterfs_s3_password: "{{ openshift_storage_glusterfs_s3_password }}" + glusterfs_s3_pvc: "{{ openshift_storage_glusterfs_s3_pvc }}" + glusterfs_s3_pvc_size: "{{ openshift_storage_glusterfs_s3_pvc_size }}" + glusterfs_s3_meta_pvc: "{{ openshift_storage_glusterfs_s3_meta_pvc }}" + glusterfs_s3_meta_pvc_size: "{{ openshift_storage_glusterfs_s3_meta_pvc_size }}" + glusterfs_wipe: "{{ openshift_storage_glusterfs_wipe | bool }}" + glusterfs_heketi_is_native: "{{ openshift_storage_glusterfs_heketi_is_native | bool }}" + glusterfs_heketi_is_missing: "{{ openshift_storage_glusterfs_heketi_is_missing | bool }}" + glusterfs_heketi_deploy_is_missing: "{{ openshift_storage_glusterfs_heketi_deploy_is_missing | bool }}" + glusterfs_heketi_cli: "{{ openshift_storage_glusterfs_heketi_cli }}" + glusterfs_heketi_image: "{{ openshift_storage_glusterfs_heketi_image }}" + glusterfs_heketi_version: "{{ openshift_storage_glusterfs_heketi_version }}" + glusterfs_heketi_admin_key: "{{ openshift_storage_glusterfs_heketi_admin_key }}" + glusterfs_heketi_user_key: "{{ openshift_storage_glusterfs_heketi_user_key }}" + glusterfs_heketi_topology_load: "{{ openshift_storage_glusterfs_heketi_topology_load | bool }}" + glusterfs_heketi_wipe: "{{ openshift_storage_glusterfs_heketi_wipe | bool }}" + glusterfs_heketi_url: "{{ openshift_storage_glusterfs_heketi_url }}" + glusterfs_heketi_port: "{{ openshift_storage_glusterfs_heketi_port }}" + glusterfs_heketi_executor: "{{ openshift_storage_glusterfs_heketi_executor }}" + glusterfs_heketi_ssh_port: "{{ openshift_storage_glusterfs_heketi_ssh_port }}" + glusterfs_heketi_ssh_user: "{{ openshift_storage_glusterfs_heketi_ssh_user }}" + glusterfs_heketi_ssh_sudo: "{{ openshift_storage_glusterfs_heketi_ssh_sudo | bool }}" + glusterfs_heketi_ssh_keyfile: "{{ openshift_storage_glusterfs_heketi_ssh_keyfile }}" + glusterfs_heketi_fstab: "{{ openshift_storage_glusterfs_heketi_fstab }}" + glusterfs_nodes: "{{ groups.glusterfs | default([]) }}" diff --git a/roles/openshift_storage_glusterfs/tasks/glusterfs_registry.yml b/roles/openshift_storage_glusterfs/tasks/glusterfs_registry.yml index 10c29fd37..e91e13033 100644 --- a/roles/openshift_storage_glusterfs/tasks/glusterfs_registry.yml +++ b/roles/openshift_storage_glusterfs/tasks/glusterfs_registry.yml @@ -1,54 +1,5 @@ --- -- set_fact: - glusterfs_timeout: "{{ openshift_storage_glusterfs_registry_timeout }}" - glusterfs_namespace: "{{ openshift_storage_glusterfs_registry_namespace }}" - glusterfs_is_native: "{{ openshift_storage_glusterfs_registry_is_native | bool }}" - glusterfs_name: "{{ openshift_storage_glusterfs_registry_name }}" - # map_from_pairs is a custom filter plugin in role lib_utils - glusterfs_nodeselector: "{{ openshift_storage_glusterfs_registry_nodeselector | default(['storagenode', openshift_storage_glusterfs_registry_name] | join('=')) | map_from_pairs }}" - glusterfs_use_default_selector: "{{ openshift_storage_glusterfs_registry_use_default_selector }}" - glusterfs_storageclass: "{{ openshift_storage_glusterfs_registry_storageclass }}" - glusterfs_storageclass_default: "{{ openshift_storage_glusterfs_registry_storageclass_default | bool }}" - glusterfs_image: "{{ openshift_storage_glusterfs_registry_image }}" - glusterfs_version: "{{ openshift_storage_glusterfs_registry_version }}" - glusterfs_block_deploy: "{{ openshift_storage_glusterfs_registry_block_deploy | bool }}" - glusterfs_block_image: "{{ openshift_storage_glusterfs_registry_block_image }}" - glusterfs_block_version: "{{ openshift_storage_glusterfs_registry_block_version }}" - glusterfs_block_host_vol_create: "{{ openshift_storage_glusterfs_registry_block_host_vol_create }}" - glusterfs_block_host_vol_size: "{{ openshift_storage_glusterfs_registry_block_host_vol_size }}" - glusterfs_block_host_vol_max: "{{ openshift_storage_glusterfs_registry_block_host_vol_max }}" - glusterfs_block_storageclass: "{{ openshift_storage_glusterfs_registry_block_storageclass | bool }}" - glusterfs_block_storageclass_default: "{{ openshift_storage_glusterfs_registry_block_storageclass_default | bool }}" - glusterfs_s3_deploy: "{{ openshift_storage_glusterfs_registry_s3_deploy | bool }}" - glusterfs_s3_image: "{{ openshift_storage_glusterfs_registry_s3_image }}" - glusterfs_s3_version: "{{ openshift_storage_glusterfs_registry_s3_version }}" - glusterfs_s3_account: "{{ openshift_storage_glusterfs_registry_s3_account }}" - glusterfs_s3_user: "{{ openshift_storage_glusterfs_registry_s3_user }}" - glusterfs_s3_password: "{{ openshift_storage_glusterfs_registry_s3_password }}" - glusterfs_s3_pvc: "{{ openshift_storage_glusterfs_registry_s3_pvc }}" - glusterfs_s3_pvc_size: "{{ openshift_storage_glusterfs_registry_s3_pvc_size }}" - glusterfs_s3_meta_pvc: "{{ openshift_storage_glusterfs_registry_s3_meta_pvc }}" - glusterfs_s3_meta_pvc_size: "{{ openshift_storage_glusterfs_registry_s3_meta_pvc_size }}" - glusterfs_wipe: "{{ openshift_storage_glusterfs_registry_wipe | bool }}" - glusterfs_heketi_is_native: "{{ openshift_storage_glusterfs_registry_heketi_is_native | bool }}" - glusterfs_heketi_is_missing: "{{ openshift_storage_glusterfs_registry_heketi_is_missing | bool }}" - glusterfs_heketi_deploy_is_missing: "{{ openshift_storage_glusterfs_registry_heketi_deploy_is_missing | bool }}" - glusterfs_heketi_cli: "{{ openshift_storage_glusterfs_registry_heketi_cli }}" - glusterfs_heketi_image: "{{ openshift_storage_glusterfs_registry_heketi_image }}" - glusterfs_heketi_version: "{{ openshift_storage_glusterfs_registry_heketi_version }}" - glusterfs_heketi_admin_key: "{{ openshift_storage_glusterfs_registry_heketi_admin_key }}" - glusterfs_heketi_user_key: "{{ openshift_storage_glusterfs_registry_heketi_user_key }}" - glusterfs_heketi_topology_load: "{{ openshift_storage_glusterfs_registry_heketi_topology_load | bool }}" - glusterfs_heketi_wipe: "{{ openshift_storage_glusterfs_registry_heketi_wipe | bool }}" - glusterfs_heketi_url: "{{ openshift_storage_glusterfs_registry_heketi_url }}" - glusterfs_heketi_port: "{{ openshift_storage_glusterfs_registry_heketi_port }}" - glusterfs_heketi_executor: "{{ openshift_storage_glusterfs_registry_heketi_executor }}" - glusterfs_heketi_ssh_port: "{{ openshift_storage_glusterfs_registry_heketi_ssh_port }}" - glusterfs_heketi_ssh_user: "{{ openshift_storage_glusterfs_registry_heketi_ssh_user }}" - glusterfs_heketi_ssh_sudo: "{{ openshift_storage_glusterfs_registry_heketi_ssh_sudo | bool }}" - glusterfs_heketi_ssh_keyfile: "{{ openshift_storage_glusterfs_registry_heketi_ssh_keyfile }}" - glusterfs_heketi_fstab: "{{ openshift_storage_glusterfs_registry_heketi_fstab }}" - glusterfs_nodes: "{% if groups.glusterfs_registry is defined and groups['glusterfs_registry'] | length > 0 %}{% set nodes = groups.glusterfs_registry %}{% elif 'groups.glusterfs' is defined and groups['glusterfs'] | length > 0 %}{% set nodes = groups.glusterfs %}{% else %}{% set nodes = '[]' %}{% endif %}{{ nodes }}" +- include_tasks: glusterfs_registry_facts.yml - include_tasks: glusterfs_common.yml when: diff --git a/roles/openshift_storage_glusterfs/tasks/glusterfs_registry_facts.yml b/roles/openshift_storage_glusterfs/tasks/glusterfs_registry_facts.yml new file mode 100644 index 000000000..5fa5f0895 --- /dev/null +++ b/roles/openshift_storage_glusterfs/tasks/glusterfs_registry_facts.yml @@ -0,0 +1,51 @@ +--- +- set_fact: + glusterfs_timeout: "{{ openshift_storage_glusterfs_registry_timeout }}" + glusterfs_namespace: "{{ openshift_storage_glusterfs_registry_namespace }}" + glusterfs_is_native: "{{ openshift_storage_glusterfs_registry_is_native | bool }}" + glusterfs_name: "{{ openshift_storage_glusterfs_registry_name }}" + # map_from_pairs is a custom filter plugin in role lib_utils + glusterfs_nodeselector: "{{ openshift_storage_glusterfs_registry_nodeselector | default(['storagenode', openshift_storage_glusterfs_registry_name] | join('=')) | map_from_pairs }}" + glusterfs_use_default_selector: "{{ openshift_storage_glusterfs_registry_use_default_selector }}" + glusterfs_storageclass: "{{ openshift_storage_glusterfs_registry_storageclass }}" + glusterfs_storageclass_default: "{{ openshift_storage_glusterfs_registry_storageclass_default | bool }}" + glusterfs_image: "{{ openshift_storage_glusterfs_registry_image }}" + glusterfs_version: "{{ openshift_storage_glusterfs_registry_version }}" + glusterfs_block_deploy: "{{ openshift_storage_glusterfs_registry_block_deploy | bool }}" + glusterfs_block_image: "{{ openshift_storage_glusterfs_registry_block_image }}" + glusterfs_block_version: "{{ openshift_storage_glusterfs_registry_block_version }}" + glusterfs_block_host_vol_create: "{{ openshift_storage_glusterfs_registry_block_host_vol_create }}" + glusterfs_block_host_vol_size: "{{ openshift_storage_glusterfs_registry_block_host_vol_size }}" + glusterfs_block_host_vol_max: "{{ openshift_storage_glusterfs_registry_block_host_vol_max }}" + glusterfs_block_storageclass: "{{ openshift_storage_glusterfs_registry_block_storageclass | bool }}" + glusterfs_block_storageclass_default: "{{ openshift_storage_glusterfs_registry_block_storageclass_default | bool }}" + glusterfs_s3_deploy: "{{ openshift_storage_glusterfs_registry_s3_deploy | bool }}" + glusterfs_s3_image: "{{ openshift_storage_glusterfs_registry_s3_image }}" + glusterfs_s3_version: "{{ openshift_storage_glusterfs_registry_s3_version }}" + glusterfs_s3_account: "{{ openshift_storage_glusterfs_registry_s3_account }}" + glusterfs_s3_user: "{{ openshift_storage_glusterfs_registry_s3_user }}" + glusterfs_s3_password: "{{ openshift_storage_glusterfs_registry_s3_password }}" + glusterfs_s3_pvc: "{{ openshift_storage_glusterfs_registry_s3_pvc }}" + glusterfs_s3_pvc_size: "{{ openshift_storage_glusterfs_registry_s3_pvc_size }}" + glusterfs_s3_meta_pvc: "{{ openshift_storage_glusterfs_registry_s3_meta_pvc }}" + glusterfs_s3_meta_pvc_size: "{{ openshift_storage_glusterfs_registry_s3_meta_pvc_size }}" + glusterfs_wipe: "{{ openshift_storage_glusterfs_registry_wipe | bool }}" + glusterfs_heketi_is_native: "{{ openshift_storage_glusterfs_registry_heketi_is_native | bool }}" + glusterfs_heketi_is_missing: "{{ openshift_storage_glusterfs_registry_heketi_is_missing | bool }}" + glusterfs_heketi_deploy_is_missing: "{{ openshift_storage_glusterfs_registry_heketi_deploy_is_missing | bool }}" + glusterfs_heketi_cli: "{{ openshift_storage_glusterfs_registry_heketi_cli }}" + glusterfs_heketi_image: "{{ openshift_storage_glusterfs_registry_heketi_image }}" + glusterfs_heketi_version: "{{ openshift_storage_glusterfs_registry_heketi_version }}" + glusterfs_heketi_admin_key: "{{ openshift_storage_glusterfs_registry_heketi_admin_key }}" + glusterfs_heketi_user_key: "{{ openshift_storage_glusterfs_registry_heketi_user_key }}" + glusterfs_heketi_topology_load: "{{ openshift_storage_glusterfs_registry_heketi_topology_load | bool }}" + glusterfs_heketi_wipe: "{{ openshift_storage_glusterfs_registry_heketi_wipe | bool }}" + glusterfs_heketi_url: "{{ openshift_storage_glusterfs_registry_heketi_url }}" + glusterfs_heketi_port: "{{ openshift_storage_glusterfs_registry_heketi_port }}" + glusterfs_heketi_executor: "{{ openshift_storage_glusterfs_registry_heketi_executor }}" + glusterfs_heketi_ssh_port: "{{ openshift_storage_glusterfs_registry_heketi_ssh_port }}" + glusterfs_heketi_ssh_user: "{{ openshift_storage_glusterfs_registry_heketi_ssh_user }}" + glusterfs_heketi_ssh_sudo: "{{ openshift_storage_glusterfs_registry_heketi_ssh_sudo | bool }}" + glusterfs_heketi_ssh_keyfile: "{{ openshift_storage_glusterfs_registry_heketi_ssh_keyfile }}" + glusterfs_heketi_fstab: "{{ openshift_storage_glusterfs_registry_heketi_fstab }}" + glusterfs_nodes: "{% if groups.glusterfs_registry is defined and groups['glusterfs_registry'] | length > 0 %}{% set nodes = groups.glusterfs_registry %}{% elif 'groups.glusterfs' is defined and groups['glusterfs'] | length > 0 %}{% set nodes = groups.glusterfs %}{% else %}{% set nodes = '[]' %}{% endif %}{{ nodes }}" diff --git a/roles/openshift_storage_glusterfs/tasks/glusterfs_uninstall.yml b/roles/openshift_storage_glusterfs/tasks/glusterfs_uninstall.yml new file mode 100644 index 000000000..a5774cc75 --- /dev/null +++ b/roles/openshift_storage_glusterfs/tasks/glusterfs_uninstall.yml @@ -0,0 +1,116 @@ +--- + +- name: Delete pre-existing heketi resources + oc_obj: + namespace: "{{ glusterfs_namespace }}" + kind: "{{ item.kind }}" + name: "{{ item.name | default(omit) }}" + selector: "{{ item.selector | default(omit) }}" + state: absent + with_items: + - kind: "template,route,service,dc,jobs,secret" + selector: "deploy-heketi" + - kind: "svc" + name: "heketi-storage-endpoints" + - kind: "svc" + name: "heketi-storage" + - kind: "secret" + name: "heketi-{{ glusterfs_name }}-topology-secret" + - kind: "template,route,service,dc" + name: "heketi-{{ glusterfs_name }}" + - kind: "svc" + name: "heketi-db-{{ glusterfs_name }}-endpoints" + - kind: "sa" + name: "heketi-{{ glusterfs_name }}-service-account" + - kind: "secret" + name: "heketi-{{ glusterfs_name }}-admin-secret" + - kind: "secret" + name: "heketi-{{ glusterfs_name }}-config-secret" + failed_when: False + +- name: Delete pre-existing GlusterFS resources + oc_obj: + namespace: "{{ glusterfs_namespace }}" + kind: "{{ item.kind }}" + name: "{{ item.name }}" + state: absent + with_items: + - kind: template + name: glusterfs + - kind: daemonset + name: "glusterfs-{{ glusterfs_name }}" + - kind: storageclass + name: "glusterfs-{{ glusterfs_name }}" + +- name: Unlabel any existing GlusterFS nodes + oc_label: + name: "{{ hostvars[item].openshift.node.nodename }}" + kind: node + state: absent + labels: "{{ glusterfs_nodeselector | lib_utils_oo_dict_to_list_of_dict }}" + with_items: "{{ groups.all }}" + +- name: Delete pre-existing GlusterFS config + file: + path: /var/lib/glusterd + state: absent + delegate_to: "{{ item }}" + with_items: "{{ glusterfs_nodes | default([]) }}" + +- name: Delete pre-existing additional GlusterFS config + file: + path: /etc/glusterfs + state: absent + delegate_to: "{{ item }}" + with_items: "{{ glusterfs_nodes | default([]) }}" + +- name: Delete pre-existing Heketi config + file: + path: /var/lib/heketi + state: absent + delegate_to: "{{ item }}" + with_items: "{{ glusterfs_nodes | default([]) }}" + +- name: Delete Glusterfs logs + file: + path: /var/log/glusterfs + state: absent + delegate_to: "{{ item }}" + with_items: "{{ glusterfs_nodes | default([]) }}" + +- name: Delete deploy resources + oc_obj: + namespace: "{{ glusterfs_namespace }}" + kind: "{{ item.kind }}" + name: "{{ item.name | default(omit) }}" + selector: "{{ item.selector | default(omit) }}" + state: absent + with_items: + - kind: "template,route,service,jobs,dc,secret" + selector: "deploy-heketi" + - kind: "svc" + name: "heketi-storage-endpoints" + - kind: "secret" + name: "heketi-{{ glusterfs_name }}-topology-secret" + +- name: Get GlusterFS storage devices state + command: "pvdisplay -C --noheadings -o pv_name,vg_name {% for device in hostvars[item].glusterfs_devices %}{{ device }} {% endfor %}" + register: devices_info + delegate_to: "{{ item }}" + with_items: "{{ glusterfs_nodes | default([]) }}" + failed_when: False + when: glusterfs_wipe + + # Runs "lvremove -ff <vg>; vgremove -fy <vg>; pvremove -fy <pv>" for every device found to be a physical volume. +- name: Clear GlusterFS storage device contents + shell: "{% for line in item.stdout_lines %}{% set fields = line.split() %}{% if fields | count > 1 %}lvremove -ff {{ fields[1] }}; vgremove -fy {{ fields[1] }}; {% endif %}pvremove -fy {{ fields[0] }}; {% endfor %}" + delegate_to: "{{ item.item }}" + with_items: "{{ devices_info.results }}" + register: clear_devices + until: + - "'contains a filesystem in use' not in clear_devices.stderr" + delay: 1 + retries: 30 + when: + - glusterfs_wipe + - item.stdout_lines | count > 0 diff --git a/roles/openshift_storage_glusterfs/tasks/uninstall.yml b/roles/openshift_storage_glusterfs/tasks/uninstall.yml new file mode 100644 index 000000000..dcf0c9357 --- /dev/null +++ b/roles/openshift_storage_glusterfs/tasks/uninstall.yml @@ -0,0 +1,12 @@ +--- +- name: uninstall glusterfs + block: + - include_tasks: glusterfs_config_facts.yml + - include_tasks: glusterfs_uninstall.yml + when: "'glusterfs' in groups and groups['glusterfs'] | length > 0" + +- name: uninstall glusterfs registry + block: + - include_tasks: glusterfs_registry_facts.yml + - include_tasks: glusterfs_uninstall.yml + when: "'glusterfs_registry' in groups and groups['glusterfs_registry'] | length > 0" |