Browse Source

Determine root filesistem device and partition before running growpart (#8024)

pull/8029/head
Marcos Lorenzo 3 years ago
committed by GitHub
parent
commit
4c5328fd1f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 4 deletions
  1. 17
      roles/kubernetes/preinstall/tasks/0120-growpart-azure-centos-7.yml

17
roles/kubernetes/preinstall/tasks/0120-growpart-azure-centos-7.yml

@ -7,8 +7,17 @@
name: cloud-utils-growpart
state: present
- name: Search root filesystem device
vars:
query: "[?mount=='/'].device"
_root_device: "{{ ansible_mounts|json_query(query) }}"
set_fact:
device: "{{ _root_device | first | regex_replace('([^0-9]+)[0-9]+', '\\1') }}"
partition: "{{ _root_device | first | regex_replace('[^0-9]+([0-9]+)', '\\1') }}"
root_device: "{{ _root_device }}"
- name: check if growpart needs to be run
command: growpart -N /dev/sda 1
command: growpart -N {{ device }} {{ partition }}
failed_when: False
changed_when: "'NOCHANGE:' not in growpart_needed.stdout"
register: growpart_needed
@ -16,16 +25,16 @@
LC_ALL: C
- name: check fs type
command: file -Ls /dev/sda1
command: file -Ls {{ root_device }}
changed_when: False
register: fs_type
- name: run growpart # noqa 503
command: growpart /dev/sda 1
command: growpart {{ device }} {{ partition }}
when: growpart_needed.changed
environment:
LC_ALL: C
- name: run xfs_growfs # noqa 503
command: xfs_growfs /dev/sda1
command: xfs_growfs {{ root_device }}
when: growpart_needed.changed and 'XFS' in fs_type.stdout
Loading…
Cancel
Save