--- # 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. - name: Gather variables for each operating system include_vars: "{{ item }}" with_first_found: - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - "{{ ansible_distribution | lower }}.yml" - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - "{{ ansible_os_family | lower }}.yml" tags: - always - name: Stop all cloud-init services and disable them systemd: name: "{{item}}" enabled: no state: stopped with_items: - "cloud-config" - "cloud-final" - "cloud-init" - "cloud-init-local" - name: Remove udev rule which enables dhcp on the first interface file: path="/etc/udev/rules.d/70-persistent-net.rules" state=absent - name: Remove interface configuration which use dhcp shell: rm -f $(grep -li BOOTPROTO.*dhcp /etc/sysconfig/network-scripts/ifcfg-* | sort -u) - name : Get system disk info parted: device: "{{root_disk}}" unit: GB register: root_disk_info - debug: msg: "root_disk_info: {{root_disk_info}}" - set_fact: sys_part: "{{ root_disk_info.partitions|selectattr('num', 'equalto', 1)|first }}" sys_part_number: 1 when: root_disk_info.disk.table == "msdos" - set_fact: sys_part: "{{ root_disk_info.partitions|selectattr('num', 'equalto', 3)|first }}" sys_part_number: 3 when: root_disk_info.disk.table == "gpt" - debug: msg: "sys_part = {{root_disk}}{{sys_part_number}}: {{sys_part}}" - name: get volume pools shell: dmsetup ls | awk '{print $1}' register: volume_pools ignore_errors: yes - debug: msg: "volume pools: {{ volume_pools.stdout_lines }}" - name: Delete old LVMs if not mounted already script: "{{role_path}}/scripts/old_vol_rm.sh" args: creates: /etc/partfs_rootdisk_created - 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 }}" - name: remove old volume groups include: remove_old_instance_vg.yml - name: delete temporary partition parted: device: "{{root_disk}}" number: "{{ sys_part_number|int + 1 }}" state: absent when: delete_partition is defined - name: configure root volume groups include: root_disk_volume_groups.yml vars: create_disk_part: True - name: configure instance disk partition parted: device: "{{root_disk}}" number: "{{instance_part_number}}" part_start: "{{instance_part_start}}GB" flags: [ lvm ] state: present when: rootdisk_vg_percentage != all_disk_size_for_volume_group_vg - name: remove old volume groups include: remove_old_instance_vg.yml - name: create /etc/partfs_rootdisk_created file command: touch /etc/partfs_rootdisk_created args: creates: /etc/partfs_rootdisk_created