使用Puppet安装其他软件包之前,请运行apt-get update. [英] Run `apt-get update` before installing other packages with Puppet
问题描述
我正在尝试创建自动安装zend服务器CE的puppet模块,这在这里并不重要,但是步骤如下
I'm trying to create puppet module which automates installation of zend server CE, this is not important here, but steps are as following
- 更新/etc/apt/source.list
- 通过wget下载存储库密钥
- 执行更新
- 执行apt-get install zend-server-ce-5.2
我有init.pp
个文件
class zendserverce {
# https://github.com/puppetlabs/puppetlabs-stdlib
file_line { 'debian_package':
path => '/etc/apt/sources.list',
line => 'deb http://repos.zend.com/zend-server/deb server non-free'
}
exec { "wget http://repos.zend.com/zend.key -O- |apt-key add -":
path => ["/usr/bin", "/usr/sbin"]
}
exec { "apt-get update":
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'",
}
package { "zend-server-ce-php-5.2":
ensure => "latest"
}
}
似乎木偶以不同于我所需的顺序运行命令.有什么方法可以告诉他按照我想要的顺序跑步吗?
Seems that puppet runs commands in different order then I need. Is there any way how to for tell him to run in my desired order?
该代码段的输出为
[0;36mnotice: /Stage[main]/Mc/Package[mc]/ensure: ensure changed 'purged' to 'latest'[0m
[1;35merr: /Stage[main]/Zendserverce/Package[zend-server-ce-php-5.2]/ensure: change from purged to latest failed: Could not update: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install zend-server-ce-php-5.2' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Couldn't find package zend-server-ce-php-5.2 at /tmp/vagrant-puppet/modules 0/zendserverce/manifests/init.pp:28[0m
[0;36mnotice: /Stage[main]/Zendserverce/Exec[wget http://repos.zend.com/zend.key -O- |apt-key add -]/returns: executed successfully[0m
[0;36mnotice: /Stage[main]/Zendserverce/File_line[debian_package]/ensure: created[0m
[0;36mnotice: Finished catalog run in 6.75 seconds[0m
它说:找不到软件包zend-server-ce-php-5.2
So it says: Couldn't find package zend-server-ce-php-5.2
任何人都可以指导我哪里出问题了吗?
Can anyone guide me what is wrong?
推荐答案
您需要指定依赖关系.最简单/最干净的方法是使用对所有资源类型都可用的require参数.
You need to specify the dependency relationships. The easiest/cleanest approach is to use the require parameter which is available for all resource types.
package { "zend-server-ce-php-5.2":
ensure => latest,
require => Exec['apt-get update'],
}
等.
这篇关于使用Puppet安装其他软件包之前,请运行apt-get update.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!