Changing a cookbook's folder-name - how painful?


#1

Hi,
I’m in the process or revisiting my idea to use Bundler to manage
groups of individual cookbooks in to ./chef-repo/cookbooks.
I’ve made some progress. Hence I have a couple of questions:

  • If I change a cookbook’s folder name (i.e. under
    ./chef-repo/cookbooks), where am I going to have propagate that
    change? E.g. cookbooks/apache2 -> cookbooks/apache2-. So far I
    can guess a couple of places, but it would be nice to have a list of
    everywhere that change must be made.
  • Is there a way or one place to map a cookbook’s folder name to some
    name that is referenced else where? Some way of abusing Role’s
    override_attributes or some such thing?
  • WRT to Chef environments, will these map to a folder structure under
    the cookbooks folder, e.g. cookbooks/prod/apache2-,
    cookbooks/staging/apache2-

Appreciate any insights.


πόλλ’ οἶδ ἀλώπηξ, ἀλλ’ ἐχῖνος ἓν μέγα
[The fox knows many things, but the hedgehog knows one big thing.]
Archilochus, Greek poet (c. 680 BC – c. 645 BC)
http://wiki.hedgehogshiatus.com


#2

On Wed, Dec 8, 2010 at 1:33 AM, Hedge Hog hedgehogshiatus@gmail.com wrote:

Hi,
I’m in the process or revisiting my idea to use Bundler to manage
groups of individual cookbooks in to ./chef-repo/cookbooks.
I’ve made some progress. Hence I have a couple of questions:

  • If I change a cookbook’s folder name (i.e. under
    ./chef-repo/cookbooks), where am I going to have propagate that
    change? E.g. cookbooks/apache2 -> cookbooks/apache2-. So far I
    can guess a couple of places, but it would be nice to have a list of
    everywhere that change must be made.
  • Is there a way or one place to map a cookbook’s folder name to some
    name that is referenced else where? Some way of abusing Role’s
    override_attributes or some such thing?
  • WRT to Chef environments, will these map to a folder structure under
    the cookbooks folder, e.g. cookbooks/prod/apache2-,
    cookbooks/staging/apache2-

Appreciate any insights.

This is going to be tough. The cookbook loader uses the directory name
as the name of the cookbook, so you’d have to change the run lists of
all of the nodes and roles to use recipe[apache2-123def]. If you’re
committed to what you’ve got so far, you might be able to use a rake
task or similar to create symlinks with the hash part removed.

Dan DeLeo


πόλλ’ οἶδ ἀλώπηξ, ἀλλ’ ἐχῖνος ἓν μέγα
[The fox knows many things, but the hedgehog knows one big thing.]
Archilochus, Greek poet (c. 680 BC – c. 645 BC)
http://wiki.hedgehogshiatus.com


#3

On Thu, Dec 9, 2010 at 4:13 AM, Daniel DeLeo dan@kallistec.com wrote:

On Wed, Dec 8, 2010 at 1:33 AM, Hedge Hog hedgehogshiatus@gmail.com wrote:

Hi,
I’m in the process or revisiting my idea to use Bundler to manage
groups of individual cookbooks in to ./chef-repo/cookbooks.
I’ve made some progress. Hence I have a couple of questions:

  • If I change a cookbook’s folder name (i.e. under
    ./chef-repo/cookbooks), where am I going to have propagate that
    change? E.g. cookbooks/apache2 -> cookbooks/apache2-. So far I
    can guess a couple of places, but it would be nice to have a list of
    everywhere that change must be made.
  • Is there a way or one place to map a cookbook’s folder name to some
    name that is referenced else where? Some way of abusing Role’s
    override_attributes or some such thing?
  • WRT to Chef environments, will these map to a folder structure under
    the cookbooks folder, e.g. cookbooks/prod/apache2-,
    cookbooks/staging/apache2-

Appreciate any insights.

This is going to be tough. The cookbook loader uses the directory name
as the name of the cookbook, so you’d have to change the run lists of
all of the nodes and roles to use recipe[apache2-123def]. If you’re
committed to what you’ve got so far, you might be able to use a rake
task or similar to create symlinks with the hash part removed.

Dan DeLeo

Thanks for the insight.


πόλλ’ οἶδ ἀλώπηξ, ἀλλ’ ἐχῖνος ἓν μέγα
[The fox knows many things, but the hedgehog knows one big thing.]
Archilochus, Greek poet (c. 680 BC – c. 645 BC)
http://wiki.hedgehogshiatus.com


πόλλ’ οἶδ ἀλώπηξ, ἀλλ’ ἐχῖνος ἓν μέγα
[The fox knows many things, but the hedgehog knows one big thing.]
Archilochus, Greek poet (c. 680 BC – c. 645 BC)
http://wiki.hedgehogshiatus.com


#4

On Thu, Dec 9, 2010 at 4:13 AM, Daniel DeLeo dan@kallistec.com wrote:

On Wed, Dec 8, 2010 at 1:33 AM, Hedge Hog hedgehogshiatus@gmail.com wrote:

Hi,
I’m in the process or revisiting my idea to use Bundler to manage
groups of individual cookbooks in to ./chef-repo/cookbooks.
I’ve made some progress. Hence I have a couple of questions:

  • If I change a cookbook’s folder name (i.e. under
    ./chef-repo/cookbooks), where am I going to have propagate that
    change? E.g. cookbooks/apache2 -> cookbooks/apache2-. So far I
    can guess a couple of places, but it would be nice to have a list of
    everywhere that change must be made.
  • Is there a way or one place to map a cookbook’s folder name to some
    name that is referenced else where? Some way of abusing Role’s
    override_attributes or some such thing?
  • WRT to Chef environments, will these map to a folder structure under
    the cookbooks folder, e.g. cookbooks/prod/apache2-,
    cookbooks/staging/apache2-

Appreciate any insights.

This is going to be tough. The cookbook loader uses the directory name
as the name of the cookbook, so you’d have to change the run lists of
all of the nodes and roles to use recipe[apache2-123def]. If you’re
committed to what you’ve got so far, you might be able to use a rake
task or similar to create symlinks with the hash part removed.

I’m struggling to see if or how environments show up ‘on-the-disk’ in
the chef-repo.
From the feature file I see the HTTP API uses:
./environments//cookbooks

It seems this does not map to the chef-repo - or at least looking at
what is currently in the environments branch.

There are a lot of feature files and I haven’t memorized Chef’s
internal workflows, so I’d appreciate any hint about what feature
file(s) to dig into.

Best wishes.

Dan DeLeo


πόλλ’ οἶδ ἀλώπηξ, ἀλλ’ ἐχῖνος ἓν μέγα
[The fox knows many things, but the hedgehog knows one big thing.]
Archilochus, Greek poet (c. 680 BC – c. 645 BC)
http://wiki.hedgehogshiatus.com


πόλλ’ οἶδ ἀλώπηξ, ἀλλ’ ἐχῖνος ἓν μέγα
[The fox knows many things, but the hedgehog knows one big thing.]
Archilochus, Greek poet (c. 680 BC – c. 645 BC)
http://wiki.hedgehogshiatus.com


#5

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello!

On Dec 8, 2010, at 12:27 PM, Hedge Hog wrote:

I’m struggling to see if or how environments show up ‘on-the-disk’ in
the chef-repo.
From the feature file I see the HTTP API uses:
./environments//cookbooks

It seems this does not map to the chef-repo - or at least looking at
what is currently in the environments branch.

Environments will go in the directory “environments” in the chef-repo. For example from my testing sandbox:

% ls ~/chef-repo/environments
development.rb
production.rb
staging.rb

Each of those is the Ruby DSL file for the environment0. The cookbook versions would be specified in the environment. The directory structure does not change on disk. The association happens on the server side through the API automatically.


Opscode, Inc
Joshua Timberman, Technical Evangelist
IRC, Skype, Twitter, Github: jtimberman

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEYEARECAAYFAk0AE8cACgkQO97WSdVpzT17CwCfbSF7I/oSKpddeIj9Lcf75GqN
TgcAnRGWT10XcVNjWHPE+aOGsiPvIzci
=jU/u
-----END PGP SIGNATURE-----


#6

On Thu, Dec 9, 2010 at 10:24 AM, Joshua Timberman joshua@opscode.com wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello!

On Dec 8, 2010, at 12:27 PM, Hedge Hog wrote:

I’m struggling to see if or how environments show up ‘on-the-disk’ in
the chef-repo.
From the feature file I see the HTTP API uses:
./environments//cookbooks

It seems this does not map to the chef-repo - or at least looking at
what is currently in the environments branch.

Environments will go in the directory “environments” in the chef-repo. For example from my testing sandbox:

OK, I’d not pulled the branch correctly - apologies.
In the ‘you manage environments with files’ use case mentioned on the
wiki, could the following be an alternative to editing a file to add a
cookbook, i.e. only the cookbook_versions line would be absent or over
ridden by the presence of a sub-folder ./development/cookbooks:

$ ls -la ~/chef-repo/environments/*
development.rb
production.rb
staging.rb

development:
total 8
drwxr-sr-x 2 hedge users 22 2010-12-09 10:34 .
drwxrwsr-x 9 hedge users 4096 2010-12-09 10:34 …
drwxr-xr-x 3 hedge users 20 2010-12-08 16:09 cookbooks

production:
total 8
drwxr-sr-x 2 hedge users 22 2010-12-09 10:34 .
drwxrwsr-x 9 hedge users 4096 2010-12-09 10:34 …
drwxr-xr-x 3 hedge users 20 2010-12-08 16:09 cookbooks

staging:
total 8
drwxr-sr-x 2 hedge users 22 2010-12-09 10:34 .
drwxrwsr-x 9 hedge users 4096 2010-12-09 10:34 …
drwxr-xr-x 3 hedge users 20 2010-12-08 16:09 cookbooks

Where

$ ls -la ~/chef-repo/environments/development/*

cookbooks:
total 20
drwxr-xr-x 26 hedge users 4096 2010-12-08 16:10 .
drwxr-xr-x 10 hedge users 4096 2010-12-08 16:09 …
drwxr-xr-x 8 hedge users 4096 2010-12-08 16:10 apache2
drwxr-xr-x 5 hedge users 118 2010-12-08 16:09 application
drwxr-xr-x 5 hedge users 114 2010-12-08 16:09 apt
etc.

What benefit does this bring?
I, or my script, can update cookbooks without having to edit any
files, by installing them to a folder as follows:

bundle install --without production staging --gemfile
~/chef/app_stacks/rails.gemfile --install-path
~/chef/chef-repo/environments/development/cookbooks

There is some way to go to get bundler to fully live up to its
potential and play its complete part, but it’d be nice to have Chef’s
door left open.

Appreciate the consideration.

% ls ~/chef-repo/environments
development.rb
production.rb
staging.rb

Each of those is the Ruby DSL file for the environment0. The cookbook versions would be specified in the environment. The directory structure does not change on disk. The association happens on the server side through the API automatically.


Opscode, Inc
Joshua Timberman, Technical Evangelist
IRC, Skype, Twitter, Github: jtimberman

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEYEARECAAYFAk0AE8cACgkQO97WSdVpzT17CwCfbSF7I/oSKpddeIj9Lcf75GqN
TgcAnRGWT10XcVNjWHPE+aOGsiPvIzci
=jU/u
-----END PGP SIGNATURE-----


πόλλ’ οἶδ ἀλώπηξ, ἀλλ’ ἐχῖνος ἓν μέγα
[The fox knows many things, but the hedgehog knows one big thing.]
Archilochus, Greek poet (c. 680 BC – c. 645 BC)
http://wiki.hedgehogshiatus.com