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

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
主站蜘蛛池模板: 偃师市| 阿克苏市| 三亚市| 穆棱市| 安阳县| 孝昌县| 神农架林区| 黄大仙区| 尚义县| 莎车县| 达拉特旗| 江都市| 大姚县| 黄石市| 华安县| 朝阳县| 嘉义市| 双牌县| 乌拉特中旗| 吴忠市| 平南县| 孟津县| 旬阳县| 漳平市| 永仁县| 丹阳市| 惠水县| 满洲里市| 扶沟县| 西藏| 文安县| 寿宁县| 通江县| 成武县| 南漳县| 揭西县| 镇赉县| 冀州市| 镇巴县| 堆龙德庆县| 麟游县|