I figured out how to do this, by the way. In site.pp, adding:
Lvm::Logical_volume {
fs_type => lookup('foo::default_fstype'),
options => lookup('foo::default_options'),
size_is_minsize => true,
}
did the trick. Theoretically I could have done something with '*' =>
lookup('foo::default_options') or whatever but this was fine for now.
https://puppet.com/docs/puppet/5.5/lang_defaults.html has more
documentation on the matter.
-stefan
On Monday, August 31, 2020 at 11:28:52 AM UTC-5 Stefan Strandberg wrote:
> Hello,
>
> I have a use case where I'm trying to set a default variable for a defined
> type parameter that's unfortunately fairly nested. Perhaps there's an
> obvious solution for this that I'm missing, but I'm not finding it.
>
> In my specific use case, we're trying to have the puppetlabs-lvm class
> managed wholly in hiera, with an example as follows:
>
> lvm::volume_groups:
> Volume00:
> physical_volumes:
> - /dev/sda3
> logical_volumes:
> root:
> size: 2G
> mountpath: /
> fs_type: xfs
> usr:
> size: 4G
> mountpath: /
> options: defaults,nodev
> fs_type: xfs
>
> And so forth. Unfortunately, it gets cumbersome setting fs_type to xfs
> for every single mount, especially when spread across multiple yamls.
> Unfortunately, the puppetlabs-lvm logical_volume.pp is a defined type that
> defaults fs_type to ext4, and I'm not sure how to override that as a
> default without having to enter it in for every single filesystem.
>
> Is there any way to do this, or does it need to be done specifically for
> every single filesystem? I think it's a bit too nested for a wrapper class
> that calls create_resources('lvm::volume_groups', $my_filesystems,
> $my_defaults) or similar, I think I'd have to instead create at least two
> wrappers which I'd rather avoid and keep this as simple as practical.
>
> So, I suppose in summary the question is if there's any way to effectively
> globally override a defined type's parameter default value solely in hiera
> and without writing wrapper classes?
>
> Thanks,
>
> -stefan
>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/bd43edbb-15c7-4049-8e66-73844f094924n%40googlegroups.com.