Jar*_*aro 50 puppet apt-get zend-server
我正在尝试创建自动安装zend服务器CE的puppet模块,这在这里并不重要,但步骤如下
我有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"
}
}
Run Code Online (Sandbox Code Playgroud)
似乎puppet以不同的顺序运行命令然后我需要.有什么方法告诉他按照我想要的顺序跑吗?
这样的片段的输出是
[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
Run Code Online (Sandbox Code Playgroud)
所以它说:找不到软件包zend-server-ce-php-5.2
谁能指导我出错了什么?
DrD*_*Dol 101
从Puppet 2.6.0开始,引入了一个新功能"关系语法" .
Puppet 2.6.0及更高版本中的示例如下所示:
exec { "apt-update":
command => "/usr/bin/apt-get update"
}
Exec["apt-update"] -> Package <| |>
Run Code Online (Sandbox Code Playgroud)
每次执行包命令时,将依次触发依赖项(在我们的例子中为"apt-update").您甚至可以定义更长的链.
cze*_*vik 50
您需要指定依赖关系.最简单/最干净的方法是使用可用于所有资源类型的require参数.
package { "zend-server-ce-php-5.2":
ensure => latest,
require => Exec['apt-get update'],
}
Run Code Online (Sandbox Code Playgroud)
等等..
小智 13
我尝试过以前的变种,但它在Ubuntu 10.04上对我不起作用
最后,我准备了以下脚本,每次存储库超过一周时都会运行更新:
exec { 'apt-get update':
command => "/usr/bin/apt-get update",
onlyif => "/bin/bash -c 'exit $(( $(( $(date +%s) - $(stat -c %Y /var/lib/apt/lists/$( ls /var/lib/apt/lists/ -tr1|tail -1 )) )) <= 604800 ))'"
}
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你.
joe*_*erx 12
我更喜欢将apt-upgrade放到在主阶段之前运行的单独阶段,因此我不必硬连接任何依赖项.请点击此处:http://docs.puppetlabs.com/puppet/2.7/reference/lang_run_stages.html.
一个简单的例子如下所示.它意味着你有一个单独的类来进行实际的apt-update:
stage { "init": before => Stage["main"] }
class {"apt-update":
stage => init,
apt_mirror => $apt_mirror
}
Run Code Online (Sandbox Code Playgroud)
检查我在github上的样本LAMPP-box,看看它们是如何组合在一起的:https://github.com/joerx/vagrant-lampp
注意:小心使用apt-upgrade,因为一些基本框会破坏内核升级之类的东西.
归档时间: |
|
查看次数: |
68267 次 |
最近记录: |