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

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

Adding additional type properties

Type properties are attributes that reflect the current state of that resource on the underlying operating system.

During the Puppet run, these values are actively enforced, so they should be both discoverable and updatable. If the attribute can't be updated, it could be implemented as a read-only property. In the following code, we are extending our example type's interface to define a version property:

Puppet::Type.newtype(:mynewtype) do
...
mynewproperty(:version) do
end
...
end

Now we start to use that property in the Puppet DSL, as shown in the following code:

mynewtype{ 'foo':
version => '2.2',
}

But it won't allow the catalog to compile yet, since there's no implementation for that property in any corresponding provider, as shown in the following command:

$ puppet apply -e "mynewtype { 'foo': version => '2.2' }"
err: /Stage[main]// Mynewtype[foo]: Could not evaluate: undefined method 'version' for nil:NilClass
notice: Finished catalog run in 0.04 seconds

主站蜘蛛池模板: 资溪县| 四川省| 翁牛特旗| 金塔县| 太白县| 孝感市| 吉林市| 额济纳旗| 桂平市| 铜陵市| 扶绥县| 潍坊市| 都兰县| 南靖县| 六盘水市| 临猗县| 天长市| 怀远县| 融水| 忻州市| 米泉市| 清徐县| 宜春市| 新津县| 黄梅县| 东阿县| 麻江县| 永靖县| 渝北区| 松溪县| 乌兰察布市| 临湘市| 滕州市| 称多县| 齐河县| 阜南县| 卢龙县| 新竹县| 平安县| 姜堰市| 河西区|