Roles to JSON broken on Chef-Solo


#1

Why does chef-solo require a key to generate a JSON representation of a
role for use with chef-solo?

I’m using the command from the wiki.
http://wiki.opscode.com/display/chef/Chef+Repository#ChefRepository-rolesorrole\rolename\

rake role[webserver]

/usr/local/lib/ruby/gems/1.8/gems/chef-0.9.6/lib/chef/rest/auth_credentials.rb:62:in
`load_signing_key’: I cannot read ~/.chef/user.pem, which you told me to
use to sign requests! (Chef::Exceptions::PrivateKeyMissing)


#2

On Fri, Jul 16, 2010 at 1:01 PM, consiliens consiliens@gmail.com wrote:

Why does chef-solo require a key to generate a JSON representation of a role
for use with chef-solo?

rake roles calls knife role from file which assumes you want to
upload the role to the server. With chef solo, you are not required to
convert the role to JSON before using it, however–you should be able
to just configure your role_path in solo.rb and run with it. I see
this is not documented on the roles page in the wiki, and the chef
solo page states that you have to convert to JSON first, which is
incorrect. I don’t have time to fix these right now, but I’ll make a
note to fix them as I’m able. If you’re willing to fix them, that
would be greatly appreciated.

Dan DeLeo


#3

On 07/19/2010 12:07 PM, Daniel DeLeo wrote:

On Fri, Jul 16, 2010 at 1:01 PM, consiliensconsiliens@gmail.com wrote:

Why does chef-solo require a key to generate a JSON representation of a role
for use with chef-solo?

rake roles calls knife role from file which assumes you want to
upload the role to the server. With chef solo, you are not required to
convert the role to JSON before using it, however–you should be able
to just configure your role_path in solo.rb and run with it. I see
this is not documented on the roles page in the wiki, and the chef
solo page states that you have to convert to JSON first, which is
incorrect. I don’t have time to fix these right now, but I’ll make a
note to fix them as I’m able. If you’re willing to fix them, that
would be greatly appreciated.

Dan DeLeo

I’m willing to fix them. Thank you for explaining how to use roles with
chef-solo.


#4

On 07/19/2010 06:36 PM, consiliens wrote:

On 07/19/2010 12:07 PM, Daniel DeLeo wrote:

On Fri, Jul 16, 2010 at 1:01 PM, consiliensconsiliens@gmail.com wrote:

Why does chef-solo require a key to generate a JSON representation of
a role
for use with chef-solo?

rake roles calls knife role from file which assumes you want to
upload the role to the server. With chef solo, you are not required to
convert the role to JSON before using it, however–you should be able
to just configure your role_path in solo.rb and run with it. I see
this is not documented on the roles page in the wiki, and the chef
solo page states that you have to convert to JSON first, which is
incorrect. I don’t have time to fix these right now, but I’ll make a
note to fix them as I’m able. If you’re willing to fix them, that
would be greatly appreciated.

Dan DeLeo

I’m willing to fix them. Thank you for explaining how to use roles with
chef-solo.

I tried role_path and it’s still not working. I’ll update the wiki once
it works. Here’s the code I’m using.

sudo chef-solo --config ./solo.rb

Contents of solo.rb

file_cache_path File.expand_path( ‘…’, FILE )
cookbook_path File.expand_path( ‘…/cookbooks’, FILE )
role_path File.expand_path( ‘…/roles’, FILE )
node_name ‘nginx’

…/roles contains nginx.rb that uses the Role DSL as defined on the
wiki. http://wiki.opscode.com/display/chef/Roles


#5

On Mon, Jul 19, 2010 at 6:19 PM, consiliens consiliens@gmail.com wrote:

On 07/19/2010 06:36 PM, consiliens wrote:

On 07/19/2010 12:07 PM, Daniel DeLeo wrote:

On Fri, Jul 16, 2010 at 1:01 PM, consiliensconsiliens@gmail.com wrote:

Why does chef-solo require a key to generate a JSON representation of
a role
for use with chef-solo?

rake roles calls knife role from file which assumes you want to
upload the role to the server. With chef solo, you are not required to
convert the role to JSON before using it, however–you should be able
to just configure your role_path in solo.rb and run with it. I see
this is not documented on the roles page in the wiki, and the chef
solo page states that you have to convert to JSON first, which is
incorrect. I don’t have time to fix these right now, but I’ll make a
note to fix them as I’m able. If you’re willing to fix them, that
would be greatly appreciated.

Dan DeLeo

I’m willing to fix them. Thank you for explaining how to use roles with
chef-solo.

I tried role_path and it’s still not working. I’ll update the wiki once it
works. Here’s the code I’m using.

What error are you getting? Chef::Exceptions::RoleNotFound?
Unfortunately, there’s not a lot of debug info to be had here, but if
you’re willing to hack some into the code, here’s where you’d do it:

HTH,
Dan DeLeo


#6

On 07/20/2010 09:53 AM, Daniel DeLeo wrote:

On Mon, Jul 19, 2010 at 6:19 PM, consiliensconsiliens@gmail.com wrote:

On 07/19/2010 06:36 PM, consiliens wrote:

On 07/19/2010 12:07 PM, Daniel DeLeo wrote:

On Fri, Jul 16, 2010 at 1:01 PM, consiliensconsiliens@gmail.com wrote:

Why does chef-solo require a key to generate a JSON representation of
a role
for use with chef-solo?

rake roles calls knife role from file which assumes you want to
upload the role to the server. With chef solo, you are not required to
convert the role to JSON before using it, however–you should be able
to just configure your role_path in solo.rb and run with it. I see
this is not documented on the roles page in the wiki, and the chef
solo page states that you have to convert to JSON first, which is
incorrect. I don’t have time to fix these right now, but I’ll make a
note to fix them as I’m able. If you’re willing to fix them, that
would be greatly appreciated.

Dan DeLeo

I’m willing to fix them. Thank you for explaining how to use roles with
chef-solo.

I tried role_path and it’s still not working. I’ll update the wiki once it
works. Here’s the code I’m using.

What error are you getting? Chef::Exceptions::RoleNotFound?
Unfortunately, there’s not a lot of debug info to be had here, but if
you’re willing to hack some into the code, here’s where you’d do it:
http://github.com/opscode/chef/blob/5f8f81915cfa2bc60cfd5d0cb2899a1188d8731c/chef/lib/chef/role.rb#L253-267

HTH,
Dan DeLeo

There is no error. The cookbooks just never run. I’m using the exact
same files on the Opscode platform without issue. Is setting node_name
the proper way to tell chef-solo which role to apply?

I’ll add the debug info and see what happens.


#7

On Tue, Jul 20, 2010 at 9:24 AM, consiliens consiliens@gmail.com wrote:

On 07/20/2010 09:53 AM, Daniel DeLeo wrote:

On Mon, Jul 19, 2010 at 6:19 PM, consiliensconsiliens@gmail.com wrote:

On 07/19/2010 06:36 PM, consiliens wrote:

On 07/19/2010 12:07 PM, Daniel DeLeo wrote:

On Fri, Jul 16, 2010 at 1:01 PM, consiliensconsiliens@gmail.com
wrote:

Why does chef-solo require a key to generate a JSON representation of
a role
for use with chef-solo?

rake roles calls knife role from file which assumes you want to
upload the role to the server. With chef solo, you are not required to
convert the role to JSON before using it, however–you should be able
to just configure your role_path in solo.rb and run with it. I see
this is not documented on the roles page in the wiki, and the chef
solo page states that you have to convert to JSON first, which is
incorrect. I don’t have time to fix these right now, but I’ll make a
note to fix them as I’m able. If you’re willing to fix them, that
would be greatly appreciated.

Dan DeLeo

I’m willing to fix them. Thank you for explaining how to use roles with
chef-solo.

I tried role_path and it’s still not working. I’ll update the wiki once
it
works. Here’s the code I’m using.

What error are you getting? Chef::Exceptions::RoleNotFound?
Unfortunately, there’s not a lot of debug info to be had here, but if
you’re willing to hack some into the code, here’s where you’d do it:

http://github.com/opscode/chef/blob/5f8f81915cfa2bc60cfd5d0cb2899a1188d8731c/chef/lib/chef/role.rb#L253-267

HTH,
Dan DeLeo

There is no error. The cookbooks just never run. I’m using the exact same
files on the Opscode platform without issue. Is setting node_name the
proper way to tell chef-solo which role to apply?

I’ll add the debug info and see what happens.

Oh, looking at your command-line invocation of chef-solo, it seems
like you need to also provide a JSON file with a run_list that
specifies which roles chef should use:
http://wiki.opscode.com/display/chef/chef+Solo#ChefSolo-JSON%2CAttributesandRecipes


#8

On 07/20/2010 10:30 AM, Daniel DeLeo wrote:

On Tue, Jul 20, 2010 at 9:24 AM, consiliensconsiliens@gmail.com wrote:

On 07/20/2010 09:53 AM, Daniel DeLeo wrote:

On Mon, Jul 19, 2010 at 6:19 PM, consiliensconsiliens@gmail.com wrote:

On 07/19/2010 06:36 PM, consiliens wrote:

On 07/19/2010 12:07 PM, Daniel DeLeo wrote:

On Fri, Jul 16, 2010 at 1:01 PM, consiliensconsiliens@gmail.com
wrote:

Why does chef-solo require a key to generate a JSON representation of
a role
for use with chef-solo?

rake roles calls knife role from file which assumes you want to
upload the role to the server. With chef solo, you are not required to
convert the role to JSON before using it, however–you should be able
to just configure your role_path in solo.rb and run with it. I see
this is not documented on the roles page in the wiki, and the chef
solo page states that you have to convert to JSON first, which is
incorrect. I don’t have time to fix these right now, but I’ll make a
note to fix them as I’m able. If you’re willing to fix them, that
would be greatly appreciated.

Dan DeLeo

I’m willing to fix them. Thank you for explaining how to use roles with
chef-solo.

I tried role_path and it’s still not working. I’ll update the wiki once
it
works. Here’s the code I’m using.

What error are you getting? Chef::Exceptions::RoleNotFound?
Unfortunately, there’s not a lot of debug info to be had here, but if
you’re willing to hack some into the code, here’s where you’d do it:

http://github.com/opscode/chef/blob/5f8f81915cfa2bc60cfd5d0cb2899a1188d8731c/chef/lib/chef/role.rb#L253-267

HTH,
Dan DeLeo

There is no error. The cookbooks just never run. I’m using the exact same
files on the Opscode platform without issue. Is setting node_name the
proper way to tell chef-solo which role to apply?

I’ll add the debug info and see what happens.

Oh, looking at your command-line invocation of chef-solo, it seems
like you need to also provide a JSON file with a run_list that
specifies which roles chef should use:
http://wiki.opscode.com/display/chef/chef+Solo#ChefSolo-JSON%2CAttributesandRecipes

That worked. I’ll update the wiki.

sudo chef-solo --config ./solo.rb --json-attributes ./run_list.json

$ cat run_list.json
{
“run_list”: [
“role[nginx]”
]
}

It would be nice if there was a --ruby-attributes option. run_list.rb
could use the Ruby DSL.
run_list ‘role[nginx]’


#9

On 07/20/2010 11:39 AM, consiliens wrote:

On 07/20/2010 10:30 AM, Daniel DeLeo wrote:

On Tue, Jul 20, 2010 at 9:24 AM, consiliensconsiliens@gmail.com wrote:

On 07/20/2010 09:53 AM, Daniel DeLeo wrote:

On Mon, Jul 19, 2010 at 6:19 PM, consiliensconsiliens@gmail.com
wrote:

On 07/19/2010 06:36 PM, consiliens wrote:

On 07/19/2010 12:07 PM, Daniel DeLeo wrote:

On Fri, Jul 16, 2010 at 1:01 PM, consiliensconsiliens@gmail.com
wrote:

Why does chef-solo require a key to generate a JSON
representation of
a role
for use with chef-solo?

rake roles calls knife role from file which assumes you want to
upload the role to the server. With chef solo, you are not
required to
convert the role to JSON before using it, however–you should be
able
to just configure your role_path in solo.rb and run with it. I see
this is not documented on the roles page in the wiki, and the chef
solo page states that you have to convert to JSON first, which is
incorrect. I don’t have time to fix these right now, but I’ll make a
note to fix them as I’m able. If you’re willing to fix them, that
would be greatly appreciated.

Dan DeLeo

I’m willing to fix them. Thank you for explaining how to use roles
with
chef-solo.

I tried role_path and it’s still not working. I’ll update the wiki
once
it
works. Here’s the code I’m using.

What error are you getting? Chef::Exceptions::RoleNotFound?
Unfortunately, there’s not a lot of debug info to be had here, but if
you’re willing to hack some into the code, here’s where you’d do it:

http://github.com/opscode/chef/blob/5f8f81915cfa2bc60cfd5d0cb2899a1188d8731c/chef/lib/chef/role.rb#L253-267

HTH,
Dan DeLeo

There is no error. The cookbooks just never run. I’m using the exact
same
files on the Opscode platform without issue. Is setting node_name the
proper way to tell chef-solo which role to apply?

I’ll add the debug info and see what happens.

Oh, looking at your command-line invocation of chef-solo, it seems
like you need to also provide a JSON file with a run_list that
specifies which roles chef should use:
http://wiki.opscode.com/display/chef/chef+Solo#ChefSolo-JSON%2CAttributesandRecipes

That worked. I’ll update the wiki.

sudo chef-solo --config ./solo.rb --json-attributes ./run_list.json

$ cat run_list.json
{
“run_list”: [
“role[nginx]”
]
}

It would be nice if there was a --ruby-attributes option. run_list.rb
could use the Ruby DSL.
run_list ‘role[nginx]’

I updated the wiki.

http://wiki.opscode.com/pages/diffpagesbyversion.action?pageId=1179893&selectedPageVersions=16&selectedPageVersions=12

The CAPTCHA on every edit combined with no preview button made it
difficult to contribute. It would be nice if Knife was able to locally
convert between the Ruby DSL and the JSON syntax.


#10

On Tue, Jul 20, 2010 at 11:49 AM, consiliens consiliens@gmail.com wrote:

On 07/20/2010 11:39 AM, consiliens wrote:

I updated the wiki.

http://wiki.opscode.com/pages/diffpagesbyversion.action?pageId=1179893&selectedPageVersions=16&selectedPageVersions=12

The CAPTCHA on every edit combined with no preview button made it difficult
to contribute. It would be nice if Knife was able to locally convert
between the Ruby DSL and the JSON syntax.

First of all, thank you. Every tiny bit that we can improve the docs
helps. I don’t know what we can do about the CAPTCHAs, but confluence
does have a preview mode:

http://img.skitch.com/20100721-t4ghb8gx63egg1sbhbp48p6xfr.jpg

It took me a long time to find this at first, I hope you guys won’t
have to struggle with it now :slight_smile:

Dan DeLeo


#11

I’ve tweaked the config so that approved contributors should no longer be
seeing CAPTCHAs when editing wiki pages.

On Tue, Jul 20, 2010 at 11:32 PM, Daniel DeLeo dan@kallistec.com wrote:

On Tue, Jul 20, 2010 at 11:49 AM, consiliens consiliens@gmail.com wrote:

On 07/20/2010 11:39 AM, consiliens wrote:

I updated the wiki.

http://wiki.opscode.com/pages/diffpagesbyversion.action?pageId=1179893&selectedPageVersions=16&selectedPageVersions=12

The CAPTCHA on every edit combined with no preview button made it
difficult
to contribute. It would be nice if Knife was able to locally convert
between the Ruby DSL and the JSON syntax.

First of all, thank you. Every tiny bit that we can improve the docs
helps. I don’t know what we can do about the CAPTCHAs, but confluence
does have a preview mode:

http://img.skitch.com/20100721-t4ghb8gx63egg1sbhbp48p6xfr.jpg

It took me a long time to find this at first, I hope you guys won’t
have to struggle with it now :slight_smile:

Dan DeLeo