Skip to content

Commit 3bed0ac

Browse files
committed
Guard against undef $puppet_agent::collection
If `$puppet_agent::collection` was undef, then the regex match would result in an error: $ bundle exec puppet apply -e '$foo = undef if $foo =~ /core/ { }' Error: Evaluation Error: Left match operand must result in a String value. Got an Undef Value.
1 parent cbd43f2 commit 3bed0ac

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

manifests/osfamily/debian.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
ensure => absent,
6767
priority => '90',
6868
}
69-
} elsif $puppet_agent::collection =~ /core/ {
69+
} elsif $puppet_agent::collection and $puppet_agent::collection =~ /core/ {
7070
$source = 'https://apt-puppetcore.puppet.com'
7171
} else {
7272
$source = $puppet_agent::apt_source

manifests/osfamily/redhat.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
} else {
6161
if $puppet_agent::collection == 'PC1' {
6262
$source = "${puppet_agent::yum_source}/${platform_and_version}/${puppet_agent::collection}/${puppet_agent::arch}"
63-
} elsif $puppet_agent::collection =~ /core/ {
63+
} elsif $puppet_agent::collection and $puppet_agent::collection =~ /core/ {
6464
$_collection = regsubst($puppet_agent::collection, /core/, '')
6565
$source = "https://yum-puppetcore.puppet.com/${_collection}/${platform_and_version}/${puppet_agent::arch}"
6666
} else {

manifests/osfamily/suse.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
} else {
5151
if $puppet_agent::collection == 'PC1' {
5252
$source = "${puppet_agent::yum_source}/sles/${facts['os']['release']['major']}/${puppet_agent::collection}/${puppet_agent::arch}"
53-
} elsif $puppet_agent::collection =~ /core/ {
53+
} elsif $puppet_agent::collection and $puppet_agent::collection =~ /core/ {
5454
$_collection = regsubst($puppet_agent::collection, /core/, '')
5555
$source = "https://yum-puppetcore.puppet.com/${_collection}/sles/${facts['os']['release']['major']}/${puppet_agent::arch}"
5656
} else {

manifests/osfamily/windows.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
} else {
2424
if $puppet_agent::collection == 'PC1' {
2525
$source = "${puppet_agent::windows_source}/windows/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-${puppet_agent::arch}.msi"
26-
} elsif $puppet_agent::collection =~ /core/ {
26+
} elsif $puppet_agent::collection and $puppet_agent::collection =~ /core/ {
2727
$source = 'https://artifacts-puppetcore.puppet.com/v1/download'
2828
} else {
2929
$source = "${puppet_agent::windows_source}/windows/${puppet_agent::collection}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-${puppet_agent::arch}.msi"

manifests/prepare/package.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
$mode = '0644'
3939
}
4040

41-
if $puppet_agent::collection =~ /core/ and $facts['os']['family'] =~ /windows/ {
41+
if $puppet_agent::collection and $puppet_agent::collection =~ /core/ and $facts['os']['family'] =~ /windows/ {
4242
$download_username = getvar('puppet_agent::username', 'forge-key')
4343
$download_password = unwrap(getvar('puppet_agent::password'))
4444

0 commit comments

Comments
 (0)