24 lines
748 B
Puppet
24 lines
748 B
Puppet
define puppet::defines::env_fact ($value, $factname = '', $ensure = 'present') {
|
|
$factname_real = $factname ? {
|
|
'' => 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'],
|
|
}
|
|
}
|
|
|
|
common::line { "env_fact-${factname_real}":
|
|
ensure => $ensure,
|
|
line => "export FACTER_${factname_real}=${value}",
|
|
file => '/etc/profile.d/env_facts.sh',
|
|
}
|
|
}
|