ec2 attributes


#1

Hi

I’m configuring an AWS auto scaling group in my infrastructure. Now, I am
writing a script to install and configure chef-client in the ec2 instances
launched automatically.

When I run the chef-client first time, it find my recipes and try to run
them. Some of the recipes uses attributes from ec2 (e.g.
node[‘ec2’][‘instance_id’] ). But this attribute does not exist in the
instance. Some guy s in the irc channel told me to rerun ohai to reload the
attributes. For this, I added the following code in the recipe:

But the problem persists. Is This what I should do?


#2

The node needs a ‘hint’ that it’s in EC2. Namely this:

mkdir -p /etc/chef/ohai/hints
touch /etc/chef/ohai/hints/ec2.json

then run chef-client and ohai will find all ec2 facts.

–Peter

On Thu, Apr 16, 2015 at 7:09 AM, José Guilherme Vanz <
guilherme.sft@gmail.com> wrote:

Hi

I’m configuring an AWS auto scaling group in my infrastructure. Now, I am
writing a script to install and configure chef-client in the ec2 instances
launched automatically.

When I run the chef-client first time, it find my recipes and try to run
them. Some of the recipes uses attributes from ec2 (e.g.
node[‘ec2’][‘instance_id’] ). But this attribute does not exist in the
instance. Some guy s in the irc channel told me to rerun ohai to reload the
attributes. For this, I added the following code in the recipe:

https://gist.github.com/jvanz/d8b73de8a0d4457e11e7

But the problem persists. Is This what I should do?

Peter Burkholder — Customer Success Engineer

Unavailability: No travel/PTO in April

301-204-5767 – pburkholder@chef.io – *my: *Linkedin
http://www.linkedin.com/in/pburkholder Twitter
http://www.twitter.com/pburkholder Cal
https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK
endar

CHEF

CHEF.IO http://www.chef.io/

TM

chef.io http://www.chef.io/ Blog http://www.chef.io/blog/ Facebook
https://www.facebook.com/getchefdotcom Twitter
https://twitter.com/chef Youtube https://www.youtube.com/getchef


#3

It’s worth knowing that if you use knife ec2 to create instances then it
makes the hint file for you, which is possibly why you never knew about it.

On Thu, Apr 16, 2015 at 5:27 AM, Peter Burkholder pburkholder@chef.io
wrote:

The node needs a ‘hint’ that it’s in EC2. Namely this:

mkdir -p /etc/chef/ohai/hints
touch /etc/chef/ohai/hints/ec2.json

then run chef-client and ohai will find all ec2 facts.

–Peter

On Thu, Apr 16, 2015 at 7:09 AM, José Guilherme Vanz <
guilherme.sft@gmail.com> wrote:

Hi

I’m configuring an AWS auto scaling group in my infrastructure. Now, I am
writing a script to install and configure chef-client in the ec2 instances
launched automatically.

When I run the chef-client first time, it find my recipes and try to run
them. Some of the recipes uses attributes from ec2 (e.g.
node[‘ec2’][‘instance_id’] ). But this attribute does not exist in the
instance. Some guy s in the irc channel told me to rerun ohai to reload the
attributes. For this, I added the following code in the recipe:

https://gist.github.com/jvanz/d8b73de8a0d4457e11e7

But the problem persists. Is This what I should do?

Peter Burkholder — Customer Success Engineer

Unavailability: No travel/PTO in April

301-204-5767 – pburkholder@chef.io – *my: *Linkedin
http://www.linkedin.com/in/pburkholder Twitter
http://www.twitter.com/pburkholder Cal
https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK
endar

CHEF

CHEF.IO http://www.chef.io/

TM

chef.io http://www.chef.io/ Blog http://www.chef.io/blog/
Facebook https://www.facebook.com/getchefdotcom Twitter
https://twitter.com/chef Youtube https://www.youtube.com/getchef


Yoshi Spendiff
Ops Engineer
Indochino
Mobile: +1 778 952 2025
Email: yoshi.spendiff@indochino.com


#4

I cannot use knife ec2. The instance is started by my auto scaling group.
Anyway, the instructions sent by Peter solved my problem

Thank you

On Thu, Apr 16, 2015 at 12:16 PM Yoshi Spendiff <
yoshi.spendiff@indochino.com> wrote:

It’s worth knowing that if you use knife ec2 to create instances then it
makes the hint file for you, which is possibly why you never knew about it.

On Thu, Apr 16, 2015 at 5:27 AM, Peter Burkholder pburkholder@chef.io
wrote:

The node needs a ‘hint’ that it’s in EC2. Namely this:

mkdir -p /etc/chef/ohai/hints
touch /etc/chef/ohai/hints/ec2.json

then run chef-client and ohai will find all ec2 facts.

–Peter

On Thu, Apr 16, 2015 at 7:09 AM, José Guilherme Vanz <
guilherme.sft@gmail.com> wrote:

Hi

I’m configuring an AWS auto scaling group in my infrastructure. Now, I
am writing a script to install and configure chef-client in the ec2
instances launched automatically.

When I run the chef-client first time, it find my recipes and try to run
them. Some of the recipes uses attributes from ec2 (e.g.
node[‘ec2’][‘instance_id’] ). But this attribute does not exist in the
instance. Some guy s in the irc channel told me to rerun ohai to reload the
attributes. For this, I added the following code in the recipe:

https://gist.github.com/jvanz/d8b73de8a0d4457e11e7

But the problem persists. Is This what I should do?

Peter Burkholder — Customer Success Engineer

Unavailability: No travel/PTO in April

301-204-5767 – pburkholder@chef.io – *my: *Linkedin
http://www.linkedin.com/in/pburkholder Twitter
http://www.twitter.com/pburkholder Cal
https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK
endar

CHEF

CHEF.IO http://www.chef.io/

TM

chef.io http://www.chef.io/ Blog http://www.chef.io/blog/
Facebook https://www.facebook.com/getchefdotcom Twitter
https://twitter.com/chef Youtube https://www.youtube.com/getchef


Yoshi Spendiff
Ops Engineer
Indochino
Mobile: +1 778 952 2025
Email: yoshi.spendiff@indochino.com


#5

If you’re doing it via autoscaling, you probably want to bake some
automated registration into your AMI. At which point, I would suggest
baking the hint file into said AMI as well.


~~ StormeRider ~~

“Every world needs its heroes […] They inspire us to be better than we
are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… http://bit.ly/Ps3uSS

On Thu, Apr 16, 2015 at 12:23 PM, José Guilherme Vanz <
guilherme.sft@gmail.com> wrote:

I cannot use knife ec2. The instance is started by my auto scaling group.
Anyway, the instructions sent by Peter solved my problem

Thank you

On Thu, Apr 16, 2015 at 12:16 PM Yoshi Spendiff <
yoshi.spendiff@indochino.com> wrote:

It’s worth knowing that if you use knife ec2 to create instances then it
makes the hint file for you, which is possibly why you never knew about it.

On Thu, Apr 16, 2015 at 5:27 AM, Peter Burkholder pburkholder@chef.io
wrote:

The node needs a ‘hint’ that it’s in EC2. Namely this:

mkdir -p /etc/chef/ohai/hints
touch /etc/chef/ohai/hints/ec2.json

then run chef-client and ohai will find all ec2 facts.

–Peter

On Thu, Apr 16, 2015 at 7:09 AM, José Guilherme Vanz <
guilherme.sft@gmail.com> wrote:

Hi

I’m configuring an AWS auto scaling group in my infrastructure. Now, I
am writing a script to install and configure chef-client in the ec2
instances launched automatically.

When I run the chef-client first time, it find my recipes and try to
run them. Some of the recipes uses attributes from ec2 (e.g.
node[‘ec2’][‘instance_id’] ). But this attribute does not exist in the
instance. Some guy s in the irc channel told me to rerun ohai to reload the
attributes. For this, I added the following code in the recipe:

https://gist.github.com/jvanz/d8b73de8a0d4457e11e7

But the problem persists. Is This what I should do?

Peter Burkholder — Customer Success Engineer

Unavailability: No travel/PTO in April

301-204-5767 – pburkholder@chef.io – *my: *Linkedin
http://www.linkedin.com/in/pburkholder Twitter
http://www.twitter.com/pburkholder Cal
https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK
endar

CHEF

CHEF.IO http://www.chef.io/

TM

chef.io http://www.chef.io/ Blog http://www.chef.io/blog/
Facebook https://www.facebook.com/getchefdotcom Twitter
https://twitter.com/chef Youtube https://www.youtube.com/getchef


Yoshi Spendiff
Ops Engineer
Indochino
Mobile: +1 778 952 2025
Email: yoshi.spendiff@indochino.com


#6

Yeah, is a good idea.

Thank you

On Thu, Apr 16, 2015 at 4:44 PM Morgan Blackthorne stormerider@gmail.com
wrote:

If you’re doing it via autoscaling, you probably want to bake some
automated registration into your AMI. At which point, I would suggest
baking the hint file into said AMI as well.


~~ StormeRider ~~

“Every world needs its heroes […] They inspire us to be better than we
are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… http://bit.ly/Ps3uSS

On Thu, Apr 16, 2015 at 12:23 PM, José Guilherme Vanz <
guilherme.sft@gmail.com> wrote:

I cannot use knife ec2. The instance is started by my auto scaling group.
Anyway, the instructions sent by Peter solved my problem

Thank you

On Thu, Apr 16, 2015 at 12:16 PM Yoshi Spendiff <
yoshi.spendiff@indochino.com> wrote:

It’s worth knowing that if you use knife ec2 to create instances then it
makes the hint file for you, which is possibly why you never knew about it.

On Thu, Apr 16, 2015 at 5:27 AM, Peter Burkholder pburkholder@chef.io
wrote:

The node needs a ‘hint’ that it’s in EC2. Namely this:

mkdir -p /etc/chef/ohai/hints
touch /etc/chef/ohai/hints/ec2.json

then run chef-client and ohai will find all ec2 facts.

–Peter

On Thu, Apr 16, 2015 at 7:09 AM, José Guilherme Vanz <
guilherme.sft@gmail.com> wrote:

Hi

I’m configuring an AWS auto scaling group in my infrastructure. Now, I
am writing a script to install and configure chef-client in the ec2
instances launched automatically.

When I run the chef-client first time, it find my recipes and try to
run them. Some of the recipes uses attributes from ec2 (e.g.
node[‘ec2’][‘instance_id’] ). But this attribute does not exist in the
instance. Some guy s in the irc channel told me to rerun ohai to reload the
attributes. For this, I added the following code in the recipe:

https://gist.github.com/jvanz/d8b73de8a0d4457e11e7

But the problem persists. Is This what I should do?

Peter Burkholder — Customer Success Engineer

Unavailability: No travel/PTO in April

301-204-5767 – pburkholder@chef.io – *my: *Linkedin
http://www.linkedin.com/in/pburkholder Twitter
http://www.twitter.com/pburkholder Cal
https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK
endar

CHEF

CHEF.IO http://www.chef.io/

TM

chef.io http://www.chef.io/ Blog http://www.chef.io/blog/
Facebook https://www.facebook.com/getchefdotcom Twitter
https://twitter.com/chef Youtube https://www.youtube.com/getchef


Yoshi Spendiff
Ops Engineer
Indochino
Mobile: +1 778 952 2025
Email: yoshi.spendiff@indochino.com