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

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

主站蜘蛛池模板: 嵊州市| 汝南县| 大安市| 乐清市| 聂拉木县| 晋江市| 东莞市| 平武县| 凤山市| 太原市| 内乡县| 三原县| 喀喇沁旗| 靖安县| 焦作市| 靖西县| 中方县| 泗水县| 阿拉善右旗| 成都市| 蒙自县| 宜宾市| 会宁县| 定结县| 苍梧县| 孟州市| 青田县| 卓尼县| 崇阳县| 乡宁县| 布拖县| 开化县| 尼木县| 郑州市| 大宁县| 荆门市| 达拉特旗| 灵璧县| 宁乡县| 楚雄市| 社会|