Skip to content

Commit be43cc2

Browse files
committed
Fix validate command.
1 parent 4dc42d2 commit be43cc2

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

manifests/fact.pp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@
1212

1313
validate_re($title, '^[0-9A-Za-z_\-]+$', 'The $title fact does not match ^[0-9A-Za-z_\-]+$')
1414
$facter_data = { "${title}" => $value }
15+
if ( versioncmp($::puppetversion, '4.0.0') < 0 ) {
16+
$validate_cmd = "/usr/bin/env ruby -ryaml -e \"YAML.load_file '%'\""
17+
} else {
18+
$validate_cmd = "/opt/puppetlabs/puppet/bin/ruby -ryaml -e \"YAML.load_file '%'\""
19+
}
1520

1621
file { "${facterbasepath}/facts.d/${title}.yaml":
1722
ensure => $ensure,
1823
owner => 'root',
1924
group => $::puppet::defaults::puppet_group,
2025
mode => '0640',
21-
validate_cmd => "/usr/bin/env ruby -ryaml -e \"YAML.load_file '%'\"",
26+
validate_cmd => $validate_cmd,
2227
content => template('puppet/fact.yaml.erb'),
2328
}
2429

manifests/facts.pp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@
1414
if $custom_facts {
1515
validate_hash($custom_facts)
1616
}
17+
if ( versioncmp($::puppetversion, '4.0.0') < 0 ) {
18+
$validate_cmd = "/usr/bin/env ruby -ryaml -e \"YAML.load_file '%'\""
19+
} else {
20+
$validate_cmd = "/opt/puppetlabs/puppet/bin/ruby -ryaml -e \"YAML.load_file '%'\""
21+
}
1722

1823
file { "${facterbasepath}/facts.d/local.yaml":
1924
ensure => file,
2025
owner => 'root',
2126
group => $::puppet::defaults::puppet_group,
2227
mode => '0640',
23-
validate_cmd => "/usr/bin/env ruby -ryaml -e \"YAML.load_file '%'\"",
28+
validate_cmd => $validate_cmd,
2429
content => template('puppet/local_facts.yaml.erb'),
2530
}
2631

0 commit comments

Comments
 (0)