确保已安装/最新,Puppet无法降级

时间:2017-06-28 14:19:15

标签: puppet

我在我的Puppet清单中使用了以下内容:

$packages = [
  '2klic-gateway=2.10.5',
]

package { $packages: ensure => latest }

还尝试使用installed代替latest。但我收回了以下错误:

Error: Could not update: Execution of '/usr/bin/apt-get q -y -o DPkg::Options::=-force-confold install 2klic-gateway=2.10.5' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
The following package was automatically installed and is no longer required:
2klic-updates
Use 'apt-get autoremove' to remove it.
The following packages will be DOWNGRADED:
2klic-gateway
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 5 not upgraded.
Need to get 22.0 MB of archives.
After this operation, 312 kB disk space will be freed.
E: There are problems and -y was used without --force-yes
Error: /Stage[main]/Main/Node[default]/Package[2klic-gateway=2.10.5]/ensure: change from purged to latest failed: Could not update: Execution of '/usr/bin/apt-get q -y -o DPkg::Options::=-force-confold install 2klic-gateway=2.10.5' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
The following package was automatically installed and is no longer required:
2klic-updates
Use 'apt-get autoremove' to remove it.
The following packages will be DOWNGRADED:
2klic-gateway
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 5 not upgraded.
Need to get 22.0 MB of archives.
After this operation, 312 kB disk space will be freed.
E: There are problems and -y was used without --force-yes

如果我手动ssh到节点,我可以使用apt-get install 2klic-gateway=2.10.5,它可以工作。我也可以删除程序然后运行puppet并且清单工作正常。但是只要我添加-y标志,我就会得到:

E: There are problems and -y was used without --force-yes

1 个答案:

答案 0 :(得分:0)

我能够通过告诉Puppet在安装时使用--force-yes来解决这个问题:

package { 
  $packages: ensure => installed,
  install_options   => ['--force-yes'],
}

我将这个问题保持开放,因为这个答案并不安全。

--force-yes
       Force yes; this is a dangerous option that will cause apt to continue
       without prompting if it is doing something potentially harmful. It
       should not be used except in very special situations. Using force-yes
       can potentially destroy your system! Configuration Item:
       APT::Get::force-yes. This is deprecated and replaced by
       --allow-downgrades, --allow-remove-essential,
       --allow-change-held-packages in 1.1.

选项#2

如果您的节点运行的是具有适用于1.1版或更高版本的系统,则可以使用--allow-downgrades代替--force-yes。这是一个更安全的选项,但仍未在手册页中推荐:

 --allow-downgrades
       This is a dangerous option that will cause apt to continue without
       prompting if it is doing downgrades. It should not be used except
       in very special situations. Using it can potentially destroy your
       system! Configuration Item: APT::Get::allow-downgrades. Introduced
       in APT 1.1.

不幸的是,在我的情况下,我的节点正在运行apt版本1,所以这需要首先升级apt版本。