Puppet 不尊重依赖顺序?
我创建了两个Puppet模块,它们编译并安装Puppet 不尊重依赖顺序?,puppet,Puppet,我创建了两个Puppet模块,它们编译并安装x264,这取决于编译器yasm 模块如下所示: class yasm { $install_dir = "/usr/local/yasm" include yasm::download, yasm::compile, yasm::install } class x264 { require yasm $install_dir = "/usr/local/x264" include x264::downl
x264
,这取决于编译器yasm
模块如下所示:
class yasm {
$install_dir = "/usr/local/yasm"
include yasm::download, yasm::compile, yasm::install
}
class x264 {
require yasm
$install_dir = "/usr/local/x264"
include x264::download, x264::compile, x264::install
}
因此,当我在节点中声明对x264
的依赖关系时,我希望yasm
将在x264
发生任何事情之前下载、编译和安装
然而,事实并非如此:
[default] Running provisioner: puppet...
Running Puppet with vagrant-precise64.pp...
stdin: is not a tty
warning: Could not retrieve fact fqdn
warning: Host is missing hostname and/or domain: precise64
info: Applying configuration version '1385018183'
notice: /Stage[main]/X264::Download/File[x264-dir]/ensure: created
notice: /Stage[main]/X264::Download/Exec[x264-clone]/returns: executed successfully
notice: /Stage[main]/X264::Compile/Exec[x264-compile]/returns: Makefile:3: config.mak: No such file or directory
notice: /Stage[main]/X264::Compile/Exec[x264-compile]/returns: cat: config.h: No such file or directory
notice: /Stage[main]/X264::Compile/Exec[x264-compile]/returns: ./configure
notice: /Stage[main]/X264::Compile/Exec[x264-compile]/returns: Found no assembler
notice: /Stage[main]/X264::Compile/Exec[x264-compile]/returns: Minimum version is yasm-1.2.0
notice: /Stage[main]/X264::Compile/Exec[x264-compile]/returns: If you really want to compile without asm, configure with --disable-asm.
notice: /Stage[main]/X264::Compile/Exec[x264-compile]/returns: make: *** [config.mak] Error 1
err: /Stage[main]/X264::Compile/Exec[x264-compile]/returns: change from notrun to 0 failed: make returned 2 instead of one of [0] at /tmp/vagrant-puppet/modules-0/x264/manifests/compile.pp:21
notice: /Stage[main]/X264::Install/Exec[x264-install]: Dependency Exec[x264-compile] has failures: true
warning: /Stage[main]/X264::Install/Exec[x264-install]: Skipping because of failed dependencies
notice: /Stage[main]/Yasm::Download/File[yasm-dir]/ensure: created
notice: /Stage[main]/Yasm::Download/Exec[yasm-download]/returns: executed successfully
notice: /Stage[main]/Yasm::Download/Exec[yasm-extract]/returns: executed successfully
notice: /Stage[main]/Yasm::Compile/Exec[yasm-configure]/returns: executed successfully
notice: /Stage[main]/Yasm::Compile/Exec[yasm-compile]/returns: executed successfully
notice: /Stage[main]/Yasm::Install/Exec[yasm-install]/returns: executed successfully
notice: Finished catalog run in 22.66 seconds
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
puppet apply --verbose --modulepath '/etc/puppet/modules:/tmp/vagrant-puppet/modules-0' --color=false --manifestdir /tmp/vagrant-puppet/manifests --detailed-exitcodes /tmp/vagrant-puppet/manifests/vagrant-precise64.pp || [ $? -eq 2 ]
无论出于何种原因,我的Puppet apply都会在安装yasm之前尝试安装x264,yasm是x264的依赖项。我做错了什么?我如何表示x264完全依赖于yasm?
x264
直接依赖于yasm
,但yasm
不依赖任何东西
yasm
中的include
s仅将其添加到目录中,但不为其提供任何依赖结构
一种方法是:
class yasm {
$install_dir = "/usr/local/yasm"
require yasm::download, yasm::compile, yasm::install
}
class x264 {
require yasm
$install_dir = "/usr/local/x264"
Class['yasm'] -> class{ 'x264::download': }
Class['yasm'] -> class{ 'x264::compile': }
Class['yasm'] -> class{ 'x264::install': }
}
嗯,即使这样似乎对我也不起作用。我必须在
x264::compile
中要求yasm
。为什么依赖类中的需求不仅仅意味着模块顶层的需求?哎呀,我之前的错误建议是为x264
设置依赖项,而不是为它包含的类设置依赖项,它们本身也没有依赖项。因此,将require
直接放在需要它的类中(即x264::compile
)实际上是可行的。我更改了我的示例,包括为x264::
类添加依赖项。希望这能奏效!