[chef] Re: Re: Re: Re: Re: knife diff and JSON files in environments/ & roles/


Chronological Thread 
  • From: John Keiser < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Re: knife diff and JSON files in environments/ & roles/
  • Date: Mon, 20 Aug 2012 11:13:08 -0700

It applies to data_bags, roles and environments ... cookbooks can have whatever files they want.

--John

On Mon, Aug 20, 2012 at 10:53 AM, Denis Haskin < " target="_blank"> > wrote:
Does this apply only to environment and role files?  Or other files as well?

Thanks,


--
Denis Haskin



On Mon, Aug 20, 2012 at 1:52 PM, John Keiser < " target="_blank"> > wrote:
At Opscode, we're using .json files to store this information when deploying Hosted Chef.  But other people may be using .rb so they can write code in their data files.  I'm not sure which is more common, but they will work identically well as long as you are just recording data and not writing code in there.

--John

On Mon, Aug 20, 2012 at 10:43 AM, Denis Haskin < " target="_blank"> > wrote:
Thanks.  Sorry if I was unclear; I do understand that knife-essentials is just presenting me with a filesystem-ish view of the REST resources, not an actual filesystem.

What's common practice?  Using JSON files instead of ruby, as you suggest?


--
Denis Haskin




On Mon, Aug 20, 2012 at 12:34 PM, John Keiser < " target="_blank"> > wrote:
Hi Denis.  Glad you like the tool!

It's option (a): Chef takes the .rb files and turns them into JSON before we send them.  But a brief note: the Chef server is just a REST interface (which admittedly uses the JSON format) and is not actually a filesystem.  knife-essentials imposes that structure: it maps the server's REST interface into a virtual filesystem composed of .json files (i.e. the environments/blah.json "file" corresponds to HTTP GET/PUT/DELETE operations on /environments/blah).  It turns out this gives us a powerful toolset, and is a super convenient way to think about the system, but just FYI, that's an invention of knife-essentials.

The issue you are seeing is that knife diff assumes that your local filesystem looks the same as the virtual mapping (it assumes a certain directory structure, and assumes that files are .json).  For many people this is true, but not everyone (i.e. .rb files).  I've filed an issue for its lack of .rb support, because I still need to weigh the complexity costs of supporting multiple file formats against the benefits of .rb files.

Solution: If you're OK with JSON instead of RB files, the simplest solution is to:

1. Run "knife download roles environments", which will download all your current environments and roles as .json files.
2. Verify that the .json files actually represent when you wrote in the .rb files, and delete the .rb files to get rid of confusion.

I'd love to hear whether this solution works for you.

Thanks!

--John

On Mon, Aug 20, 2012 at 8:24 AM, Denis Haskin < " target="_blank"> > wrote:
When I use knife diff from the knife-essentials[1] gem (which is awesome, by the way), it shows me a lot of JSON files in the environments/ and roles/ folders that don't exist in my local filesystem (e.g. only on the chef server) [2].  But I have corresponding .rb files for each .json file that is indicated as "missing".

This is confusing... either (a) chef creates the .json files when I upload environments or roles to the server, from the .rb files, or (b) these are left over on the server from an old version of chef.

Anybody know which it is?  Is there some way I can fix this?

Thanks!


[2] (portion of output of knife diff --name-status)
D environments/obanyc_testrl.json
D environments/obanyc_prod.json
D environments/obanyc_dev.json
D environments/obanyc_demo.json
D environments/_default.json
D environments/obanyc_replay.json
D environments/staging.json
D environments/obanyc_qa.json
D environments/obanyc_staging.json
D roles/queuep.json
D roles/app.json
D roles/1ie.json
D roles/tds.json
D roles/2ie.json
D roles/queues.json
...etc for all roles...

--
Denis Haskin









Archive powered by MHonArc 2.6.16.

§