Merge pull request #48 from Tcharl/rebased

XFS resize
This commit is contained in:
Larry Smith Jr
2020-06-07 20:05:35 -04:00
committed by GitHub
4 changed files with 50 additions and 56 deletions

View File

@@ -1,4 +1,21 @@
---
# unable to resize xfs: looks like we've to reference the mountpoint instead of the device
- name: create_fs | check already converted
# at least xfs is executed twice if the partition has changed in the meantime
# then it tries to recreate the fs on the mounted fs which indeed fails...
shell: "xfs_info {{ lv.mntp }} | grep -c 'ftype=1'"
become: yes
register: mountedxfs
ignore_errors: true
changed_when: false
when:
- lv is defined and lv != 'None'
- lv.filesystem is defined
- lv.filesystem == "xfs"
- lv.create is defined
- lv.create|bool
- name: create_fs | unmounting filesystem(s)
mount:
path: "{{ lv.mntp }}"
@@ -6,9 +23,6 @@
fstype: "{{ lv.filesystem | default(omit) }}"
state: absent
become: true
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
when:
- lv is defined
- lv != 'None'
@@ -21,9 +35,6 @@
fstype: "{{ lv.filesystem }}"
dev: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
resizefs: yes
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
become: true
when:
- vg.create is defined
@@ -36,32 +47,10 @@
- lv.filesystem != 'None'
- lv.filesystem != 'xfs'
# unable to resize xfs: looks like we've to reference the mountpoint instead of the device
- name: create_fs | check already converted
# at least xfs is executed twice if the partition has changed in the meantime
# then it tries to recreate the fs on the mounted fs which indeed fails...
shell: "xfs_info {{ lv.mntp }} | grep -c 'ftype=1'"
become: yes
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
register: mountedxfs
ignore_errors: true
changed_when: false
when:
- lv is defined and lv != 'None'
- lv.filesystem is defined
- lv.filesystem == "xfs"
- lv.create is defined
- lv.create|bool
- name: create_fs | creating new xfs filesystem on new LVM logical volume(s)
filesystem:
fstype: "{{ lv.filesystem }}"
dev: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
become: true
when:
- mountedxfs is failed
@@ -82,9 +71,6 @@
state: mounted
opts: "{{ lv.mopts | default('defaults') }}"
become: true
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
when:
- vg.create is defined
- vg.create|bool
@@ -94,3 +80,17 @@
- lv.create|bool
- lv.mount is defined
- lv.mount|bool
- name: create_fs | resizing xfs filesystem on new LVM logical volume(s)
command: "xfs_growfs {{ lv.mntp }}"
become: true
when:
- vg.create is defined
- vg.create|bool
- lv is defined
- lv != 'None'
- lv.create is defined
- lv.create|bool
- lv.filesystem is defined
- lv.filesystem == 'xfs'
- lvchanged.changed

View File

@@ -1,17 +1,10 @@
---
- name: create_lv | Display Volume Group
debug:
var: vg
verbosity: 2
- name: create_lv | debug lvm
loop: "{{ vg.lvnames | default([]) }}"
debug:
var: lv
verbosity: 1
loop_control:
loop_var: lv
- name: create_lv | creating new LVM logical volume(s)
lvol:
vg: "{{ vg.vgname }}"
@@ -20,10 +13,8 @@
shrink: false
opts: "{{ lv.opts | default('') }}"
state: present
loop: "{{ vg.lvnames | default([]) }}"
loop_control:
loop_var: lv
become: true
register: lvchanged
when:
- vg.create is defined
- vg.create|bool
@@ -31,3 +22,10 @@
- lv != 'None'
- lv.create is defined
- lv.create|bool
- name: create_lv | debug changed attribute
debug:
var: lvchanged
- name: create_lv | configuring FS
include_tasks: create_fs.yml

View File

@@ -1,11 +1,16 @@
---
- name: create_vg | creating new LVM volume group(s)
lvg:
vg: "{{ item.vgname }}"
pvs: "{{ item.disks | join(',') }}"
vg: "{{ vg.vgname }}"
pvs: "{{ vg.disks | join(',') }}"
state: present
become: true
loop: "{{ lvm_groups }}"
when:
- item.create is defined
- item.create|bool
- vg.create is defined
- vg.create|bool
- name: manage_lvm | loop over logical volume group(s) to create logical volumes
include_tasks: create_lv.yml
loop: "{{ vg.lvnames | default([]) }}"
loop_control:
loop_var: lv

View File

@@ -1,15 +1,6 @@
---
- name: manage_lvm | manage physical volume group creation
include_tasks: create_vg.yml
- name: manage_lvm | loop over logical volume group(s) to create logical volumes
include_tasks: create_lv.yml
loop: "{{ lvm_groups }}"
loop_control:
loop_var: vg
- name: manage_lvm | loop over logical volume group(s) to create filesystems
include_tasks: create_fs.yml
loop: "{{ lvm_groups }}"
loop_control:
loop_var: vg