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

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
主站蜘蛛池模板: 苍南县| 康平县| 尉犁县| 淳化县| 米易县| 嘉义县| 郸城县| 兴隆县| 成武县| 桐梓县| 军事| 竹溪县| 聂拉木县| 巴南区| 宣城市| 桐梓县| 咸阳市| 库伦旗| 陈巴尔虎旗| 灵寿县| 增城市| 宁明县| 泸溪县| 鄂托克前旗| 新沂市| 密山市| 柞水县| 华宁县| 涪陵区| 蕉岭县| 会昌县| 梨树县| 怀柔区| 江津市| 三门峡市| 仪陇县| 方城县| 高清| 阳江市| 微山县| 历史|