Unable to set environment on a node during bootstrap


#1

Hello all,

I’m trying to bootstrap a new node, and set its environment so the correct
versions of its cookbooks are run during the bootstrap process. It doesn’t
seem to work - the new node is created with the environment “_default”. Here’s
the bootstrap command I’m using:

knife bootstrap node.domain -N node.domain -x root -P XXXXXX -r
role[datacenter1],role[dev],recipe[baseline] --distro centos5-gems
–environment dev

thanks in advance.

-mg


#2

Forgot to note that I’m using chef server 0.10.2.

-----Original Message-----
From: mgarrett@silverpop.com [mailto:mgarrett@silverpop.com]
Sent: Monday, September 12, 2011 12:04 PM
To: chef@lists.opscode.com
Subject: [chef] Unable to set environment on a node during bootstrap

Hello all,

I’m trying to bootstrap a new node, and set its environment so the
correct
versions of its cookbooks are run during the bootstrap process. It
doesn’t
seem to work - the new node is created with the environment “_default”.
Here’s
the bootstrap command I’m using:

knife bootstrap node.domain -N node.domain -x root -P XXXXXX -r
role[datacenter1],role[dev],recipe[baseline] --distro centos5-gems
–environment dev

thanks in advance.

-mg

CONFIDENTIALITY NOTICE and DISCLAIMER
This message and any attachment are confidential and may be
privileged or otherwise protected from disclosure and solely for
the use of the person(s) or entity to whom it is intended. If you
have received this message in error and are not the intended
recipient, please notify the sender immediately and delete this
message and any attachment from your system. If you are not the
intended recipient, be advised that any use of this message is
prohibited and may be unlawful, and you must not copy this
message or attachment or disclose the contents to any other person.


#3

What version of Chef is installed on your workstation?

–Noah

On Sep 12, 2011, at 12:19 PM, Michael Garrett wrote:

Forgot to note that I’m using chef server 0.10.2.

-----Original Message-----
From: mgarrett@silverpop.com [mailto:mgarrett@silverpop.com]
Sent: Monday, September 12, 2011 12:04 PM
To: chef@lists.opscode.com
Subject: [chef] Unable to set environment on a node during bootstrap

Hello all,

I’m trying to bootstrap a new node, and set its environment so the
correct
versions of its cookbooks are run during the bootstrap process. It
doesn’t
seem to work - the new node is created with the environment “_default”.
Here’s
the bootstrap command I’m using:

knife bootstrap node.domain -N node.domain -x root -P XXXXXX -r
role[datacenter1],role[dev],recipe[baseline] --distro centos5-gems
–environment dev

thanks in advance.

-mg

CONFIDENTIALITY NOTICE and DISCLAIMER
This message and any attachment are confidential and may be
privileged or otherwise protected from disclosure and solely for
the use of the person(s) or entity to whom it is intended. If you
have received this message in error and are not the intended
recipient, please notify the sender immediately and delete this
message and any attachment from your system. If you are not the
intended recipient, be advised that any use of this message is
prohibited and may be unlawful, and you must not copy this
message or attachment or disclose the contents to any other person.


#4

0.10.2 on the workstation also.

-----Original Message-----
From: Noah Kantrowitz [mailto:noah@coderanger.net]
Sent: Monday, September 12, 2011 3:36 PM
To: chef@lists.opscode.com
Subject: [chef] Re: RE: Unable to set environment on a node during
bootstrap

What version of Chef is installed on your workstation?

–Noah

On Sep 12, 2011, at 12:19 PM, Michael Garrett wrote:

Forgot to note that I’m using chef server 0.10.2.

-----Original Message-----
From: mgarrett@silverpop.com [mailto:mgarrett@silverpop.com]
Sent: Monday, September 12, 2011 12:04 PM
To: chef@lists.opscode.com
Subject: [chef] Unable to set environment on a node during bootstrap

Hello all,

I’m trying to bootstrap a new node, and set its environment so the
correct
versions of its cookbooks are run during the bootstrap process. It
doesn’t
seem to work - the new node is created with the environment
"_default".
Here’s
the bootstrap command I’m using:

knife bootstrap node.domain -N node.domain -x root -P XXXXXX -r
role[datacenter1],role[dev],recipe[baseline] --distro centos5-gems
–environment dev

thanks in advance.

-mg

CONFIDENTIALITY NOTICE and DISCLAIMER
This message and any attachment are confidential and may be
privileged or otherwise protected from disclosure and solely for
the use of the person(s) or entity to whom it is intended. If you
have received this message in error and are not the intended
recipient, please notify the sender immediately and delete this
message and any attachment from your system. If you are not the
intended recipient, be advised that any use of this message is
prohibited and may be unlawful, and you must not copy this
message or attachment or disclose the contents to any other person.

CONFIDENTIALITY NOTICE and DISCLAIMER
This message and any attachment are confidential and may be
privileged or otherwise protected from disclosure and solely for
the use of the person(s) or entity to whom it is intended. If you
have received this message in error and are not the intended
recipient, please notify the sender immediately and delete this
message and any attachment from your system. If you are not the
intended recipient, be advised that any use of this message is
prohibited and may be unlawful, and you must not copy this
message or attachment or disclose the contents to any other person.


#5

I ran into the same issue.

I worked around it by including an “environment” statement in the
bootstrapped client.rb file.

The problem with this is that changing the environment then becomes a change
in the file, rather than via knife, though not a problem in my location.

Rgds,

mgh

On Tue, Sep 13, 2011 at 6:03 AM, Michael Garrett mgarrett@silverpop.comwrote:

0.10.2 on the workstation also.

-----Original Message-----
From: Noah Kantrowitz [mailto:noah@coderanger.net]
Sent: Monday, September 12, 2011 3:36 PM
To: chef@lists.opscode.com
Subject: [chef] Re: RE: Unable to set environment on a node during
bootstrap

What version of Chef is installed on your workstation?

–Noah

On Sep 12, 2011, at 12:19 PM, Michael Garrett wrote:

Forgot to note that I’m using chef server 0.10.2.

-----Original Message-----
From: mgarrett@silverpop.com [mailto:mgarrett@silverpop.com]
Sent: Monday, September 12, 2011 12:04 PM
To: chef@lists.opscode.com
Subject: [chef] Unable to set environment on a node during bootstrap

Hello all,

I’m trying to bootstrap a new node, and set its environment so the
correct
versions of its cookbooks are run during the bootstrap process. It
doesn’t
seem to work - the new node is created with the environment
"_default".
Here’s
the bootstrap command I’m using:

knife bootstrap node.domain -N node.domain -x root -P XXXXXX -r
role[datacenter1],role[dev],recipe[baseline] --distro centos5-gems
–environment dev

thanks in advance.

-mg

CONFIDENTIALITY NOTICE and DISCLAIMER
This message and any attachment are confidential and may be
privileged or otherwise protected from disclosure and solely for
the use of the person(s) or entity to whom it is intended. If you
have received this message in error and are not the intended
recipient, please notify the sender immediately and delete this
message and any attachment from your system. If you are not the
intended recipient, be advised that any use of this message is
prohibited and may be unlawful, and you must not copy this
message or attachment or disclose the contents to any other person.

CONFIDENTIALITY NOTICE and DISCLAIMER
This message and any attachment are confidential and may be
privileged or otherwise protected from disclosure and solely for
the use of the person(s) or entity to whom it is intended. If you
have received this message in error and are not the intended
recipient, please notify the sender immediately and delete this
message and any attachment from your system. If you are not the
intended recipient, be advised that any use of this message is
prohibited and may be unlawful, and you must not copy this
message or attachment or disclose the contents to any other person.


#6

Thanks for your reply. Unfortunately that isn’t a workable solution in
my environment. I’m hoping I can get a clean solution to setting the
environment during the bootstrap, but in the meantime I’m working around
it by writing a little shell wrapper for the bootstrap commands, which
bootstraps with an empty runlist, then uses knife to set the run list,
then uses knife exec to set then environment, and finally knife ssh to
run chef-client.

From: mgherman@gmail.com [mailto:mgherman@gmail.com] On Behalf Of
Michael Herman
Sent: Monday, September 12, 2011 5:35 PM
To: chef@lists.opscode.com
Subject: [chef] Re: RE: Re: RE: Unable to set environment on a node
during bootstrap

I ran into the same issue.

I worked around it by including an “environment” statement in the
bootstrapped client.rb file.

The problem with this is that changing the environment then becomes a
change in the file, rather than via knife, though not a problem in my
location.

Rgds,

mgh

On Tue, Sep 13, 2011 at 6:03 AM, Michael Garrett
mgarrett@silverpop.com wrote:

0.10.2 on the workstation also.

-----Original Message-----
From: Noah Kantrowitz [mailto:noah@coderanger.net]
Sent: Monday, September 12, 2011 3:36 PM
To: chef@lists.opscode.com

Subject: [chef] Re: RE: Unable to set environment on a node during
bootstrap

What version of Chef is installed on your workstation?

–Noah

On Sep 12, 2011, at 12:19 PM, Michael Garrett wrote:

Forgot to note that I’m using chef server 0.10.2.

-----Original Message-----
From: mgarrett@silverpop.com [mailto:mgarrett@silverpop.com]
Sent: Monday, September 12, 2011 12:04 PM
To: chef@lists.opscode.com
Subject: [chef] Unable to set environment on a node during bootstrap

Hello all,

I’m trying to bootstrap a new node, and set its environment so the
correct
versions of its cookbooks are run during the bootstrap process. It
doesn’t
seem to work - the new node is created with the environment
"_default".
Here’s
the bootstrap command I’m using:

knife bootstrap node.domain -N node.domain -x root -P XXXXXX -r
role[datacenter1],role[dev],recipe[baseline] --distro centos5-gems
–environment dev

thanks in advance.

-mg

CONFIDENTIALITY NOTICE and DISCLAIMER
This message and any attachment are confidential and may be
privileged or otherwise protected from disclosure and solely for
the use of the person(s) or entity to whom it is intended. If you
have received this message in error and are not the intended
recipient, please notify the sender immediately and delete this
message and any attachment from your system. If you are not the
intended recipient, be advised that any use of this message is
prohibited and may be unlawful, and you must not copy this
message or attachment or disclose the contents to any other person.

CONFIDENTIALITY NOTICE and DISCLAIMER
This message and any attachment are confidential and may be
privileged or otherwise protected from disclosure and solely for
the use of the person(s) or entity to whom it is intended. If you
have received this message in error and are not the intended
recipient, please notify the sender immediately and delete this
message and any attachment from your system. If you are not the
intended recipient, be advised that any use of this message is
prohibited and may be unlawful, and you must not copy this
message or attachment or disclose the contents to any other person.

CONFIDENTIALITY NOTICE and DISCLAIMER
This message and any attachment are confidential and may be
privileged or otherwise protected from disclosure and solely for
the use of the person(s) or entity to whom it is intended. If you
have received this message in error and are not the intended
recipient, please notify the sender immediately and delete this
message and any attachment from your system. If you are not the
intended recipient, be advised that any use of this message is
prohibited and may be unlawful, and you must not copy this
message or attachment or disclose the contents to any other person.


#7

Hi all,

I am calling the apt cookbook to set up apt on my node (just apt::default, nothing fancy).
Later on, I realise that default debian includes nginx0.7, and I really want nginx1.0.6, for which I can add an apt repository.
I naturally think that the apt cookbook is the place for this, so I alter the default recipe and add this:

apt_repository “nginx” do
uri "http://nginx.org/packages/debian/"
distribution "squeeze"
components [“nginx”]
action :add
end

Pretty simple - I recommit, reupload the cookbooks, and expect the next time chef-client runs, for me to have a brand new /etc/apt/sources.list.d/nginx.list
Except… nothing happens -
Am I viewing chef the wrong way? It works if I instantiate a brand new node, but chef seems to believe its got no work to do on an existing node…

I have seen similar behaviour with a configuration file - e.g. nginx.conf - the first time chef writes it out fine, nicely templated. But if I go and change it and rerun chef-client, nothing happens. I would have expected chef to say ‘hey this file doesnt look the way it’s supposed to, i’m going to fix it back’

Thanks, Geoff


#8
  • Geoff Meakin Acid [2011-09-13]:

Pretty simple - I recommit, reupload the cookbooks, and expect the
next time chef-client runs, for me to have a brand new
/etc/apt/sources.list.d/nginx.list Except… nothing happens -

Chef caches cookbooks locally and uses those files. You should see it
downloading files the first time, but not in later runs. I haven’t yet
firgured out when it updates cached files.

HTH,

Nikolay


#9

Here is the stanza I use in my nginx recipe (for Ubuntu)

apt_repository “nginx” do
uri "http://ppa.launchpad.net/nginx/stable/ubuntu"
distribution "lucid"
components [“main”]
keyserver "keyserver.ubuntu.com"
key "C300EE8C"
action :add
notifies :run, “execute[apt-get update]”, :immediately
end

I’ve had issues where the stock nginx 0.7 gets installed before adding the repository. You need to do an “apt-get remove --purge nginx” to uninstall the 0.7, and then re-run the installer once the repository is added.

You can either do this manually, or add it as a script resource before the package resource in your cookbook.

On Sep 13, 2011, at 10:56 AM, Geoff Meakin Acid wrote:

Hi all,

I am calling the apt cookbook to set up apt on my node (just apt::default, nothing fancy).
Later on, I realise that default debian includes nginx0.7, and I really want nginx1.0.6, for which I can add an apt repository.
I naturally think that the apt cookbook is the place for this, so I alter the default recipe and add this:

apt_repository “nginx” do
uri "http://nginx.org/packages/debian/"
distribution "squeeze"
components [“nginx”]
action :add
end

Pretty simple - I recommit, reupload the cookbooks, and expect the next time chef-client runs, for me to have a brand new /etc/apt/sources.list.d/nginx.list
Except… nothing happens -
Am I viewing chef the wrong way? It works if I instantiate a brand new node, but chef seems to believe its got no work to do on an existing node…

I have seen similar behaviour with a configuration file - e.g. nginx.conf - the first time chef writes it out fine, nicely templated. But if I go and change it and rerun chef-client, nothing happens. I would have expected chef to say ‘hey this file doesnt look the way it’s supposed to, i’m going to fix it back’

Thanks, Geoff


#10

It should download new cookbooks when they change. What you may be
seeing (though I thought it was resolved with 0.10.x) is metadata.json
being uploaded.

In your cookbook directory, if you have a metadata.json file, remove
it and try to reupload the cookbook.

Also it would help to mention if you’re running on the platform or a
local chef-server.

On Tue, Sep 13, 2011 at 12:07 PM, Nikolay Sturm
opscode@erisiandiscord.de wrote:

  • Geoff Meakin Acid [2011-09-13]:

Pretty simple - I recommit, reupload the cookbooks, and expect the
next time chef-client runs, for me to have a brand new
/etc/apt/sources.list.d/nginx.list Except… nothing happens -

Chef caches cookbooks locally and uses those files. You should see it
downloading files the first time, but not in later runs. I haven’t yet
firgured out when it updates cached files.

HTH,

Nikolay


#11
  • John E. Vincent (lusis) [2011-09-13]:

It should download new cookbooks when they change. What you may be
seeing (though I thought it was resolved with 0.10.x) is metadata.json
being uploaded.

Yes, you are right, it might have been metadata.json. All updates fine
here, now.

cheers,

Nikolay


“It’s all part of my Can’t-Do approach to life.” Wally


#12

Default action of package is install not upgrade.

http://wiki.opscode.com/display/chef/Resources#Resources-Package

If you look at the recipe you will see it uses the default call of:

package “nginx”

Personally I write my cookbooks to all use a attribute version that defaults to false, there by allowing me to choose my version only when needed.

All boxes build after your repo addition will get the new nginx.

Quick fix update the nginx ookbook to

package "nginx"
action :install
end

On Sep 16, 2011, at 2:49 AM, Nikolay Sturm opscode@erisiandiscord.de wrote:

  • John E. Vincent (lusis) [2011-09-13]:

It should download new cookbooks when they change. What you may be
seeing (though I thought it was resolved with 0.10.x) is metadata.json
being uploaded.

Yes, you are right, it might have been metadata.json. All updates fine
here, now.

cheers,

Nikolay


“It’s all part of my Can’t-Do approach to life.” Wally


#13

Sorry hit send before reviewing … I could blame writing it on my phone at 3:20 am but that would be to easy

package “nginx” do
action :upgrade
end

On Sep 16, 2011, at 3:20 AM, Joshua Miller jassinpain@gmail.com wrote:

Default action of package is install not upgrade.

http://wiki.opscode.com/display/chef/Resources#Resources-Package

If you look at the recipe you will see it uses the default call of:

package “nginx”

Personally I write my cookbooks to all use a attribute version that defaults to false, there by allowing me to choose my version only when needed.

All boxes build after your repo addition will get the new nginx.

Quick fix update the nginx ookbook to

package "nginx"
action :install
end

On Sep 16, 2011, at 2:49 AM, Nikolay Sturm opscode@erisiandiscord.de wrote:

  • John E. Vincent (lusis) [2011-09-13]:

It should download new cookbooks when they change. What you may be
seeing (though I thought it was resolved with 0.10.x) is metadata.json
being uploaded.

Yes, you are right, it might have been metadata.json. All updates fine
here, now.

cheers,

Nikolay


“It’s all part of my Can’t-Do approach to life.” Wally