--- /dev/null
+---
+
+# Copyright 2019 Nokia
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+- set_fact:
+ root_disk_part3: "{% if root_disk == default_rootdisk_device %}{{root_disk}}3{% else %}{{root_disk}}-part3{% endif %}"
+
+- debug:
+ msg: "root disk part3: {{ root_disk_part3 }}"
+
+- name: get volume pools
+ shell: dmsetup ls | awk '/volumes/ {print $1}'
+ register: volume_pools
+ ignore_errors: yes
+
+- debug:
+ msg: "volume pools: {{ volume_pools.stdout_lines }}"
+
+- name: remove volume pools 1 round
+ shell: dmsetup remove {{ item }}
+ with_items: "{{ volume_pools.stdout_lines }}"
+ ignore_errors: yes
+ when: volume_pools.stdout_lines
+
+- name: get volume pools
+ shell: dmsetup ls | awk '/volumes/ {print $1}'
+ register: volume_pools
+ ignore_errors: yes
+
+- debug:
+ msg: "volume pools: {{ volume_pools.stdout_lines }}"
+
+- name: remove volume pools 2 round
+ shell: dmsetup remove {{ item }}
+ with_items: "{{ volume_pools.stdout_lines }}"
+ ignore_errors: yes
+ when: volume_pools.stdout_lines
+
+- name: get volume groups
+ shell: "vgs -o vg_name --noheadings | sed 's/ //g'"
+ register: volumegroups
+
+- debug:
+ msg: "volume groups: {{ volumegroups.stdout_lines }}"
+
+- name: remove volume groups
+ lvg: vg={{ item }} state=absent force=yes
+ ignore_errors: yes
+ with_items: "{{ volumegroups.stdout_lines }}"
+ when:
+ - volumegroups.stdout_lines
+ - item != "VG"
+
+- name: remove physical volume (if any)
+ shell: pvremove {{ root_disk_part3 }}
+ ignore_errors: yes
+
+- name: get volume groups
+ shell: "vgs -o vg_name --noheadings | sed 's/ //g'"
+ register: volumegroups
+ ignore_errors: yes
+
+- debug:
+ msg: "volume groups: {{ volumegroups.stdout_lines }}"
+
+- name: get volume pools
+ shell: dmsetup ls | awk '{print $1}'
+ register: volume_pools
+ ignore_errors: yes
+
+- debug:
+ msg: "volume pools: {{ volume_pools.stdout_lines }}"