这是我们的一个 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 及其依赖项都已安装