【问题标题】:Updating dependency package in Ubuntu through puppet?通过 puppet 在 Ubuntu 中更新依赖包?
【发布时间】:2013-12-31 17:54:57
【问题描述】:

我正在像下面的代码一样更新包?

package { '<packageName1>':
         ensure => latest,
}

但它没有安装依赖包。

所以我加入了

exec {'testing': command => "apt-get build-dep packageName1'}

但仍然无法正常工作..如何实现安装依赖包。 还有什么好的方法吗??

刚才我尝试了 apt 类。它也不起作用。

包括适当的

apt::builddep { 'packagename': }

【问题讨论】:

  • 您当然不想为此使用 Exec。我们有机会看到运行清单的输出吗?
  • 没有不显示任何东西

标签: ubuntu puppet


【解决方案1】:

这是我们的一个 puppet 清单中的包部分的示例。这是在 Ubuntu 上使用的。

package { ["mysql-server", "libapache2-mod-auth-mysql", "php5-mysql"] :
        ensure  => present,
    }

apt-get install puppet 设置所有内容,以便“包”资源类型知道如何安装包

示例2 我有一个没有安装 mysql-server 的 vm apt-get -s install mysql-server(模拟模式)给出这个输出

$ apt-get -s install mysql-server
NOTE: This is only a simulation!
      apt-get needs root privileges for real execution.
      Keep also in mind that locking is deactivated,
      so don't depend on the relevance to the real current situation!
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-2.6.32-38 linux-headers-2.6.32-38-server
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libnet-daemon-perl
  libplrpc-perl mysql-client-5.1 mysql-client-core-5.1 mysql-server-5.1
  mysql-server-core-5.1
Suggested packages:
  dbishell libipc-sharedcache-perl tinyca mailx
The following NEW packages will be installed
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libnet-daemon-perl
  libplrpc-perl mysql-client-5.1 mysql-client-core-5.1 mysql-server
  mysql-server-5.1 mysql-server-core-5.1
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Inst libnet-daemon-perl (0.43-1 Ubuntu:10.04/lucid)
Inst libplrpc-perl (0.2020-2 Ubuntu:10.04/lucid)
Inst libdbi-perl (1.609-1build1 Ubuntu:10.04/lucid)
Inst libdbd-mysql-perl (4.012-1ubuntu1 Ubuntu:10.04/lucid)
Inst mysql-client-core-5.1 (5.1.72-0ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Inst mysql-client-5.1 (5.1.72-0ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Inst mysql-server-core-5.1 (5.1.72-0ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Inst mysql-server-5.1 (5.1.72-0ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Inst libhtml-template-perl (2.9-1 Ubuntu:10.04/lucid)
Inst mysql-server (5.1.72-0ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Conf libnet-daemon-perl (0.43-1 Ubuntu:10.04/lucid)
Conf libplrpc-perl (0.2020-2 Ubuntu:10.04/lucid)
Conf libdbi-perl (1.609-1build1 Ubuntu:10.04/lucid)
Conf libdbd-mysql-perl (4.012-1ubuntu1 Ubuntu:10.04/lucid)
Conf mysql-client-core-5.1 (5.1.72-0ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Conf mysql-client-5.1 (5.1.72-0ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Conf mysql-server-core-5.1 (5.1.72-0ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Conf mysql-server-5.1 (5.1.72-0ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Conf libhtml-template-perl (2.9-1 Ubuntu:10.04/lucid)
Conf mysql-server (5.1.72-0ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)

所以我制作了这样的清单文件

$ more p.pp
package { "mysql-server":
ensure => present
}

然后像这样运行它

$ sudo puppet apply p.pp
Warning: Could not retrieve fact fqdn
Notice: Compiled catalog for puppet1 in environment production in 0.12 seconds
Notice: /Stage[main]//Package[mysql-server]/ensure: ensure changed 'purged' to 'present'
Notice: Finished catalog run in 57.49 seconds

完成此操作后,mysql-server 及其依赖项都已安装

【讨论】:

  • 它会添加包,但不会添加依赖包。
  • @Python_Dude 如果你自己用apt-get安装,它会安装依赖包吗?
  • 所有puppet apply 都运行/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install mysql-server 或类似的。您可以使用 apply --verbose --debug 并检查输出来检查确切的命令
猜你喜欢
  • 2013-07-05
  • 1970-01-01
  • 2016-01-06
  • 2018-06-03
  • 2022-01-13
  • 1970-01-01
  • 2013-12-22
  • 1970-01-01
  • 2019-01-11
相关资源
最近更新 更多