Feature #8393

puppet-lvm filesystem provider need options parameter for mkfs create options

Added by Mikael Fridh almost 2 years ago. Updated almost 2 years ago.

Status:ClosedStart date:07/12/2011
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:lvmEstimated time:1.00 hour
Target version:-Spent time:-
Keywords:puppet-lvm lvm mkfs Branch:

Description

I needed to be able to specify filesystem create options to mkfs.xfs, so I made this simple patch:

diff --git a/README.markdown b/README.markdown
index 912576f..c3465ba 100644
--- a/README.markdown
+++ b/README.markdown
@@ -26,12 +26,13 @@ Here's a simple working example:
}
logical_volume { "mylv":
ensure => present,
-        volume_group => "myvg"
+        volume_group => "myvg",
size => "20G"
}
filesystem { "/dev/myvg/mylv":
-        ensure => present
-        fs_type => "ext3"
+        ensure => present,
+        fs_type => "ext3",
+        options => '-b 4096 -E stride=32,stripe-width=64'
}
This simple 1 physical volume, 1 volume group, 1 logical volume case
@@ -40,6 +41,8 @@ be shortened to be:
volume("myvg", "/dev/hdc", "mylv", "ext3", "20G")
+Except that in the latter case you cannot specify create options.
+
If you need a more complex configuration, you'll need to build the
resources out yourself.
diff --git a/lib/puppet/provider/filesystem/lvm.rb b/lib/puppet/provider/filesystem/lvm.rb
index c464d56..241ec0b 100644
--- a/lib/puppet/provider/filesystem/lvm.rb
+++ b/lib/puppet/provider/filesystem/lvm.rb
@@ -29,6 +29,11 @@ Puppet::Type.type(:filesystem).provide :lvm do
command_array << mkfs_params[fs_type]
end
+        if resource[:options]
+            mkfs_options = Array.new(resource[:options].split)
+            mkfs_cmd << mkfs_options
+        end
+
execute mkfs_cmd
end
diff --git a/lib/puppet/type/filesystem.rb b/lib/puppet/type/filesystem.rb
index e945785..d456465 100644
--- a/lib/puppet/type/filesystem.rb
+++ b/lib/puppet/type/filesystem.rb
@@ -19,4 +19,8 @@ Puppet::Type.newtype(:filesystem) do
end
end
+    newparam(:options) do
+        desc "Params for the mkfs command. eg. -l internal,agcount=x"
+    end
+
end

puppet-lvm-mkfs-options.patch Magnifier (1.89 KB) Mikael Fridh, 07/12/2011 04:15 pm

History

#1 Updated by Mikael Fridh almost 2 years ago

  • File deleted (0001-Allow-filesystem-type-to-accept-parameters-options.patch)

#2 Updated by Mikael Fridh almost 2 years ago

Of course I go and botch that patch, there was a small mistake in the provider, here’s how it should be:

diff --git a/lib/puppet/provider/filesystem/lvm.rb b/lib/puppet/provider/filesystem/lvm.rb
index c464d56..76256f9 100644
--- a/lib/puppet/provider/filesystem/lvm.rb
+++ b/lib/puppet/provider/filesystem/lvm.rb
@@ -26,9 +26,14 @@ Puppet::Type.type(:filesystem).provide :lvm do
         mkfs_cmd    = ["mkfs.#{fs_type}", @resource[:name]]
         
         if mkfs_params[fs_type]
-            command_array << mkfs_params[fs_type]
+            mkfs_cmd << mkfs_params[fs_type]
         end
         
+        if resource[:options]
+            mkfs_options = Array.new(resource[:options].split)
+            mkfs_cmd << mkfs_options
+        end
+
         execute mkfs_cmd
     end
 
diff --git a/lib/puppet/type/filesystem.rb b/lib/puppet/type/filesystem.rb
index e945785..d456465 100644
--- a/lib/puppet/type/filesystem.rb
+++ b/lib/puppet/type/filesystem.rb
@@ -19,4 +19,8 @@ Puppet::Type.newtype(:filesystem) do
         end
     end
 
+    newparam(:options) do
+        desc "Params for the mkfs command. eg. -l internal,agcount=x"
+    end
+
 end

#3 Updated by Mikael Fridh almost 2 years ago

  • Assignee set to Matt Robinson
  • Estimated time set to 1.00

small fix and improvement

#4 Updated by Matt Robinson almost 2 years ago

  • Status changed from Unreviewed to Closed
  • Assignee deleted (Matt Robinson)

Hey Mikael, thanks for the patch.

Assigning it to me doesn’t really do anything since I won’t have time to work on it in the near future since I’ve got a feature project I’m doing right now. The best way to get this in is to file a github pull request since it’s a patch to a module (which could have been clearer in this ticket). https://github.com/puppetlabs/puppet-lvm

Our process for submitting code for modules isn’t nearly as standardized as it is for committing to puppet itself (http://projects.puppetlabs.com/projects/puppet/wiki/Development_Development_Lifecycle for future reference). We’re working on making module ownership and submission processes easier, but until then we’ll probably just merge a pull request you send.

#5 Updated by James Turnbull almost 2 years ago

  • Status changed from Closed to Accepted

Matt – the ticket shouldn’t be closed though.

#6 Updated by James Turnbull almost 2 years ago

  • Project changed from Puppet to Puppet Labs Modules
  • Category deleted (provider)

#7 Updated by Mikael Fridh almost 2 years ago

Matt Robinson wrote:

Assigning it to me doesn’t really do anything since I won’t have time to work on it in the near future since I’ve got a feature project I’m doing right now. The best way to get this in is to file a github pull request since it’s a patch to a module (which could have been clearer in this ticket). https://github.com/puppetlabs/puppet-lvm

I’ll try to improve my reporting as I go along.

Ok guys, I created a pull request: https://github.com/puppetlabs/puppet-lvm/pull/2

#8 Updated by Ken Barber almost 2 years ago

  • Category set to lvm

#9 Updated by Matthaus Owens almost 2 years ago

  • Status changed from Accepted to Merged - Pending Release

Merged in commit https://github.com/puppetlabs/puppet-lvm/commit/729eb39e49b480b289bd21abbb969e0010166cd2

Updated tests for provider coming soon.

#10 Updated by Matthaus Owens almost 2 years ago

  • Status changed from Merged - Pending Release to Closed

Tests updated in #9272

Also available in: Atom PDF