0

our ops team wants to make sure that all IIS web sites are (a) logging to the right place and (b) logging the right things. The most awesome IIS Cookbook allows me to do both of these things if I know what sites are running on this old box, which, sadly, I do not. So a fairly straightforward implementation could be:

list_of_sites.each do |s|
  iis_site s do
    log_directory 'c:/fireplace'
    etc.
  end
end

But ... I don't know what sites are running on a given node. Ohai doesn't seem to have this info, but maybe there is a wonderous (I like this spelling better) Ohai plugin that my google-foo couldn't find. I could write an ohai plugin for this I suppose. But it would be my first so a little reluctant to go there. Are there other options?

Good list of ways to list sites is here: Display all sites and bindings in powershell, but not sure how to use a list of sites generated by powershell from within a recipe.

We're running chef 12 and various IIS's but oldest is 7.0.

Thx for any advice!

Beel
  • 1,000
  • 12
  • 23

1 Answers1

0

Making an Ohai plugin for this one thing is probably overkill, I would just use powershell_out with a variant of the code you linked to. You would want something like this:

cmd = powershell_out!(<<-EOH)
# A bunch of PS code goes here
EOH
sites = some_kind_of_parsing(cmd.stdout)
sites.each do |site|

The example PS code you linked is using Format-Table which would suck to parse back out, but I bet you can find some way to output it as JSON which would be much easier, or even just a line-based table without the header lines.

coderanger
  • 52,400
  • 4
  • 52
  • 75