2013-12-16 50 views
1

我建立了一個運行我的Couchbase數據庫的流浪盒。創建箱子時,我想用木偶初始化我的Couchbase。當我運行以下命令(它位於Couchbase集羣中)時,它可以工作。用木偶初始化Couchbase

[email protected]:~$ /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 
$ [email protected]:~$ echo $? 
0 

但是,當我通過puppet運行相同的命令,關於一個非零返回值的puppet投訴。

[email protected]:~$ 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 

請任何想法如何,我可以運行傀儡命令。

+0

你可以添加'-d'到the'couchbase-cli';也可以用''傀儡來'傀儡' - 這可能會揭示失敗的原因。 – DaveR

+0

戴夫我已經更新了這個問題。它現在包含帶有調試標誌的命令的輸出。 – nebenmir

+0

您可以讓exec打印[命令輸出](http://docs.puppetlabs.com/references/latest/type.html#exec-attribute-logoutput),這對於調試目的非常有用。 – bartavelle

回答

0

我相信puppet apply -e需要一個puppet表達式,而不是一個任意的shell表達式。您可能希望喜歡的東西:

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

但這就是我所做的。或者至少我不能發現你的建議片段和我的區別。 – nebenmir