You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

  1. ---
  2. # Running growpart seems to be only required on Azure, as other Cloud Providers do this at boot time
  3. - name: install growpart
  4. package:
  5. name: cloud-utils-growpart
  6. state: present
  7. - name: Gather mounts facts
  8. setup:
  9. gather_subset: 'mounts'
  10. - name: Search root filesystem device
  11. vars:
  12. query: "[?mount=='/'].device"
  13. _root_device: "{{ ansible_mounts|json_query(query) }}"
  14. set_fact:
  15. device: "{{ _root_device | first | regex_replace('([^0-9]+)[0-9]+', '\\1') }}"
  16. partition: "{{ _root_device | first | regex_replace('[^0-9]+([0-9]+)', '\\1') }}"
  17. root_device: "{{ _root_device }}"
  18. - name: check if growpart needs to be run
  19. command: growpart -N {{ device }} {{ partition }}
  20. failed_when: False
  21. changed_when: "'NOCHANGE:' not in growpart_needed.stdout"
  22. register: growpart_needed
  23. environment:
  24. LC_ALL: C
  25. - name: check fs type
  26. command: file -Ls {{ root_device }}
  27. changed_when: False
  28. register: fs_type
  29. - name: run growpart # noqa 503
  30. command: growpart {{ device }} {{ partition }}
  31. when: growpart_needed.changed
  32. environment:
  33. LC_ALL: C
  34. - name: run xfs_growfs # noqa 503
  35. command: xfs_growfs {{ root_device }}
  36. when: growpart_needed.changed and 'XFS' in fs_type.stdout