0

I was trying to create and bootstrap an instance on openstack with chef using this command:

sudo knife openstack server create -N jenkins_openstack -f 0eb9c50a-07b9-4fc1-aa33-f6bd66c6bc7b --network-ids 7d5c5d7e-e447-4b22-a5f8-5dbfb53c2128 --openstack-ssh-key-id mmm --openstack-floating-ip -r 'role[jenkins]' --environment production -i /root/.ssh/mmm.pem --ssh-user centos --bootstrap-install-command ' sudo sh -c 'echo 192.168.103.194 chef.server.com >> /etc/hosts''

but this doesn't work and gives this error:

-bash: /etc/hosts: Permission denied

Any ideas?

  • i had to use this command : --bootstrap-install-command ' sudo sh -c 'echo 192.168.103.194 chef.server.com >> /etc/hosts'' cause my instance doesn't see chef – guest Nov 30 '15 at 17:08
1

Single quotes do not nest:

--bootstrap-install-command ' sudo sh -c  'echo 192.168.103.194 chef.server.com   >> /etc/hosts''

The argument to --bootstrap-install-command will be sudo sh -c 'echo, then stray tokens 192.168.103.194 chef.server.com >>/etc/hosts will remain, resulting in a non-sudo attempt to append to file /etc/hosts. This explains the error message you received.

Try this instead:

--bootstrap-install-command 'sudo sh -c "echo 192.168.103.194 chef.server.com >>/etc/hosts"'
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.