Vagrant 用木偶初始化Couchbase

Vagrant 用木偶初始化Couchbase,vagrant,puppet,couchbase,Vagrant,Puppet,Couchbase,我设置了一个流浪者箱来运行我的Couchbase数据库。创建长方体时,我希望使用puppet初始化我的Couchbase。当我运行以下命令(初始化Couchbase集群)时,它可以工作 vagrant@precise64:~$ /opt/couchbase/bin/couchbase-cli cluster-init --cluster=localhost --cluster-init-username=Administrator --cluster-init-password=foobar

我设置了一个流浪者箱来运行我的Couchbase数据库。创建长方体时,我希望使用puppet初始化我的Couchbase。当我运行以下命令(初始化Couchbase集群)时,它可以工作

vagrant@precise64:~$ /opt/couchbase/bin/couchbase-cli  cluster-init --cluster=localhost --cluster-init-username=Administrator --cluster-init-password=foobar --cluster-init-ramsize=256 -u Administrator -p foobar -d
INFO: running command: cluster-init 
INFO: servers {'add': {}, 'failover': {}, 'remove': {}}
METHOD: POST
PARAMS:  {'username': 'Administrator', 'password': 'foobar', 'port': 'SAME', 'initStatus': 'done'}
ENCODED_PARAMS: username=Administrator&password=foobar&port=SAME&initStatus=done
REST CMD: POST /settings/web
response.status: 200
METHOD: POST
PARAMS:  {'memoryQuota': '256'}
ENCODED_PARAMS: memoryQuota=256
REST CMD: POST /pools/default
response.status: 200
SUCCESS: init localhost
$ vagrant@precise64:~$ echo $?
0
然而,当我通过puppet运行相同的命令时,puppet抱怨返回值为非零

vagrant@precise64:~$ puppet apply --debug -e 'exec { "couchbase-init-cluster": command => "/opt/couchbase/bin/couchbase-cli  cluster-init --cluster=localhost --cluster-init-username=administrator --cluster-init-password=foobar --cluster-init-ramsize=256 -u administrator -p foobar"}'
warning: Could not retrieve fact fqdn
debug: Creating default schedules
debug: Failed to load library 'selinux' for feature 'selinux'
debug: Failed to load library 'shadow' for feature 'libshadow'
debug: Failed to load library 'ldap' for feature 'ldap'
debug: /File[/home/vagrant/.puppet/var/state/state.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state]
debug: /File[/home/vagrant/.puppet/var/log]: Autorequiring File[/home/vagrant/.puppet/var]
debug: /File[/home/vagrant/.puppet/var/state/last_run_report.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state]
debug: /File[/home/vagrant/.puppet/var/state/graphs]: Autorequiring File[/home/vagrant/.puppet/var/state]
debug: /File[/home/vagrant/.puppet/var/run]: Autorequiring File[/home/vagrant/.puppet/var]
debug: /File[/home/vagrant/.puppet/ssl/private]: Autorequiring File[/home/vagrant/.puppet/ssl]
debug: /File[/home/vagrant/.puppet/ssl]: Autorequiring File[/home/vagrant/.puppet]
debug: /File[/home/vagrant/.puppet/var/facts]: Autorequiring File[/home/vagrant/.puppet/var]
debug: /File[/home/vagrant/.puppet/var/clientbucket]: Autorequiring File[/home/vagrant/.puppet/var]
debug: /File[/home/vagrant/.puppet/ssl/certificate_requests]: Autorequiring File[/home/vagrant/.puppet/ssl]
debug: /File[/home/vagrant/.puppet/var/state/last_run_summary.yaml]: Autorequiring File[/home/vagrant/.puppet/var/state]
debug: /File[/home/vagrant/.puppet/var/state]: Autorequiring File[/home/vagrant/.puppet/var]
debug: /File[/home/vagrant/.puppet/var/client_data]: Autorequiring File[/home/vagrant/.puppet/var]
debug: /File[/home/vagrant/.puppet/ssl/public_keys]: Autorequiring File[/home/vagrant/.puppet/ssl]
debug: /File[/home/vagrant/.puppet/var/lib]: Autorequiring File[/home/vagrant/.puppet/var]
debug: /File[/home/vagrant/.puppet/ssl/certs]: Autorequiring File[/home/vagrant/.puppet/ssl]
debug: /File[/home/vagrant/.puppet/var]: Autorequiring File[/home/vagrant/.puppet]
debug: /File[/home/vagrant/.puppet/var/client_yaml]: Autorequiring File[/home/vagrant/.puppet/var]
debug: /File[/home/vagrant/.puppet/ssl/private_keys]: Autorequiring File[/home/vagrant/.puppet/ssl]
debug: Finishing transaction 70097870601760
debug: Loaded state in 0.00 seconds
debug: Loaded state in 0.00 seconds
info: Applying configuration version '1387188181'
debug: /Schedule[daily]: Skipping device resources because running on a host
debug: /Schedule[monthly]: Skipping device resources because running on a host
debug: /Schedule[hourly]: Skipping device resources because running on a host
debug: Exec[couchbase-init-cluster](provider=posix): Executing '/opt/couchbase/bin/couchbase-cli  cluster-init --cluster=localhost --cluster-init-username=administrator --cluster-init-password=foobar --cluster-init-ramsize=256 -u administrator -p foobar'
debug: Executing '/opt/couchbase/bin/couchbase-cli  cluster-init --cluster=localhost --cluster-init-username=administrator --cluster-init-password=foobar --cluster-init-ramsize=256 -u administrator -p foobar'
err: /Stage[main]//Exec[couchbase-init-cluster]/returns: change from notrun to 0 failed: /opt/couchbase/bin/couchbase-cli  cluster-init --cluster=localhost --cluster-init-username=administrator --cluster-init-password=foobar --cluster-init-ramsize=256 -u administrator -p foobar returned 2 instead of one of [0] at line 1
debug: /Schedule[never]: Skipping device resources because running on a host
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 70097871491620
debug: Storing state
debug: Stored state in 0.01 seconds
notice: Finished catalog run in 0.63 seconds
debug: Finishing transaction 70097871014480
debug: Received report to process from precise64
debug: Processing report from precise64 with processor Puppet::Reports::Store

请告诉我如何使用puppet运行该命令。

我相信
puppet apply-e
采用的是一个puppet表达式,而不是任意的shell表达式。您可能需要以下内容:

puppet apply -e 'exec { "couchbase-init": \
    command => "/opt/couchbase/bin/couchbase-cli cluster-init <rest of options>"'
puppet apply-e'exec{“couchbase init”:\
command=>“/opt/couchbase/bin/couchbase cli cluster init”

我邀请你看看这篇博文:

能否将
-d
添加到
couchbase cli
;以及
-debug
添加到
puppet apply
-这可能会说明失败的原因。Dave我已经更新了问题。它现在包括带有调试标志的命令输出。您可以使用exec打印,这对于调试非常有用。但这是w我知道。或者至少我看不出你建议的代码段和我的代码段之间的区别。谢谢。实际上我已经从那篇博文开始了。但是如果我没有遗漏什么,它不会描述如何配置Couchbase本身。它只是解释了如何安装Couchbase。你想要哪种类型的配置?