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

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

Adding the namevar special attribute

After we make use of the special attribute of the type, that is its namevar, we can then actually use a declaration of our resource using the Puppet DSL. The namevar should identify the resource uniquely within the underlying operating system, and must be something that can be prespecified, as shown in the following code:

Puppet::Type.newtype(:mynewtype) do

mynewparam(:name, :namevar => true) do
end

end

Now, we can declare our resource in the Puppet DSL. In this case, the namevar defaults to the resource title, as shown in the following code:

mynewtype { ‘foo': }

The resource title is used to make a reference to the resource uniquely inside the Puppet catalog. Hence, the namevar indicates the underlying system's name for that resource, as shown in the following code:

mynewtype { 'foo':
name => 'bar',
}

Then, run the following command:

$ puppet apply -e "mynewtype { 'foo': }"
notice: Finished catalog run in 0.09 seconds
主站蜘蛛池模板: 南昌县| 伊宁市| 天津市| 新巴尔虎左旗| 长汀县| 晋江市| 佛学| 齐河县| 隆化县| 新田县| 佛冈县| 新平| 梁山县| 布拖县| 凤山市| 吉木萨尔县| 景洪市| 龙泉市| 罗定市| 社旗县| 闵行区| 富阳市| 比如县| 敦化市| 平舆县| 内乡县| 德钦县| 恭城| 南汇区| 铜梁县| 福清市| 上杭县| 清水河县| 连城县| 榆中县| 桦甸市| 南靖县| 会同县| 上思县| 巨野县| 民勤县|