Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customization of node's client.rb via bootstrap_context #39

Closed
patcon opened this issue Jun 13, 2015 · 12 comments
Closed

Allow customization of node's client.rb via bootstrap_context #39

patcon opened this issue Jun 13, 2015 · 12 comments

Comments

@patcon
Copy link
Contributor

patcon commented Jun 13, 2015

Certain automatic node attributes change between every node save (memory, interface stats, etc.). For those who are committing the json node objects into version control, it would be nice to allow this noise to be disabled.

We can do that here, where the client.rb template is generated during bootstrap, by adding a key for "whitelisted attributes":
https://github.com/chef/chef/blob/d8172e646d9fbf43e57bca5e20d0ac352ba9a66a/lib/chef/knife/core/bootstrap_context.rb#L64-L69

We can append automatic_attribute_whitelist [] to the bootstrapped node's client.rb to completely silence the noisy automatic attributes, but that's likely too opinionated. Most stay constant anyhow.

We could instead allow arbitrarily adding key-value pairs to the generated client.rb. Or alternatively, we could have a more user-friendly config that adds something like this, which should silence most noise:

# client.rb snippet
automatic_attribute_whitelist %w(
  !network/interfaces
  !memory/
]

Blacklisting seems to be an undocumented feature...
https://github.com/chef/chef/blob/59da09f64b72dbd712c890f999322493a4bc9ec4/lib/chef/node_map.rb#L157

EDIT: Turns out blacklisting isn't a thing, so this isn't useful for now

@patcon
Copy link
Contributor Author

patcon commented Jun 13, 2015

fwiw, it seems automatic_attribute_whitelist needs at least ["fqdn/"] in order for knife-zero to continue to work. But this is probably a minimum, so that the knife node show NAME is still maximally populated:

# client.rb
automatic_attribute_whitelist [
  "fqdn/",
  "ipaddress/",
  "roles/",
  "recipes/",
  "ipaddress/",
  "platform/",
  "platform_version/",
]

@patcon
Copy link
Contributor Author

patcon commented Jun 13, 2015

Oh hey, this can be done here:
https://github.com/opscode-cookbooks/chef-client

But hey, I'll leave this open in case you want to have a simple flag in knife.rb that quiets down all the noisy linux automatic attrs.

@sawanoboly
Copy link
Member

I see. Thank you for good report of use case!

@sawanoboly
Copy link
Member

Note: I've catched up similar feedback from twitter. https://twitter.com/masudaK/status/608555090165776384

@sawanoboly
Copy link
Member

https://github.com/chef/chef/blob/59da09f64b72dbd712c890f999322493a4bc9ec4/lib/chef/knife/core/bootstrap_context.rb#L64

client.rb is made by .config_content . I'm going to append content by around_alias.

Which do you think is better? @patcon @rmoriz

  • be able to append free format content to client.rb.
  • create new option such as --[no-]suppress-attributes for add whitelist automatically.
  • create new options such as --attribute_whitelist, attribute_blacklist as Array.

@sawanoboly
Copy link
Member

hmm... how about #43 ?

@patcon
Copy link
Contributor Author

patcon commented Jun 14, 2015

Hm. I realize I made the request, but I'd actually moved away from the idea of using the whitelist (unless they add negating and make a blacklist possible). So much node information seems to be lost unless the whitelist is VERY extensive, which strikes me as very hard to manage (different platforms have different top-level keys for automatic attrs, etc.)

Perhaps this is best implemented as a recommended wrapper cookbook around one of the blacklist attrs cookbooks mentioned in chef/chef#3533?

@patcon
Copy link
Contributor Author

patcon commented Jun 14, 2015

I'm going to close this for now, as you've created a feature that addresses the initial request, and my new preferred way approach will be done outside this project :)

Thanks @sawanoboly, and sorry for the confusion!

@rmoriz
Copy link

rmoriz commented Jun 14, 2015

(Let me just add my notes, which may help other people having the same issue:

I was manging the node.json files manually (coming from a knife-solo setup) and initially had the same issue until I found out, that knife node edit <name> removes a lot of the clutter before opening the editor. This fits my use case, as I'm happy to store everything in git.)

@sawanoboly
Copy link
Member

@patcon
Thanks, I also seemed blacklist approach is better. ( discussed in chef/chef#3533 )

Apart from that, I thought also likely case useful to append whitelist, so I implemented it.

@sawanoboly
Copy link
Member

@rmoriz Yes, It's kind of use case 😃

@patcon
Copy link
Contributor Author

patcon commented Jun 14, 2015

Rockin :)

And thanks @rmoriz! That's actually really helpful for our workflow! I hadn't put two and two together on that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants