Adding a new mount for sync'ing types isn't hard, but I think the way stdlib defines the types is a problem, since they end up as lib/types/httpurl.pp instead of lib/types/stdlib/httpurl.pp and the agent-side cache loader expects to find them in the latter, since they're specified as param 'Stdlib::HTTPUrl', :url in puppet code. If stdlib properly namespaced the types, like it does with deferred functions, e.g. lib/puppet/functions/<module>/myfunction.pp, then it wouldn't be hard to sync and load types on the agent. In $codedir/environments/production/module/mymodule/lib/puppet/functions/mymodule/myupcase.rb
Puppet::Functions.create_function(:'mymodule::myupcase') do |
dispatch :from_url do |
param 'Stdlib::HTTPUrl', :url |
end |
|
def from_url(url) |
url |
end |
end
|
In $codedir/environments/production/module/mymodule/manifests/init.pp
class mymodule { |
$d = Deferred("mymodule::myupcase", ["http://puppet.com"]) |
|
notify { example : |
message => $d |
} |
}
|
In $codedir/environments/production/manifests/site.pp
Then using https://github.com/joshcooper/puppet/commit/ff2d146a88adb03a69431e182f04cbdc6ebc87ca and moving httpurl.rb into a stdlib directory, puppet can evaluate a deferred function and load types in the process:
$ bx puppet agent -t --server localhost |
... |
Notice: /File[/Users/josh/.puppetlabs/opt/puppet/cache/lib/types]/ensure: removed |
Info: Retrieving locales |
Info: Retrieving types |
Notice: /File[/Users/josh/.puppetlabs/opt/puppet/cache/lib/types]/ensure: created |
... |
Notice: http://puppet.com |
Notice: /Stage[main]/Mymodule/Notify[example]/message: defined 'message' as 'http://puppet.com'
|
Note there is a problem with plugins and types syncing to the same directory (they get deleted and redownloaded each time). We could sync them to different directories, but the agent's cache loader would need to load from multiple places, or we could create an agent-loader specifically for types. |