Skip to content

Instantly share code, notes, and snippets.

@mk2
Last active October 4, 2015 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mk2/a12c74385f68df2d9872 to your computer and use it in GitHub Desktop.
Save mk2/a12c74385f68df2d9872 to your computer and use it in GitHub Desktop.
[和訳] Updating 3.x Manifests for Puppet 4.x ref: http://qiita.com/mk2/items/830fba9871f12ff59492
if str2bool("$is_virtual") { ... }
$port_a = 80 # 数としてパース・保持され、もし数値でなかった場合はエラーになる
$port_b = '80' # 文字としてパース・保持される
class empty_string_defaults (
$parameter_to_check = ''
) {
if $parameter_to_check {
$parameter_to_check_real = $parameter_to_check
} else {
$parameter_to_check_real = 'default value'
}
}
if true { } # 無意味です
$a = 10
if true { } # non productive
$a = 10
$a [3] # 最初は変数aの値になり、次は一つの値を含む配列のリテラル表記
$a[3] # 配列aの3番目の値を参照します
$a [3] # first the value of a, then a literal array with the single value 3 in it
$a[3] # index 3 in the array referenced by $a
class outer {
$var = 'dynamic'
include inner
}
>
class inner {
notice(inline_template('<%= @var %>'))
}
>
include outer
class outer {
$var = 'dynamic'
include inner
}
class inner {
notice(inline_template('<%= @var %>'))
}
include outer
node 1name {} # 1nameは有効な10進数ではないので無効です。この名前はquoteする必要が有ります
notice(0xggg) # 0xgggは有効な16進数ではないので無効です。
$a = 1 + 0789 # 0789は有効な8進数ではないので無効です。
$port_a = 80 # Parsed and maintained as a number, errors if NOT a number
$port_b = '80' # Parsed and maintained as a string
node 1name {} # invalid because 1name is not a valid decimal number; you would need to quote this name
notice(0xggg) # invalid because 0xggg is not a valid hexadecimal number
$a = 1 + 0789 # invalid because 0789 is not a valid octal number
$valid = 40 + 50 # 両方とも数値なので有効です。
$valid = 25 + '30' # '30'という文字列は数値へ変換できるので有効です。
$invalid = 40 + 0789 # 0789という値は有効な8進数でないので無効です。
$invalid = 40 + '0789' # '0789'という文字列は数値へ変換できないので無効です。
$valid = 40 + 50 # valid because both values are numeric
$valid = 25 + '30' # valid because '30' can be cast numerically
$invalid = 40 + 0789 # invalid because 0789 isn't a valid octal number
$invalid = 40 + '0789' # invalid because '0789' can't be cast numerically
$securitylevel = 2
case $securitylevel {
/[1-3]/: { notify { 'security low': } }
/[4-7]/: { notify { 'security medium': } }
default: { notify { 'security high': } }
}
$securitylevel = 2
case $securitylevel {
/[1-3]/: { notify { 'security low': } }
/[4-7]/: { notify { 'security medium': } }
default: { notify { 'security high': } }
}
class empty_string_defaults (
$parameter_to_check = ''
) {
if $parameter_to_check {
$parameter_to_check_real = $parameter_to_check
} else {
$parameter_to_check_real = 'default value'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment