Hosted chef not honoring passed environment?

Using chef 10.16.4.

I have an environment called ‘lucid’ for my current infrastructure:

[master] darron@~/Dropbox/src/chef-repo: knife environment list
_default
lucid

We’re using hosted Chef and this next bit shows all of my cookbook
versions for that environment:

I’m adding a new server using that environment - tried passing
environment along 2 different ways:

bundle exec knife rackspace server create -E lucid -S server2013 -f 4
-N server2013 --image 112 -r
’role[setup],role[mysql_server],role[web_server],recipe[backup]’
–distro ubuntu10.04-ruby193

OR

bundle exec knife rackspace server create -S server2013 -f 4 -N
server2013 --image 112 -r
’role[setup],role[mysql_server],role[web_server],recipe[backup]’
–distro ubuntu10.04-ruby193 --environment lucid

Neither seems to work as I expect.

The server gets created, but at the end of the run, it says:

Name: server2013
Flavor: 2GB server
Image: Ubuntu 10.04 LTS
Metadata: {}
Environment: lucid
Run List: role[setup], role[mysql_server], role[web_server], recipe[backup]

But:

  1. It uses the 2.0.4 sudo cookbook that I uploaded yesterday - which
    is not part of the lucid environment.

  2. In the Opscode management interface it shows up as _default:
    http://d.pr/i/UoZz

Any ideas what I’m missing?

Tried again a few different times this weekend - same failures -
downloading the wrong version of the sudo cookbook and being assigned
to the wrong environment:

bundle exec knife rackspace server create -E lucid -S sudo2013 -f 2 -N
sudo2013 --image 112 -r 'recipe[sudo]' --distro ubuntu10.04-ruby187

http://d.pr/i/rjBp

bundle exec knife bootstrap -E lucid -r "recipe[sudo]" 184.106.71.194
-x root -P not-so-fast --node-name bootstrap2013 --distro
ubuntu10.04-ruby187

http://d.pr/i/DBDx

I also tried AWS:

bundle exec knife ec2 server create -E lucid -r "recipe[sudo]" -I
ami-ab36fbc2 -f m1.small -S dfroese -G varnish -x ubuntu --region
us-east-1 -Z us-east-1a --node-name aws2013 --distro
ubuntu10.04-ruby187

http://d.pr/i/n6Pg

I expect to be able to create new servers and assign them to a
particular environment - is this correct?

Am I misunderstanding something or is something odd going on?

On Thu, Jan 10, 2013 at 2:25 PM, Darron Froese darron@froese.org wrote:

Using chef 10.16.4.

I have an environment called 'lucid' for my current infrastructure:

[master] darron@~/Dropbox/src/chef-repo: knife environment list
_default
lucid

We're using hosted Chef and this next bit shows all of my cookbook
versions for that environment:

gist:4505868 · GitHub

I'm adding a new server using that environment - tried passing
environment along 2 different ways:

bundle exec knife rackspace server create -E lucid -S server2013 -f 4
-N server2013 --image 112 -r
'role[setup],role[mysql_server],role[web_server],recipe[backup]'
--distro ubuntu10.04-ruby193

OR

bundle exec knife rackspace server create -S server2013 -f 4 -N
server2013 --image 112 -r
'role[setup],role[mysql_server],role[web_server],recipe[backup]'
--distro ubuntu10.04-ruby193 --environment lucid

Neither seems to work as I expect.

The server gets created, but at the end of the run, it says:

Name: server2013
Flavor: 2GB server
Image: Ubuntu 10.04 LTS
Metadata: {}
Environment: lucid
Run List: role[setup], role[mysql_server], role[web_server], recipe[backup]

But:

  1. It uses the 2.0.4 sudo cookbook that I uploaded yesterday - which
    is not part of the lucid environment.

  2. In the Opscode management interface it shows up as _default:
    http://d.pr/i/UoZz

Any ideas what I'm missing?

Hey Darron,

It definitely looks like the ec2 server create should be passing through
the environment as you've specified it. [0]

Can you gist the contents of the client.rb as rendered post-bootstrap, when
you notice the machine assigned to the wrong environment, and the full
debug logs, if you haven't already posted those?

Cheers,

AJ

[0]

On 14 January 2013 19:33, Darron Froese darron@froese.org wrote:

Tried again a few different times this weekend - same failures -
downloading the wrong version of the sudo cookbook and being assigned
to the wrong environment:

bundle exec knife rackspace server create -E lucid -S sudo2013 -f 2 -N
sudo2013 --image 112 -r 'recipe[sudo]' --distro ubuntu10.04-ruby187

Environment doesn't seem to be working. · GitHub
http://d.pr/i/rjBp

bundle exec knife bootstrap -E lucid -r "recipe[sudo]" 184.106.71.194
-x root -P not-so-fast --node-name bootstrap2013 --distro
ubuntu10.04-ruby187

Tried via regular bootstrap. · GitHub
http://d.pr/i/DBDx

I also tried AWS:

bundle exec knife ec2 server create -E lucid -r "recipe[sudo]" -I
ami-ab36fbc2 -f m1.small -S dfroese -G varnish -x ubuntu --region
us-east-1 -Z us-east-1a --node-name aws2013 --distro
ubuntu10.04-ruby187

AWS · GitHub
http://d.pr/i/n6Pg

I expect to be able to create new servers and assign them to a
particular environment - is this correct?

Am I misunderstanding something or is something odd going on?

On Thu, Jan 10, 2013 at 2:25 PM, Darron Froese darron@froese.org wrote:

Using chef 10.16.4.

I have an environment called 'lucid' for my current infrastructure:

[master] darron@~/Dropbox/src/chef-repo: knife environment list
_default
lucid

We're using hosted Chef and this next bit shows all of my cookbook
versions for that environment:

gist:4505868 · GitHub

I'm adding a new server using that environment - tried passing
environment along 2 different ways:

bundle exec knife rackspace server create -E lucid -S server2013 -f 4
-N server2013 --image 112 -r
'role[setup],role[mysql_server],role[web_server],recipe[backup]'
--distro ubuntu10.04-ruby193

OR

bundle exec knife rackspace server create -S server2013 -f 4 -N
server2013 --image 112 -r
'role[setup],role[mysql_server],role[web_server],recipe[backup]'
--distro ubuntu10.04-ruby193 --environment lucid

Neither seems to work as I expect.

The server gets created, but at the end of the run, it says:

Name: server2013
Flavor: 2GB server
Image: Ubuntu 10.04 LTS
Metadata: {}
Environment: lucid
Run List: role[setup], role[mysql_server], role[web_server],
recipe[backup]

But:

  1. It uses the 2.0.4 sudo cookbook that I uploaded yesterday - which
    is not part of the lucid environment.

  2. In the Opscode management interface it shows up as _default:
    http://d.pr/i/UoZz

Any ideas what I'm missing?

OK - I think I've found a few more clues now - seems that
config_content isn't putting everything it should into the
/etc/chef/client.rb.

This is the command:

bundle exec knife ec2 server create -V -V -E lucid -r "recipe[sudo]"
-I ami-ab36fbc2 -f m1.small -S dfroese -G varnish -x ubuntu --region
us-east-1 -Z us-east-1a --node-name aws2019 --distro
ubuntu10.04-ruby187

The bootstrap has this in it:

(
cat <<'EOP'
<%= config_content %>
EOP
) > /etc/chef/client.rb

and this is the /etc/chef/client.rb:

log_level :info
log_location STDOUT
chef_server_url "Sign In - Chef Manage"
validation_client_name "nonfiction-validator"
node_name "aws2019"

If I manually create the /etc/chef/client.rb in my bootstrap recipe
then it works as I would expect:

(
cat <<'EOP'
log_level :info
log_location STDOUT
chef_server_url "<%= Chef::Config[:chef_server_url] %>"
validation_client_name "<%= Chef::Config[:validation_client_name] %>"
<% if @config[:chef_node_name] == nil %>

Using default node name"

<% else %>
node_name "<%= @config[:chef_node_name] %>"
<% end %>
environment "<%= Chef::Config[:environment] %>"
EOP
) > /etc/chef/client.rb

Will just adjust my bootstraps for the time being - not sure where
else to look now for the actual cause.

Thanks for the tip.

On Mon, Jan 14, 2013 at 12:20 AM, AJ Christensen aj@junglist.gen.nz wrote:

Hey Darron,

It definitely looks like the ec2 server create should be passing through the
environment as you've specified it. [0]

Can you gist the contents of the client.rb as rendered post-bootstrap, when
you notice the machine assigned to the wrong environment, and the full debug
logs, if you haven't already posted those?

Cheers,

AJ

[0]
knife-ec2/lib/chef/knife/ec2_server_create.rb at main · chef/knife-ec2 · GitHub

On 14 January 2013 19:33, Darron Froese darron@froese.org wrote:

Tried again a few different times this weekend - same failures -
downloading the wrong version of the sudo cookbook and being assigned
to the wrong environment:

bundle exec knife rackspace server create -E lucid -S sudo2013 -f 2 -N
sudo2013 --image 112 -r 'recipe[sudo]' --distro ubuntu10.04-ruby187

Environment doesn't seem to be working. · GitHub
http://d.pr/i/rjBp

bundle exec knife bootstrap -E lucid -r "recipe[sudo]" 184.106.71.194
-x root -P not-so-fast --node-name bootstrap2013 --distro
ubuntu10.04-ruby187

Tried via regular bootstrap. · GitHub
http://d.pr/i/DBDx

I also tried AWS:

bundle exec knife ec2 server create -E lucid -r "recipe[sudo]" -I
ami-ab36fbc2 -f m1.small -S dfroese -G varnish -x ubuntu --region
us-east-1 -Z us-east-1a --node-name aws2013 --distro
ubuntu10.04-ruby187

AWS · GitHub
http://d.pr/i/n6Pg

I expect to be able to create new servers and assign them to a
particular environment - is this correct?

Am I misunderstanding something or is something odd going on?

On Thu, Jan 10, 2013 at 2:25 PM, Darron Froese darron@froese.org wrote:

Using chef 10.16.4.

I have an environment called 'lucid' for my current infrastructure:

[master] darron@~/Dropbox/src/chef-repo: knife environment list
_default
lucid

We're using hosted Chef and this next bit shows all of my cookbook
versions for that environment:

gist:4505868 · GitHub

I'm adding a new server using that environment - tried passing
environment along 2 different ways:

bundle exec knife rackspace server create -E lucid -S server2013 -f 4
-N server2013 --image 112 -r
'role[setup],role[mysql_server],role[web_server],recipe[backup]'
--distro ubuntu10.04-ruby193

OR

bundle exec knife rackspace server create -S server2013 -f 4 -N
server2013 --image 112 -r
'role[setup],role[mysql_server],role[web_server],recipe[backup]'
--distro ubuntu10.04-ruby193 --environment lucid

Neither seems to work as I expect.

The server gets created, but at the end of the run, it says:

Name: server2013
Flavor: 2GB server
Image: Ubuntu 10.04 LTS
Metadata: {}
Environment: lucid
Run List: role[setup], role[mysql_server], role[web_server],
recipe[backup]

But:

  1. It uses the 2.0.4 sudo cookbook that I uploaded yesterday - which
    is not part of the lucid environment.

  2. In the Opscode management interface it shows up as _default:
    http://d.pr/i/UoZz

Any ideas what I'm missing?