Search code examples
amazon-ec2chef-infraknife

How to set up a Chef Node on an ec2 instance?


I am trying to use knife bootstrap command from mac terminal "knife bootstrap node_domain_or_IP -x username -P password -N name_for_node --sudo"

But the problem is, I don't have user name and password, instead the ec2-user has this private key stored in my local work station which helps me to connect to the server. I find lot of examples for debian os, but hard to find for RHEL on ec2.

OS: RHEL 6 Chef: 11.1.6

Kindly let me know if any details you need to help me better.


Solution

  • Even with host keys you will have a username. Typically, if you are using

    ssh -i somekey user@host_or_ip

    to ssh to your node, then you would use

    knife bootstrap node_domain_or_IP -x username -i sameKey -N chef_name_you_want --sudo

    Notice, I use -i rather than -P. That's all there is to it.

    An even better option for most people is to use knife ec2 server create to create your node in the first place. This will create the node in AWS and bootstrap it, all in one command.