0

I'm fairly new to Chef and have been writing recipes for Kiosks that we use at work.

I've created a role for the Kiosk that contains a set of attributes, however one of these attributes is a unique ID that is different for each Kiosk node.

This ID is provided by our customer who uses the Kiosk, is abritrary, and can't be generated automatically.

What's best practice for setting this value? I'm using Chef Server and was thinking the best place to do it would be at Bootstrap but not entirely sure how.

Pierre.Vriens
  • 7,205
  • 14
  • 37
  • 84
Caledonia91
  • 383
  • 2
  • 10
  • That's quite vague about this id, can it be generated or should it be set to a specific value ? – Tensibai Jul 27 '18 at 09:52
  • It has to be set as a specific value, that's different for every node. – Caledonia91 Jul 27 '18 at 13:08
  • What I mean is would something like node.set['attribute']['id'] = node['fqdn'].hash % 9999(which give a number between 1 and 9999 derived from hostname) works or not – Tensibai Jul 27 '18 at 13:20
  • Unfortunately not, the ID is basically an ID given to us from a client and it's different on each node. We do not generate it. – Caledonia91 Jul 27 '18 at 13:47
  • then you should [edit] your question to specify that and show an example on how you get that id (or explain it with more details) – Tensibai Jul 27 '18 at 13:53
  • I will edit the origional post for clarity, but now you know it's an arbritrary number that's different on each node and can't be generated automatically, do you have any useful sugestions? – Caledonia91 Jul 27 '18 at 15:38
  • I don't know how you provision your nodes, but one option is passing the attribute in a json file at bootstrap/first run by passing something like -j /etc/chef/first-boot.json for the first run as showcased in the docs – Tensibai Jul 27 '18 at 15:46
  • When you say "client", are you speaking of the user/customer or the application on the kiosk? – Rilindo Jul 29 '18 at 02:01
  • When I say client I mean our customer/end user, will edit for clarity – Caledonia91 Jul 30 '18 at 09:00

1 Answers1

1

Yesterday I asked similar question and found this similar question after getting replies in my own post. What people suggested me in my question is editing a node by knife edit and then setting an attribute for that particular node manually. This attribute would be assigned only to this node. Or the other way - you could create a wrapper cookbook that would override attributes of your "base" cookbook. For more details check out answers and comments for my question.

Learner
  • 123
  • 5