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

  • 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

主站蜘蛛池模板: 长泰县| 宁阳县| 松潘县| 宜良县| 句容市| 石首市| 裕民县| 大丰市| 长顺县| 合水县| 顺平县| 长泰县| 莲花县| 咸宁市| 称多县| 台中市| 西城区| 吉水县| 和平区| 金湖县| 东阳市| 桓台县| 都昌县| 四平市| 富阳市| 大城县| 望都县| 兴业县| 湘阴县| 辰溪县| 宣城市| 九江县| 历史| 云和县| 读书| 星子县| 西青区| 淮阳县| 阿图什市| 临泽县| 苍溪县|