EFI: Take into consideration the new GPT layout.
[ta/infra-ansible.git] / roles / partfs_rootdisk / tasks / remove_old_instance_vg.yml
1 ---
2
3 # Copyright 2019 Nokia
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 - set_fact:
18     instance_disk_part: "{% if root_disk == default_rootdisk_device %}{{root_disk}}{{instance_part_number}}{% else %}{{root_disk}}-part{{instance_part_number}}{% endif %}"
19
20 - debug:
21     msg: "instance partition: {{ instance_disk_part }}"
22
23 - name: get volume pools
24   shell: dmsetup ls | awk '/volumes/ {print $1}'
25   register: volume_pools
26   ignore_errors: yes
27
28 - debug:
29     msg: "volume pools: {{ volume_pools.stdout_lines }}"
30
31 - name: remove volume pools 1 round
32   shell: dmsetup remove {{ item }}
33   with_items: "{{ volume_pools.stdout_lines }}"
34   ignore_errors: yes
35   when: volume_pools.stdout_lines
36
37 - name: get volume pools
38   shell: dmsetup ls | awk '/volumes/ {print $1}'
39   register: volume_pools
40   ignore_errors: yes
41
42 - debug:
43     msg: "volume pools: {{ volume_pools.stdout_lines }}"
44
45 - name: remove volume pools 2 round
46   shell: dmsetup remove {{ item }}
47   with_items: "{{ volume_pools.stdout_lines }}"
48   ignore_errors: yes
49   when: volume_pools.stdout_lines
50
51 - name: get volume groups
52   shell: "vgs -o vg_name --noheadings | sed 's/ //g'"
53   register: volumegroups
54
55 - debug:
56     msg: "volume groups: {{ volumegroups.stdout_lines }}"
57
58 - name: remove volume groups
59   lvg: vg={{ item }} state=absent force=yes
60   ignore_errors: yes
61   with_items: "{{ volumegroups.stdout_lines }}"
62   when:
63     - volumegroups.stdout_lines
64     - item != "VG"
65
66 - name: remove physical volume (if any)
67   shell: pvremove {{ instance_disk_part }}
68   ignore_errors: yes
69
70 - name: get volume groups
71   shell: "vgs -o vg_name --noheadings | sed 's/ //g'"
72   register: volumegroups
73   ignore_errors: yes
74
75 - debug:
76     msg: "volume groups: {{ volumegroups.stdout_lines }}"
77
78 - name: get volume pools
79   shell: dmsetup ls | awk '{print $1}'
80   register: volume_pools
81   ignore_errors: yes
82
83 - debug:
84     msg: "volume pools: {{ volume_pools.stdout_lines }}"