2

我开始在我当前的项目中使用 puppet,但我遇到了一些问题。

我正在使用配方安装 jruby,但我想在安装 jruby 后设置一个环境变量(在本例中为 JRUBY_HOME 并修改 PATH 以包含 JRUBY_HOME/bin)。

这是食谱:

class jruby {
  $jruby_home = "/opt/jruby"


  exec { "download_jruby":
    command => "wget http://jruby.org.s3.amazonaws.com/downloads/1.7.0.RC2/jruby-bin-1.7.0.RC2.tar.gz",
    path => $path,    
    timeout => 0,
    unless => "ls /opt | grep jruby-1.7.0",
    require => Package["openjdk-7-jre-headless"]
  }                

  exec { "unpack_jruby" :
    command => "tar -zxf jruby-bin-1.7.0.RC2.tar.gz -C /opt",
    path => $path,
    creates => "${jruby_home}-1.7.0.RC2",
    require => Exec["download_jruby"]
  }                             

  file { $jruby_home:
    ensure => link,
    target => "${jruby_home}-1.7.0.RC2",
    require => Exec["unpack_jruby"]
  }                          

}  

那么,将 /opt/jruby 添加为 JRUBY_HOME 然后将 JRUBY_HOME/bin 添加到 PATH 的最佳方法是什么?

4

1 回答 1

4

解决了它:

# init.pp
$jruby_sh = "/etc/profile.d/jruby.sh"
file { $jruby_sh:
  ensure => present,
  source => "puppet:///modules/jruby/jruby.sh",
  owner => "root",
  group => "root",
  mode => 644,
  require => File[$jruby_home]
}

# jruby.sh
export JRUBY_HOME=/opt/jruby
export PATH=$PATH:$JRUBY_HOME/bin
于 2012-10-24T13:37:41.763 回答