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

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
主站蜘蛛池模板: 夏津县| 巴楚县| 鄂尔多斯市| 兴文县| 濉溪县| 东丽区| 荆门市| 中山市| 棋牌| 灵宝市| 禹州市| 新丰县| 大英县| 巩义市| 当涂县| 浮山县| 重庆市| 武强县| 图们市| 嘉善县| 克山县| 通河县| 鄂尔多斯市| 荥阳市| 怀远县| 阿拉善左旗| 建湖县| 奉贤区| 凉城县| 济南市| 九台市| 栖霞市| 都兰县| 日照市| 房产| 南部县| 民丰县| 寻乌县| 洛南县| 义乌市| 桂阳县|