我们有一个使用 Puppet 配置的生产环境,并且希望能够在我们的开发机器上设置类似的环境:Red Hat、Ubuntu 和 OSX 的混合。正如可以预料的那样,OSX 是这里的异类,不幸的是,我在让它工作时遇到了很多麻烦。
我的第一次尝试是使用macports
,使用以下声明:
package { 'rabbitmq-server':
ensure => installed,
provider => macports,
}
但不幸的是,这会产生以下错误:
Error: /Stage[main]/Rabbitmq/Package[rabbitmq-server]: Could not evaluate: Execution of '/opt/local/bin/port -q installed rabbitmq-server' returned 1: usage: cut -b list [-n] [file ...]
cut -c list [file ...]
cut -f list [-s] [-d delim] [file ...]
while executing
"exec dscl -q . -read /Users/$env(SUDO_USER) NFSHomeDirectory | cut -d ' ' -f 2"
(procedure "mportinit" line 95)
invoked from within
"mportinit ui_options global_options global_variations"
接下来,我想我会homebrew
尝试一下。默认情况下没有可用的包提供程序,但是puppet-homebrew看起来很有希望。在这里,我取得了很大进展,实际上成功让安装正常运行。
package { 'rabbitmq':
ensure => installed,
provider => brew,
}
file { "plist":
path => "/Library/LaunchDaemons/homebrew.mxcl.rabbitmq.plist",
source => "/usr/local/opt/rabbitmq/homebrew.mxcl.rabbitmq.plist",
ensure => present,
owner => root,
group => wheel,
mode => 0644,
}
service { "homebrew.mxcl.rabbitmq":
enable => true,
ensure => running,
provider => "launchd",
require => [ File["/Library/LaunchDaemons/homebrew.mxcl.rabbitmq.plist"] ],
}
这里,我没有收到任何错误。但 RabbitMQ 也没有启动(如果我使用 手动加载,它就会启动launchctl
)
[... snip ...]
Debug: Executing '/bin/launchctl list'
Debug: Executing '/usr/bin/plutil -convert xml1 -o /dev/stdout
/Library/LaunchDaemons/homebrew.mxcl.rabbitmq.plist'
Debug: Executing '/usr/bin/plutil -convert xml1 -o /dev/stdout
/var/db/launchd.db/com.apple.launchd/overrides.plist'
Debug: /Schedule[weekly]: Skipping device resources because running on a host
Debug: /Schedule[puppet]: Skipping device resources because running on a host
Debug: Finishing transaction 2248294820
Debug: Storing state
Debug: Stored state in 0.01 seconds
Finished catalog run in 25.90 seconds
我究竟做错了什么?
编辑:据记录,我们现在在 OSX 机器上使用 Vagrant VM 来执行此操作,但仍然优先选择本机解决方案。
答案1
不确定这是否仍然是一个问题,但看起来这是 launchd 提供程序的一个错误,已在 3.1.0 中修复。错误:https://projects.puppetlabs.com/issues/16271
答案2
一种蛮力方法:
class rabbitmqosx {
exec { "rabbitmqosx":
command => "/path/to/rabbitmq",
unless => [
"/bin/ps |grep -c rabbitmq"
]
}
node fancymac { include "rabbitmqosx }