- 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
推薦閱讀
- 常用元器件的識別與檢測
- 高效變換器設(shè)計(jì)與應(yīng)用電路
- 電子工程師自學(xué)速成:入門篇(第2版)
- cdma2000 1x/EV-DO通信網(wǎng)絡(luò)規(guī)劃與設(shè)計(jì)
- IP網(wǎng)絡(luò)可生存性技術(shù)
- 電信行業(yè)節(jié)能減排技術(shù)、方法與案例
- 第三代移動通信
- 數(shù)字電路與系統(tǒng)
- 移動通信中繼覆蓋系統(tǒng)設(shè)備與工程設(shè)計(jì)
- 集成電路靜態(tài)時(shí)序分析與建模
- 手機(jī)故障維修技巧與實(shí)例
- 數(shù)字平板電視機(jī)現(xiàn)場維修實(shí)錄
- 雙色圖文詳解電感器及應(yīng)用電路
- 光波分復(fù)用系統(tǒng)與維護(hù)
- Simulink與信號處理