使用木偶来确保stream浪箱被升级

我使用木偶来提供一个stream浪盒子(在这种情况下是Ubuntu)。 在最初启动vagrant box( vagrant up )之后,运行apt-get upgrade将列出几个更新。 我想在第一次启动时运行这些升级,但是在运行apt-get升级时却遇到了麻烦:

 # run apt-get update exec { "apt-update": command => "/usr/bin/apt-get update" } # run apt-get upgrade exec { "apt-upgrade": command => "apt-get upgrade -y", path => "/usr/bin:/usr/sbin:/bin:/usr/local/bin", require => Exec['apt-update'], } 

以下内容失败:

 err: /Stage[main]//Exec[apt-upgrade]/returns: change from notrun to 0 failed: apt-get upgrade -y returned 100 instead of one of [0] at /tmp/vagrant-puppet-1/manifests/site.pp:34 

**另外的研究:**一个谷歌小组postbuild议以下没有帮助:

 Exec { path => [ "/usr/bin", "/usr/sbin", "/bin", "/usr/local/bin" ] } 

我也尝试过添加一个对apt-get -f install -y的调用。 都没有工作。

谢谢!

所以path设置原来是在正确的轨道上,这篇文章帮助我追踪如何解决这个问题的最后一点: https : //ask.puppetlabs.com/question/1563/why-does-exec-fail-上执行时,直接可-成功/

本质上, dkpg正在dkpg

 notice: /Stage[main]//Exec[apt-upgrade]/returns: dpkg: warning: 'ldconfig' not found in PATH or not executable. notice: /Stage[main]//Exec[apt-upgrade]/returns: dpkg: warning: 'start-stop-daemon' not found in PATH or not executable. notice: /Stage[main]//Exec[apt-upgrade]/returns: dpkg: error: 2 expected programs not found in PATH or not executable. notice: /Stage[main]//Exec[apt-upgrade]/returns: Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin. notice: /Stage[main]//Exec[apt-upgrade]/returns: E: Sub-process /usr/bin/dpkg returned an error code (2) 

当我将/sbin添加到升级path时,它工作。

 exec { 'apt-upgrade': command => "/usr/bin/apt-get --quiet --yes --fix-broken upgrade", logoutput => "on_failure", path => "/usr/bin:/usr/sbin:/bin:/usr/local/bin:/usr/local/sbin:/sbin", require => Exec['apt-update'], } 

把你最初的apt-get更新请求改成这样:

 exec { 'apt-get': command => "/usr/bin/apt-get update", onlyif => "/bin/sh -c '[ ! -f /var/cache/apt/pkgcache.bin ] || /usr/bin/find /etc/apt/* -cnewer /var/cache/apt/pkgcache.bin | /bin/grep . > /dev/null'", } 

那你可以这样做:

 # run apt-get upgrade exec { 'apt-upgrade': command => "/usr/bin/apt-get upgrade -y", require => Exec['apt-update'], }