This commit is contained in:
Udo Waechter
2013-05-28 17:09:58 +02:00
parent 9e6215ba3e
commit 24f4a25732
5 changed files with 31 additions and 36 deletions

View File

@@ -1,28 +1,23 @@
# $Id: env_fact.pp 2479 2009-05-16 12:02:33Z uwaechte $
define puppet::env_fact(
$factname="",
$value,
$ensure="present"
){
define puppet::defines::env_fact ($value, $factname = '', $ensure = 'present') {
$factname_real = $factname ? {
"" => upcase($name),
'' => upcase($name),
default => upcase($factname)
}
if defined(Exec["create-env_fact.sh"]){
debug("already defined.")
}else{
exec{"create-env_fact.sh":
command => "echo \"#/bin/sh\n\" >>/etc/profile.d/env_facts.sh && chmod a+xr /etc/profile.d/env_facts.sh",
onlyif => "test ! -e /etc/profile.d/env_facts.sh",
before => Line["env_fact-${factname_real}"],
path => ["/usr/bin", "/bin" ],
if defined(Exec['create-env_fact.sh']) {
debug('already defined.')
} else {
exec { 'create-env_fact.sh':
command => 'echo \'#/bin/sh\n\' >>/etc/profile.d/env_facts.sh && chmod a+xr /etc/profile.d/env_facts.sh',
onlyif => 'test ! -e /etc/profile.d/env_facts.sh',
before => Line["env_fact-${factname_real}"],
path => ['/usr/bin', '/bin'],
}
}
line{"env_fact-${factname_real}":
line => "export FACTER_${factname_real}=${value}",
file => "/etc/profile.d/env_facts.sh",
common::line { "env_fact-${factname_real}":
line => "export FACTER_${factname_real}=${value}",
file => '/etc/profile.d/env_facts.sh',
ensure => $ensure,
}
}

View File

@@ -1,4 +1,4 @@
define puppet::defines::fact_d ($ensure = 'present', $key = false, $value) {
define puppet::defines::fact_d ($value, $ensure = 'present', $key = false) {
require 'puppet::common'
$k_real = $key ? {
false => $name,
@@ -6,7 +6,7 @@ define puppet::defines::fact_d ($ensure = 'present', $key = false, $value) {
}
file { "${puppet::common::facts_d}/${k_real}.txt":
content => "${k_real}=${value}",
ensure => $ensure,
content => "${k_real}=${value}",
}
}