使用puppet初始化Couchbase

时间:2013-12-16 09:37:55

标签: vagrant puppet couchbase

我设置了一个运行Couchbase DB的流浪盒。在创建框时,我想用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

然而,当我通过傀儡运行相同的命令时,傀儡抱怨非零返回值。

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运行该命令。

2 个答案:

答案 0 :(得分:0)

我相信puppet apply -e采用木偶表达式,而不是任意的shell表达式。你可能想要这样的东西:

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

答案 1 :(得分:0)