0

Would Chef server URL be accessible as an attribute of a node? I would like to have a custom recipe behaviour changed based on the server id (URL) the node is connected to.

https://docs.chef.io/ohai.html doesn't list server (URL) provided.

Thanks

gliptak
  • 3,592
  • 2
  • 29
  • 61

1 Answers1

4

The chef_server_url config setting is not available as a node attribute, but you can access this configuration via Chef::Config:

Chef::Config['chef_server_url']
StephenKing
  • 36,187
  • 11
  • 83
  • 112
  • 1
    the nodes in my chef server seem to have an attribute for it at node['chef_client']['config']['chef_server_url'] but that may be because I use the chef-client cookbook as part of my base cookbook runlist. – Bill Warner Jun 17 '16 at 17:57
  • Yes, sure, if you're using the [chef-client](supermarket.chef.io/cookbooks/chef-client) cookbook, you can also use the info form there. Depends on the environment, of course. – StephenKing Jun 17 '16 at 18:02