diff --git a/defaults/main.yml b/defaults/main.yml index 476616b9..743bbbb9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -8,6 +8,7 @@ storage_safe_mode: true # fail instead of implicitly/automatically removing dev storage_pool_defaults: state: "present" type: lvm + volumes: [] storage_volume_defaults: state: "present" diff --git a/library/blivet.py b/library/blivet.py index 858ca2f9..d288f8ea 100644 --- a/library/blivet.py +++ b/library/blivet.py @@ -167,7 +167,7 @@ def _get_format(self): fmt = get_format(self._volume['fs_type'], mountpoint=self._volume.get('mount_point'), label=self._volume['fs_label'], - options=self._volume['fs_create_options']) + create_options=self._volume['fs_create_options']) if not fmt.supported or not fmt.formattable: raise BlivetAnsibleError("required tools for file system '%s' are missing" % self._volume['fs_type']) @@ -209,6 +209,8 @@ def _resize(self): raise BlivetAnsibleError("volume '%s' cannot be resized from %s to %s: %s" % (self._device.name, self._device.size, size, str(e))) + elif size and self._device.size != size and not self._device.resizable: + raise BlivetAnsibleError("volume '%s' cannot be resized from %s to %s" % (self._device.name, self._device.size, size)) def _reformat(self): """ Schedule actions as needed to ensure the volume is formatted as specified. """ @@ -224,6 +226,8 @@ def _reformat(self): if self._device.format.status and not packages_only: self._device.format.teardown() + if not self._device.isleaf: + self._blivet.devicetree.recursive_remove(self._device, remove_device=False) self._blivet.format_device(self._device, fmt) def manage(self): @@ -247,6 +251,9 @@ def manage(self): if self._device.exists: self._reformat() + if self.ultimately_present and self._volume['mount_point'] and not self._device.format.mountable: + raise BlivetAnsibleError("volume '%s' has a mount point but no mountable file system" % self._volume['name']) + # schedule resize if appropriate if self._device.exists and self._volume['size']: self._resize()