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

  • 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
主站蜘蛛池模板: 涟水县| 新丰县| 卫辉市| 玉门市| 新民市| 乌什县| 嘉黎县| 曲水县| 土默特左旗| 马边| 东兴市| 永春县| 运城市| 平南县| 万荣县| 宁陵县| 调兵山市| 弥勒县| 麦盖提县| 蓬莱市| 龙里县| 湘西| 饶河县| 固始县| 阿拉善右旗| 黑水县| 吴堡县| 桦南县| 抚顺市| 新晃| 天祝| 鸡泽县| 娄底市| 汉源县| 桑植县| 百色市| 犍为县| 阳朔县| 阳信县| 项城市| 乌苏市|