Puppet4.5.0(2016/5/17リリース)の、リリースノートで個人的に気になる変更をピックアップしてみました。動作確認とかはしてないので、間違っている部分があればご指摘ください。
この投稿(2016/8/20)時点で、すでに4.6が出ています。
過去バージョンでの変更のフォロー用です。
Puppet 4.5.0
Released May 17, 2016.
New features
New functions, dig, then, and lest
Accessing data in nested structures could be difficult and required conditional logic to test for missing or optional parts of a structure. Three functions have been added to make such tasks easier; ‘dig’, ‘then’ and ‘lest’, which also combine nicely with the existing ‘with’ and ‘assert_type’ functions.
入れ子になったデータへのアクセスしやすくするための、dig,then,lest関数が追加されました。例えば、ハッシュの中にハッシュがあって、その中が配列になっているとかです。
dig
digの紹介はこちら、
例も載っています。
Example: Using dig
$data = {a => { b => [{x => 10, y => 20}, {x => 100, y => 200}]}}
notice $data.dig(a, b, 1, x)
この例の場合、dig関数の結果は、100になるようです。
($dataの、aキーの、bキーの、1番目の要素の、xキーの値)
then
thenの紹介はこちら、
(thenの説明ですが、なぜかタイトルがlestになっています。逆にlestの説明が見当たらない。。。)
例も載っています。
Example: Using dig and then
$data = {a => { b => [{x => 10, y => 20}, {x => 100, y => 200}]}}
notice $data.dig(a, b, 1, x).then |$x| { $x * 2 }
結果は、200になるようです。
(digの結果100($dataの、aキーの、bキーの、1番目の要素の、xキーの値)* 2)
digの結果がundefの場合の例もあります。
Contrast this with:
$data = {a => { b => [{x => 10, y => 20}, {ex => 100, why => 200}]}}
notice $data.dig(a, b, 1, x).then |$x| { $x * 2 }
結果は、undefになるようです。
(digの結果undef($dataの、aキーの、bキーの、1番目の要素の、xキーの値はない)ため、thenの処理は実行されない)
New types: SemVer and SemVerRange
SemVer and SemVerRange have been added to the Puppet Type System. This makes it possible to directly work with version related values in the Puppet language. Given version strings are validated and comparison operators (<, >, <=, =>, ==, !=, =~, !~), as well as the in-operator and case expression option matching works with these objects.
x.y.zのようなバージョンを比較するために便利そうな関数が追加されました。
SemVerRangeがバージョンの範囲定義、SevVerがあるバージョンが、SemVerRangeで定義したバージョンに含まれるか判定するもののようです。
例も載っています。
Examples: SemVer and SemVerRange usage
# As a type, SemVer can describe disjunct ranges which versions can be
# matched against - here the type is constructed with two
# SemVerRange objects.
#
$t = SemVer[
SemVerRange('>=1.0.0 <2.0.0'),
SemVerRange('>=3.0.0 <4.0.0')
]
notice(SemVer('1.2.3') =~ $t) # true
notice(SemVer('2.3.4') =~ $t) # false
notice(SemVer('3.4.5') =~ $t) # true
※システム内に複数バージョンが混在しているような場合や、汎用的なマニフェストを書く場合に便利そうです。
Enhancements
Path change of hiera.yaml
The default location of hiera.yaml has changed to the $confdir. Puppet now looks for hiera.yaml in $codedir first, then $confdir.
hiera.yamlのパスが変わったようです。$codedirで指定されたディレクトリにあるhiera.yamlを先に確認するようになりました。
Puppet 4.5.1
Released June 1, 2016.
バグ修正
Puppet 4.5.2
Released June 14, 2016.
バグ修正
Puppet 4.5.3
Released July 20, 2016.
バグ修正
参考
Puppet 4.5 Release Notes
https://docs.puppet.com/puppet/4.5/reference/release_notes.html