Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Puppet variable case sensitivity test
notice: Scope(Class[main]): puppet version: 0.25.5
notice: Scope(Class[main]): conditional string: sensitive
notice: Scope(Class[main]): conditional regex: sensitive
notice: Scope(Class[main]): selector string: insensitive
notice: Scope(Class[main]): selector regex: sensitive
notice: Scope(Class[main]): case string: insensitive
notice: Scope(Class[main]): case regex: sensitive
notice: Scope(Class[main]): puppet version: 2.6.1
notice: Scope(Class[main]): conditional string: insensitive
notice: Scope(Class[main]): conditional regex: sensitive
notice: Scope(Class[main]): selector string: insensitive
notice: Scope(Class[main]): selector regex: sensitive
notice: Scope(Class[main]): case string: insensitive
notice: Scope(Class[main]): case regex: sensitive
notice: Scope(Class[main]): puppet version: 2.7.13
notice: Scope(Class[main]): conditional string: insensitive
notice: Scope(Class[main]): conditional regex: sensitive
notice: Scope(Class[main]): selector string: insensitive
notice: Scope(Class[main]): selector regex: sensitive
notice: Scope(Class[main]): case string: insensitive
notice: Scope(Class[main]): case regex: sensitive
notice("puppet version: ${::puppetversion}")
$CamelCase = "FooBar"
# Conditionals. 0.25 doesn't support elsif
if $CamelCase == "foobar" {
notice("conditional string: insensitive")
} else {
if $CamelCase == "FooBar" {
notice("conditional string: sensitive")
}
}
if $CamelCase =~ /^foobar$/ {
notice("conditional regex: insensitive")
} else {
if $CamelCase =~ /^FooBar$/ {
notice("conditional regex: sensitive")
}
}
# Selectors
notice($CamelCase ? {
"foobar" => "selector string: insensitive",
"FooBar" => "selector string: sensitive",
})
notice($CamelCase ? {
/^foobar$/ => "selector regex: insensitive",
/^FooBar$/ => "selector regex: sensitive",
})
# Case
case $CamelCase {
"foobar": { notice("case string: insensitive") }
"FooBar": { notice("case string: sensitive") }
}
case $CamelCase {
/^foobar$/: { notice("case regex: insensitive") }
/^FooBar$/: { notice("case regex: sensitive") }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.