Reputation: 5434
We mainly do not use ec2 but we do have a few servers. Normally I will bring up a new blank box and boostrap it using the public ip:
knife boostrap -N my-new-ec2-box -x root 123.456.789.0
I will then run chef-server on the box once it is bootstraped to install the required software. However in the future when I want to run a command on all my boxes using chef knife is unable to connect to the ec2 because it is using the ec2 private address:
knife ssh 'do something' -x www-data -a ipaddress
is there a way to get knife to use the public ip 123.456.789.0 which I originally used?
Upvotes: 0
Views: 333
Reputation: 4223
You can use -a public_ip_address
to get the public address. This attribute is set by the ohai plugin for ec2. In some cases, particularly when your node is in a VPC, you will need to ensure your bootstrap command includes the ec2
hint in order to enable that plugin to run. So you'd do:
knife bootstrap -N my-new-ec2-box --hint ec2 -x root 123.123.123.123
AND
knife ssh 'do something' -x www-data -a public_ip_address
Upvotes: 2