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

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
主站蜘蛛池模板: 沐川县| 徐闻县| 甘泉县| 调兵山市| 大连市| 阳原县| 永靖县| 晋江市| 泰兴市| 娱乐| 深州市| 弥勒县| 定南县| 嘉义县| 赣州市| 姚安县| 密山市| 南澳县| 枞阳县| 漳平市| 太和县| 河北区| 丽水市| 江口县| 沿河| 青冈县| 泉州市| 德兴市| 呈贡县| 阿拉善右旗| 玉屏| 龙江县| 乐业县| 西畴县| 慈利县| 定边县| 越西县| 噶尔县| 台中市| 濮阳县| 邳州市|