2016-12-09 12:27:50 +00:00
|
|
|
---
|
|
|
|
|
2016-12-12 13:14:22 +00:00
|
|
|
# Running growpart seems to be only required on Azure, as other Cloud Providers do this at boot time
|
|
|
|
|
2016-12-09 12:27:50 +00:00
|
|
|
- name: install growpart
|
2017-02-17 21:22:34 +00:00
|
|
|
package:
|
|
|
|
name: cloud-utils-growpart
|
2019-04-18 08:34:08 +00:00
|
|
|
state: present
|
2016-12-09 12:27:50 +00:00
|
|
|
|
2021-09-28 06:58:42 +00:00
|
|
|
- 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 }}"
|
|
|
|
|
2016-12-09 12:27:50 +00:00
|
|
|
- name: check if growpart needs to be run
|
2021-09-28 06:58:42 +00:00
|
|
|
command: growpart -N {{ device }} {{ partition }}
|
2016-12-09 12:27:50 +00:00
|
|
|
failed_when: False
|
|
|
|
changed_when: "'NOCHANGE:' not in growpart_needed.stdout"
|
|
|
|
register: growpart_needed
|
2018-08-05 10:48:07 +00:00
|
|
|
environment:
|
2018-07-30 22:52:56 +00:00
|
|
|
LC_ALL: C
|
2016-12-09 12:27:50 +00:00
|
|
|
|
|
|
|
- name: check fs type
|
2021-09-28 06:58:42 +00:00
|
|
|
command: file -Ls {{ root_device }}
|
2016-12-09 12:27:50 +00:00
|
|
|
changed_when: False
|
|
|
|
register: fs_type
|
|
|
|
|
2020-07-27 13:24:17 +00:00
|
|
|
- name: run growpart # noqa 503
|
2021-09-28 06:58:42 +00:00
|
|
|
command: growpart {{ device }} {{ partition }}
|
2016-12-09 12:27:50 +00:00
|
|
|
when: growpart_needed.changed
|
2018-08-05 10:48:07 +00:00
|
|
|
environment:
|
2018-07-30 22:56:09 +00:00
|
|
|
LC_ALL: C
|
2016-12-09 12:27:50 +00:00
|
|
|
|
2020-07-27 13:24:17 +00:00
|
|
|
- name: run xfs_growfs # noqa 503
|
2021-09-28 06:58:42 +00:00
|
|
|
command: xfs_growfs {{ root_device }}
|
2018-07-30 22:52:56 +00:00
|
|
|
when: growpart_needed.changed and 'XFS' in fs_type.stdout
|