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

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

主站蜘蛛池模板: 徐闻县| 洞头县| 晋宁县| 宜都市| 逊克县| 大关县| 垫江县| 绥棱县| 小金县| 玉山县| 通化县| 江北区| 横峰县| 三台县| 廊坊市| 哈尔滨市| 花莲市| 桂林市| 正蓝旗| 汤原县| 会泽县| 黄大仙区| 汨罗市| 陕西省| 河西区| 泰宁县| 响水县| 桦甸市| 论坛| 房产| 钦州市| 上蔡县| 垦利县| 阳新县| 鹿邑县| 遂平县| 余江县| 泗洪县| 东至县| 邯郸市| 昭苏县|