Both parts of the problem strike me as being caused by your try to chain
a secondary configuration off of the storage.config handling. This might
be the most straightforward/logical map of the trafficserver's logic,
but it does not really reflect the reality of puppet managing it. You
seem to have already considered factoring the problem into a puppet
define that manages the storage.config and the directory in parallel
(judging from the comment in [¹]) but I do not quite follow your
reasoning and would think that a separate type to handle the actual
config file and a define to actually configure a tserver::directory,
tserver::raw_device, etc. would allow you to have proper parameters
depending on the configured cache location type and surprisingly also
provide you with a high degree of safety.
> define trafficserver::device($id = undef, $volume = undef) {
> trafficserver_storage { $name: id => $id, volume => $volume; }
> udev::access_rule { $name: user => $trafficserver::user, ... }
> }
>
> define trafficserver::directory($size, $id = undef, $volume = undef) {
> validate_path($name)
> validate_size($size)
> trafficserver_storage { $name: id => $id, volume => $volume, size => $size; }
> file { $name: ensure => directory, force => false, owner => $trafficserver::user, ... }
> }
Splitting it like this would also create independently usable artifacts
(trafficserver_storage parser, udev::access_rule) that allow people to
build their own stuff on top without having to workaround built-in
assumptions. (trafficserver::nbd_mirror anyone?)
Regards, David
[¹]
https://github.com/Brainsware/puppet-trafficserver/blob/types/lib/puppet/provider/trafficserver_storage.rb#L102
--
* Always looking for people I can help with awesome projects *
Twitter: @dev_el_ops G+:
https://plus.google.com/+DavidSchmitt
Blog:
http://club.black.co.at/log/
LinkedIn:
http://at.linkedin.com/in/davidschmitt