我正在尝试让 puppet 运行在几个虚拟机上,我的目的是使用 puppet 安装 jdk6 和 tomcat 6,但是我不能使用 yum,因为机器没有连接到互联网,如果这是一个简单的单机解决方案,那么我可以使用手动安装,但我需要自动化这个过程,并且需要用相同的配置来构建和销毁虚拟机。
我最终使用了某人的 jdk 脚本,这是一个非常脏的模块,它包含来自 oracle 的 bin 文件的所有 RPM。我将它们放在模块上的文件夹中,并从 puppet master 复制过来。然后单独运行这些包。问题是 puppet 没有按特定顺序运行它们。所以我必须等到尝试安装包 6-7 次,但最后一个 exec 命令没有执行。
我需要找到更好的方法。本地或网络 yum 存储库不是一个选项,所以我需要以相同的方式使用 RPM,但我无法弄清楚软件包的链接,我尝试使用链接,但什么都没有安装。
任何指导都非常有用,因为我需要为 tomcat 和 servicemix 编写这个
我的包如下(非常粗糙的代码)
# Class: jdk6
#
# This module manages jdk6
#
# Parameters: none
#
# Actions:
#
# Requires: see Modulefile
#
# Sample Usage:
#
class jdk6 {
file {'/tmp/':
ensure => 'directory',
source => 'puppet:///modules/jdk6/',
recurse => 'remote',
owner => 'root',
group => 'root',
mode => '0755',
}
file { '/etc/profile.d/set_java_home.sh':
ensure => present,
content => 'export JAVA_HOME=/usr/java/jdk1.6.0_37/jre/bin/java'
}
package { "jdk":
provider => rpm,
ensure => installed,
source => "/tmp/jdk-6u37-linux-i586.rpm"
}
package { "java_commons":
provider => rpm,
ensure => installed,
source => "/tmp/sun-javadb-common-10.6.2-1.1.i386.rpm"
}
package { "java_db_core":
provider => rpm,
ensure => installed,
source => "/tmp/sun-javadb-core-10.6.2-1.1.i386.rpm"
}
package { "java_client":
provider => rpm,
ensure => installed,
source => "/tmp/sun-javadb-client-10.6.2-1.1.i386.rpm"
}
package { "java_demo":
provider => rpm,
ensure => installed,
source => "/tmp/sun-javadb-demo-10.6.2-1.1.i386.rpm"
}
package { "java_db_demo":
provider => rpm,
ensure => installed,
source => "/tmp/sun-javadb-demo-10.6.2-1.1.i386.rpm"
}
package { "java_dbdocs":
provider => rpm,
ensure => installed,
source => "/tmp/sun-javadb-docs-10.6.2-1.1.i386.rpm"
}
package { "java_docs":
provider => rpm,
ensure => installed,
source => "/tmp/sun-javadb-javadoc-10.6.2-1.1.i386.rpm"
}
exec { "alternatives –config java \
&& alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_37/jre/bin/java 20000 \
&& alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.6.0_37/jre/bin/javaws 20000 \
&& alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_37/bin/javac 20000 \
&& alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_37/bin/jar 20000 \
&& alternatives --set java /usr/java/jdk1.6.0_37/jre/bin/java \
&& alternatives --set javaws /usr/java/jdk1.6.0_37/jre/bin/javaws \
&& alternatives --set javac /usr/java/jdk1.6.0_37/bin/javac \
&& alternatives --set jar /usr/java/jdk1.6.0_37/bin/jar \
&& export JAVA_HOME=/usr/java/jdk1.6.0_37/jre/bin/java":
cwd => "/tmp",
path => ["/usr/bin", "/usr/sbin"]
require
}
# this is commented as it was not installing any packages then,
# Package['java_docs'] -> Package['java_dbdocs'] -> Package['java_db_demo'] -> Package['java_demo'] -> Package['java_client'] -> Package['java_db_core'] -> Package['java_commons'] -> Package['jdk']
}
答案1
当存在相互依赖时,您可以使用“require”。
package {
"mysql-python":
ensure => installed,
provider => pip,
require => Package["libmysqlclient-dev"];
}