Last active
October 4, 2015 10:53
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if str2bool("$is_virtual") { ... } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$port_a = 80 # 数としてパース・保持され、もし数値でなかった場合はエラーになる | |
$port_b = '80' # 文字としてパース・保持される |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if true { } # 無意味です | |
$a = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if true { } # non productive | |
$a = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$a [3] # 最初は変数aの値になり、次は一つの値を含む配列のリテラル表記 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$a[3] # 配列aの3番目の値を参照します |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$a [3] # first the value of a, then a literal array with the single value 3 in it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$a[3] # index 3 in the array referenced by $a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class outer { | |
$var = 'dynamic' | |
include inner | |
} | |
> | |
class inner { | |
notice(inline_template('<%= @var %>')) | |
} | |
> | |
include outer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class outer { | |
$var = 'dynamic' | |
include inner | |
} | |
class inner { | |
notice(inline_template('<%= @var %>')) | |
} | |
include outer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node 1name {} # 1nameは有効な10進数ではないので無効です。この名前はquoteする必要が有ります | |
notice(0xggg) # 0xgggは有効な16進数ではないので無効です。 | |
$a = 1 + 0789 # 0789は有効な8進数ではないので無効です。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$port_a = 80 # Parsed and maintained as a number, errors if NOT a number | |
$port_b = '80' # Parsed and maintained as a string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$valid = 40 + 50 # 両方とも数値なので有効です。 | |
$valid = 25 + '30' # '30'という文字列は数値へ変換できるので有効です。 | |
$invalid = 40 + 0789 # 0789という値は有効な8進数でないので無効です。 | |
$invalid = 40 + '0789' # '0789'という文字列は数値へ変換できないので無効です。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$securitylevel = 2 | |
case $securitylevel { | |
/[1-3]/: { notify { 'security low': } } | |
/[4-7]/: { notify { 'security medium': } } | |
default: { notify { 'security high': } } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$securitylevel = 2 | |
case $securitylevel { | |
/[1-3]/: { notify { 'security low': } } | |
/[4-7]/: { notify { 'security medium': } } | |
default: { notify { 'security high': } } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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