Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine root filesistem device and partition before running growpart #8024

Merged
merged 1 commit into from
Sep 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions roles/kubernetes/preinstall/tasks/0120-growpart-azure-centos-7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,34 @@
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
environment:
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