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

  • 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
主站蜘蛛池模板: 广元市| 林芝县| 台中市| 阜阳市| 海伦市| 湟中县| 玛沁县| 汕尾市| 无棣县| 西乌珠穆沁旗| 广西| 钟山县| 鲁山县| 曲靖市| 上高县| 藁城市| 内黄县| 鄂温| 江门市| 安康市| 诸暨市| 从化市| 嘉义县| 吉水县| 平舆县| 开平市| 泸水县| 平乡县| 民乐县| 玉山县| 当雄县| 敦煌市| 永年县| 北宁市| 云和县| 濮阳市| 南开区| 股票| 和林格尔县| 南康市| 将乐县|