Puppet 和launchd 服务?

Joe*_*erg 15 mac-osx puppet

我们有一个配置了 Puppet 的生产环境,并且希望能够在我们的开发机器上设置一个类似的环境:红帽、Ubuntu 和 OSX 的混合。正如所料,OSX 是这里的怪人,可悲的是,我在让它工作时遇到了很多麻烦。

我的第一次尝试是使用macports,使用以下声明:

package { 'rabbitmq-server':
    ensure   => installed,
    provider => macports,
}
Run Code Online (Sandbox Code Playgroud)

但遗憾的是,这会产生以下错误:

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"
Run Code Online (Sandbox Code Playgroud)

接下来,我想我会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"] ],
}
Run Code Online (Sandbox Code Playgroud)

在这里,我没有收到任何错误。但是 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
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

编辑:为了记录,我们现在使用 Vagrant VM 而不是在我们的 OSX 机器上执行此操作,但本机解决方案仍然是首选。

Ste*_*han 0

一种暴力方法:

class rabbitmqosx {    
    exec { "rabbitmqosx":
           command =>  "/path/to/rabbitmq",
           unless => [ 
                       "/bin/ps |grep -c rabbitmq" 
                     ]
         }

node fancymac { include "rabbitmqosx }
Run Code Online (Sandbox Code Playgroud)