官术网_书友最值得收藏!

  • Mastering Puppet 5
  • Ryan Russell Yates Jason Southgate
  • 227字
  • 2021-07-16 17:46:14

Custom functions

This is where custom facts allow us to run arbitrary code on the client side. Custom functions are a server-side technology that assist you in the compilation of a catalog. Functions are executed on the Puppet server. Puppet already includes several functions that are built-in, and additional ones are contained in Puppet Forge modules, particularly the stdlib module (see https://forge.puppet.com/puppetlabs/stdlib).

There are, in fact, three possible ways to create custom functions, although you are unlikely to use the first two, so I will just leave you with some links to the Puppet documentation for those options:

The best way to create and distribute a new custom function is to place it in a module, in the puppet/functions/<modulename> subdirectory of the lib directory, and it will then be distributed via pluginsync, as shown in the following code:

#<modulepath>/lib/puppet/functions/mymodule/myfunction.rb
Puppet::Functions.create_function(:'mymodule::myfunction') do
dispatch :up do
param 'String', :a_string
end
def up(a_string)
a_string.upcase
end
end
主站蜘蛛池模板: 江油市| 诏安县| 屏南县| 乌什县| 浠水县| 罗甸县| 三亚市| 定西市| 博客| 北海市| 靖安县| 大英县| 西青区| 兰考县| 察隅县| 玉树县| 黄平县| 鹰潭市| 尼玛县| 长岭县| 彭州市| 正定县| 富裕县| 古丈县| 神池县| 铜梁县| 新巴尔虎左旗| 贵港市| 贵德县| 福清市| 和硕县| 阜康市| 张家界市| 全州县| 武川县| 乌鲁木齐县| 东港市| 韶山市| 巴东县| 天津市| 宣城市|