- From: Sean OMeara <
>
- To:
- Cc: Rob Guttman <
>, Thom May <
>,
- Subject: [chef] Re: Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup
- Date: Tue, 5 Apr 2011 10:44:40 -0400
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=f8dxmCxUr74rkXnH5eItGxT4RbxTcYxHITJ/AyZjJ+vlOfPakIXV5rtEHu+4+NgKGs e7KnWV3TnFbAG+I247CIf6Mm+jNmOlJXsplNbKmd2Cw4O6hYGWWhtWKIhSfJtq2ZEzjk fVvDYsxc/RqdiHfl34lBkGvu1A+IXdJXZUEBw=
Rob,
The hostname needs to be set before chef-client is invoked, since
there is no way (that I'm aware of) to change a machine's node and
client names after registration
I use a naming pattern like this.
something-1.prod.us-east-1.aws.example.net
You'll end up with a series of knife commands:
knife ec2 server create something-1.prod.us-east-1.aws.example.net
knife ec2 server create something-2.prod.us-east-1.aws.example.net
knife ec2 server create something-3.prod.us-east-1.aws.example.net
knife ec2 server create nothing-1.staging.us-west-1.aws.example.net
knife ec2 server create nothing-2.staging.us-west-1.aws.example.net
knife ec2 server create nothing-3.staging.us-west-1.aws.example.net
The incrementation is handled by the provisioning layer (currently,
knife + manual), but you could easily write a script to do it for you,
assuming the knife commands were being ran from a "control" node that
was already registered in chef-server and had the ability to search()
ymmv
-s
On Tue, Apr 5, 2011 at 10:22 AM, Rob Guttman
<
>
wrote:
>
Thanks for all of the examples so far, everyone. They answer half of my
>
question which is how best to set/change the hostname of an ec2 instance.
>
The other half is how best to set the hostname based on the node's roles. I
>
would like to use a host naming pattern something like this:
>
>
<primary_role>NN-<environment>-<availability-zone>
>
>
So something like:
>
>
web04-production-useast1a
>
>
So when a new ec2 instance is being launched, the recipe/definition would
>
need to determine how many nodes already exist of this pattern and then
>
increment the (left-padded) number and/or fill in number gaps if prior
>
instances were terminated. That's what I was hoping Dan's recipe would
>
show. Does anyone have something like this already coded up? (I would
>
think this would be a somewhat common need.)
>
>
- Rob
>
>
>
On Tue, Apr 5, 2011 at 8:41 AM, Thom May
>
<
>
>
wrote:
>
>
>
> There's an example of it in the dynect cookbook -
>
> https://github.com/opscode/cookbooks/blob/master/dynect/recipes/ec2.rb
>
>
>
> On Tue, Apr 5, 2011 at 13:04, Rob Guttman
>
> <
>
>
> wrote:
>
> >>
>
> > This is what we do for our EC2 nodes, except we use the instance ID for
>
> > the
>
> > node name and generate the hostnames from the roles.
>
> >
>
> > Dan, where can I find how to do something like this for ec2 nodes? Is
>
> > the
>
> > recipe available somewhere?
>
> >
>
> > Thanks.
>
> > - Rob
>
> >
>
> >
>
> > On Tue, Apr 5, 2011 at 12:58 AM, Daniel DeLeo
>
> > <
>
>
> > wrote:
>
> >>
>
> >> On Monday, April 4, 2011 at 9:53 PM, Chris Streeter wrote:
>
> >>
>
> >> I ran knife with the -N option with the parameter set to 'www'.
>
> >> However,
>
> >> the
>
> >> hostname of the box (set on the box and in the opscode console) is set
>
> >> to
>
> >> an
>
> >> AWS internal IP (ip-10-XXX-XX-XX) while the nodename is set to www. So
>
> >> this
>
> >> doesn't quite do what I want it to do. I want the actual hostname of
>
> >> the
>
> >> box to
>
> >> be www.
>
> >>
>
> >> Otherwise, in a template, how do I get the node's name (for populating
>
> >> /etc/hosts on all machines)?
>
> >>
>
> >> By setting the node name via -N, you should create the node and it's
>
> >> client with the given id, and configure it to use those values instead
>
> >> of
>
> >> the hostname. Then you're free to change the hostname without changing
>
> >> the
>
> >> ID the node uses to identify itself with the server. So you could
>
> >> create a
>
> >> cookbook to configure the hostname according to the node name. This is
>
> >> what
>
> >> we do for our EC2 nodes, except we use the instance ID for the node
>
> >> name and
>
> >> generate the hostnames from the roles. But the basic idea is the same.
>
> >>
>
> >> --
>
> >> Dan DeLeo
>
> >>
>
> >
>
> >
>
>
- [chef] Re: Re: Setting Hostname on EC2 Instance Spinup, Chris Streeter, 04/04/2011
- [chef] Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Daniel DeLeo, 04/04/2011
- [chef] Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Rob Guttman, 04/05/2011
- [chef] Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Thom May, 04/05/2011
- [chef] Re: Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Sean OMeara, 04/05/2011
- [chef] Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Rob Guttman, 04/05/2011
- [chef] Re: Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Sean OMeara, 04/05/2011
- [chef] Re: Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Brian Akins, 04/05/2011
- [chef] Re: Re: Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Seth Chisamore, 04/05/2011
- [chef] Re: Re: Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Bryan McLellan, 04/05/2011
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Sean OMeara, 04/05/2011
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Rob Guttman, 04/05/2011
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Daniel DeLeo, 04/05/2011
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Ryan C. Creasey, 04/05/2011
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Setting Hostname on EC2 Instance Spinup, Rob Guttman, 04/06/2011
Archive powered by MHonArc 2.6.16.