0

For config mgmt, we first moved from Shell scripting to Python scripting, for the purpose of smooth transition in supporting any new platform(OS), with minimum code changes. Python code uses popen() to execute commands based on OS.

As we use python for installation & configuration of applications, but python does not provide platform independent approach for install/config.

For platform independence, we want to go for Chef

There are twenty nodes(10 windows & 10 Linux), to install pdf reader.

Can a Chef cookbook recipe be platform independent to install pdf reader on any OS?

or

Do we need to write recipe per platform?

overexchange
  • 15,768
  • 30
  • 152
  • 347
  • Sounds like you're looking for this. I'd imagine you can just set the download url based on the platform https://docs.chef.io/dsl_recipe.html#platform – iCodeSometime Dec 26 '18 at 16:40
  • @kennycoc we are doing something similar in python...`if platform?('windows')` which we want to avoid.. – overexchange Dec 26 '18 at 17:13
  • as far as I can tell, there's no PDF Reader recipe.. But even if there was, it would just be switching on the platform regardless.. it's not like there's a platform independent installer. Best case, if you're just trying to avoid the conditional, you could host the installers on your own server, and do something like `url = "https://servername/pdfReader/#{node['platform']}"` – iCodeSometime Dec 26 '18 at 17:32

1 Answers1

1

Something has to be platform-aware in what you’re doing, because it is necessarily true that there’s a different installer for each platform. If you really want to go the Chef route, then use the supports keyword in your cookbook’s metadata.rb: https://docs.chef.io/config_rb_metadata.html, so that your cookbook only tries to install on specific platforms. If you add platforms to your cookbook, it would be very friendly of you to contribute it to supermarket.chef.io, because as kennycoc pointed out, there isn’t one there now.

David M
  • 4,325
  • 2
  • 28
  • 40