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

Windows 2008 isn't being detected. #346

Closed
geerzo opened this issue Jan 4, 2016 · 16 comments
Closed

Windows 2008 isn't being detected. #346

geerzo opened this issue Jan 4, 2016 · 16 comments
Assignees
Labels
Type: Bug Feature not working as expected
Milestone

Comments

@geerzo
Copy link

geerzo commented Jan 4, 2016

Split out from #323

I have a similar problem on Windows through Test Kitchen via the Chef DK 0.10.0. The os object doesn't seem to be functioning properly.

The following commands all return false.

puts os.redhat?
puts os.debian?
puts os.suse?
puts os.bsd?
puts os.solaris?
puts os.linux?
puts os.unix?
puts os.windows?

Below is the gem list from running chef gem list. There are definitely outdated gems but I was hesitant to update them since they all come pre-packaged.

activesupport (4.2.4, 3.2.22)
addressable (2.3.8)
app_conf (0.4.2)
appbundler (0.6.0)
archive (0.0.6)
aruba (0.10.0, 0.7.4)
ast (2.1.0)
astrolabe (1.3.1)
aws-sdk (2.1.35)
aws-sdk-core (2.1.35)
aws-sdk-resources (2.1.35)
aws-sdk-v1 (1.66.0)
axiom-types (0.1.1)
berkshelf (4.0.1)
berkshelf-api-client (2.0.0)
bigdecimal (1.2.4)
buff-config (1.0.1)
buff-extensions (1.0.0)
buff-ignore (1.1.1)
buff-ruby_engine (0.1.0)
buff-shell_out (0.2.0)
builder (3.2.2)
bundler (1.10.6)
cane (2.6.2)
celluloid (0.16.0)
celluloid-io (0.16.2)
CFPropertyList (2.3.2)
chef (12.5.1)
chef-config (12.5.1)
chef-dk (0.10.0)
chef-provisioning (1.5.0)
chef-provisioning-aws (1.6.1)
chef-provisioning-azure (0.4.0)
chef-provisioning-fog (0.15.0)
chef-provisioning-vagrant (0.10.0)
chef-vault (2.6.1)
chef-zero (4.3.2, 1.5.6)
cheffish (1.6.0)
chefspec (4.4.0)
childprocess (0.5.7)
cleanroom (1.0.0)
codeclimate-test-reporter (0.4.8)
coderay (1.1.0)
coercible (1.0.0)
concurrent-ruby (0.9.2)
contracts (0.12.0)
cookbook-omnifetch (0.2.2)
countloc (0.4.0)
crack (0.4.2)
cucumber (2.1.0, 1.3.20)
cucumber-core (1.3.0)
dep-selector-libgecode (1.0.2)
dep_selector (1.0.3)
descendants_tracker (0.0.4)
diff-lcs (1.2.5)
diffy (3.0.7)
docile (1.1.5)
docker-api (1.22.4)
domain_name (0.5.25)
equalizer (0.0.11)
erubis (2.7.0)
excon (0.45.4)
fakefs (0.6.7)
faraday (0.9.2)
fauxhai (2.3.0)
ffi (1.9.10)
ffi-yajl (2.2.2)
finstyle (1.5.0)
fission (0.5.0)
fog (1.35.0)
fog-aliyun (0.0.10)
fog-atmos (0.1.0)
fog-aws (0.7.6)
fog-brightbox (0.9.0)
fog-core (1.32.1)
fog-dynect (0.0.2)
fog-ecloud (0.3.0)
fog-google (0.1.1)
fog-json (1.0.2)
fog-local (0.2.1)
fog-powerdns (0.1.1)
fog-profitbricks (0.0.5)
fog-radosgw (0.0.4)
fog-riakcs (0.1.0)
fog-sakuracloud (1.3.3)
fog-serverlove (0.1.2)
fog-softlayer (1.0.2)
fog-storm_on_demand (0.1.1)
fog-terremark (0.1.0)
fog-vmfusion (0.1.0)
fog-voxel (0.1.0)
fog-xenserver (0.2.2)
fog-xml (0.1.2)
foodcritic (5.0.0)
formatador (0.2.5)
fuubar (1.3.3)
gherkin (2.12.2)
gherkin3 (3.1.2)
git (1.2.9.1)
grape (0.13.0)
grape-msgpack (0.1.2)
gssapi (1.2.0)
guard (2.13.0)
guard-compat (1.2.1)
guard-rspec (4.6.4)
gyoku (1.3.1)
hashdiff (0.2.3)
hashie (3.4.3, 2.1.2)
highline (1.7.8)
hitimes (1.2.3)
http (0.9.8)
http-cookie (1.0.2)
http-form_data (1.0.1)
http_parser.rb (0.6.0)
httpclient (2.7.0, 2.6.0.1)
i18n (0.7.0)
ice_nine (0.11.1)
inflecto (0.0.2)
inifile (2.0.2)
inspec (0.9.2)
io-console (0.4.3)
ipaddress (0.8.0)
jmespath (1.1.3)
json (1.8.3, 1.8.1)
kitchen-inspec (0.9.0)
kitchen-vagrant (0.19.0)
knife-spork (1.5.0)
knife-windows (1.1.1)
libyajl2 (1.2.0)
listen (3.0.4)
little-plugger (1.1.4)
logging (1.8.2)
lumberjack (1.0.9)
macaddr (1.7.1)
maruku (0.7.2)
metaclass (0.0.4)
method_source (0.8.2)
mime-types (2.6.2)
mini_portile (0.6.2, 0.6.0)
minitar (0.5.4)
minitest (5.8.2, 4.7.5)
mixlib-authentication (1.3.0)
mixlib-cli (1.5.0)
mixlib-config (2.2.1)
mixlib-install (0.7.0)
mixlib-log (1.6.0)
mixlib-shellout (2.2.3)
mocha (1.1.0)
molinillo (0.2.3)
moneta (0.6.0)
msgpack (0.5.12)
multi_json (1.11.2)
multi_test (0.1.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
nenv (0.2.0)
net-scp (1.2.1)
net-ssh (2.9.2)
net-ssh-gateway (1.2.0)
net-ssh-multi (1.2.1)
net-telnet (0.1.1)
netrc (0.11.0)
nio4r (1.1.1)
nokogiri (1.6.6.2, 1.6.3.1)
nori (2.6.0)
notiffany (0.0.8)
octokit (4.1.1, 3.8.0)
ohai (8.7.0)
paint (1.0.0)
parallel (1.6.1)
parser (2.2.3.0)
plist (3.1.0)
polyglot (0.3.5)
powerpack (0.1.1)
pry (0.10.3)
psych (2.0.5)
puma (1.6.3)
r-train (0.9.1)
rack (1.6.4, 1.5.5)
rack-accept (0.4.5)
rack-mount (0.8.3)
rainbow (2.0.0)
rake (10.4.2, 10.1.0, 0.9.6)
rb-fsevent (0.9.6)
rb-inotify (0.9.5)
rdoc (4.1.0)
reel (0.5.0)
retryable (2.0.3)
ridley (4.3.2)
rspec (3.3.0, 3.0.0)
rspec-core (3.3.2, 3.0.4)
rspec-expectations (3.3.1, 3.0.4)
rspec-its (1.2.0)
rspec-mocks (3.3.2, 3.0.4)
rspec-support (3.3.0, 3.0.4)
rspec_junit_formatter (0.2.3)
rubocop (0.34.2, 0.32.1, 0.31.0)
ruby-progressbar (1.7.5)
ruby-shadow (2.5.0)
ruby_gntp (0.3.4)
rubyntlm (0.4.0)
rubyzip (1.1.7)
rufus-lru (1.0.5)
safe_yaml (1.0.4)
sawyer (0.6.0)
semverse (1.2.1)
serverspec (2.24.2)
sfl (2.2)
shellany (0.0.1)
simplecov (0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
solve (2.0.1, 1.2.1)
specinfra (2.44.1)
spork (0.9.2)
stuartpreston-azure-sdk-for-ruby (0.7.1)
syslog-logger (1.6.8)
systemu (2.6.5)
test-kitchen (1.4.2)
test-unit (2.1.6.0)
thor (0.19.1)
thread_safe (0.3.5)
timers (4.0.4)
tomlrb (1.1.1)
treetop (1.6.3)
tzinfo (1.2.2)
ubuntu_ami (0.4.1)
unf (0.1.4)
unf_ext (0.0.7.1)
uuid (2.3.8)
uuidtools (2.1.5)
varia_model (0.4.1)
virtus (1.0.5)
webmock (1.22.3)
websocket_parser (1.0.0)
winrm (1.3.4)
winrm-s (0.3.1)
winrm-transport (1.0.2)
wmi-lite (1.0.0)
xml-simple (1.1.5)
yajl-ruby (1.2.1)
yard (0.8.7.6)
@chris-rock
Copy link
Contributor

@geerzo Windows detections was only solved within the latest 0.9.8 release, which will be released within the next days. Once it is released, you get this installed via chef gem install inspec. Afterwards, you should see inspec version 0.9.8 in that list.

@geerzo
Copy link
Author

geerzo commented Jan 6, 2016

Thanks @chris-rock. I'll give it a shot when it comes out.

@chris-rock
Copy link
Contributor

@geerzo We just pushed the latest version. We may used some powershell scripts that run on Win 2012 only. We plan to add more integration tests for Windows. Let us know if you run into any issues

@geerzo
Copy link
Author

geerzo commented Jan 11, 2016

Still having problems. Here is my spec file

puts os.windows?

describe windows_feature('ADDS-Domain-Controller') do
  it { should be_installed }
end

describe windows_feature('ADDS-Identity-Mgmt') do
  it { should be_installed }
end

describe windows_feature('ADDS-NIS') do
  it { should be_installed }
end

describe windows_feature('ADDS-Password-Sync') do
  it { should be_installed }
end

describe windows_feature('Application-Server') do
  it { should_not be_installed }
end

Here are the results

false
*****

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) Windows Feature 'ADDS-Domain-Controller' The `windows_feature` resource is not supported on your OS.
     # Not yet implemented
     # /Users/user/.chefdk/gem/ruby/2.1.0/gems/inspec-0.9.8/lib/inspec/runner.rb:134

  2) Windows Feature 'ADDS-Identity-Mgmt' The `windows_feature` resource is not supported on your OS.
     # Not yet implemented
     # /Users/user/.chefdk/gem/ruby/2.1.0/gems/inspec-0.9.8/lib/inspec/runner.rb:134

  3) Windows Feature 'ADDS-NIS' The `windows_feature` resource is not supported on your OS.
     # Not yet implemented
     # /Users/user/.chefdk/gem/ruby/2.1.0/gems/inspec-0.9.8/lib/inspec/runner.rb:134

  4) Windows Feature 'ADDS-Password-Sync' The `windows_feature` resource is not supported on your OS.
     # Not yet implemented
     # /Users/user/.chefdk/gem/ruby/2.1.0/gems/inspec-0.9.8/lib/inspec/runner.rb:134

  5) Windows Feature 'Application-Server' The `windows_feature` resource is not supported on your OS.
     # Not yet implemented
     # /Users/user/.chefdk/gem/ruby/2.1.0/gems/inspec-0.9.8/lib/inspec/runner.rb:134

Finished in 0.00086 seconds (files took 1.51 seconds to load)
5 examples, 0 failures, 5 pending

@chris-rock
Copy link
Contributor

You are running this locally right?

@geerzo
Copy link
Author

geerzo commented Jan 12, 2016

I'm running using test-kitchen...so I guess the answer is no. Looking at the VM spun up by kitchen, it doesn't even have the inspec gem on it at all.

@chris-rock
Copy link
Contributor

Got you. kitchen-inspec uses winrm connection to the windows server and does not require to install ruby on the Windows machine. We need to have a look, why Windows 2008 is not detected properly. Do you have a publicly available Windows 2008 machine that I can use for testing?

@geerzo
Copy link
Author

geerzo commented Jan 12, 2016

I don't have a publicly available one. But I used this packer repo to build mine. https://github.com/joefitzgerald/packer-windows

FYI - Windows updates take up to 8 hours so that variable needs to be tweaked potentially. Maybe you can turn them off though.

@chris-rock chris-rock added the Type: Bug Feature not working as expected label Jan 14, 2016
@chris-rock
Copy link
Contributor

Thanks for sharing this. We are currently working on appveyor integration to make windows testing a lot easier for each PR. I apologize for the delay.

@chris-rock chris-rock self-assigned this Jan 19, 2016
@chris-rock chris-rock added this to the 0.9.10 milestone Jan 19, 2016
@chris-rock
Copy link
Contributor

@geerzo we improved the windows support a lot during the last release cycle, especially if InSpec is used locally on Windows. We started adding continuous Windows tests in appveyor for InSpec and Train to ensure better quality for Windows. Unfortunately we could not fix all issues for Windows 2008 this week, but we continue working on this topic during the coming week.

@chris-rock chris-rock modified the milestones: 0.9.11, 0.9.10 Jan 25, 2016
@geerzo
Copy link
Author

geerzo commented Jan 25, 2016

@chris-rock Thanks for the update. Let me know what I can do to help.

@chris-rock
Copy link
Contributor

@geerzo Okay, I analyzed the problem and I found the root cause. Our version detection uses features that require at least Powershell 3.

At this point of time I recommend to install the newer Windows Management Framework. Could you try that @geerzo in you vbox?

Current situation:

  • we are going to improve the version detection and make it independent from Powershell
  • that allows to run commands and check files via InSpec
  • it will be really hard to support windows resources on systems where Powershell is not at least in version 3

@chris-rock chris-rock modified the milestones: 0.9.12, 0.9.11, 0.9.13 Jan 29, 2016
@geerzo
Copy link
Author

geerzo commented Feb 11, 2016

@chris-rock It took a bit to get Powershell installed properly using test-kitchen but it appears as if things work much better now.

@geerzo geerzo closed this as completed Feb 11, 2016
@chris-rock
Copy link
Contributor

@geerzo Thanks for trying out the solution. Could you share how you have done it. It may helps other until we improved Windows 2008 OS Detection

@geerzo
Copy link
Author

geerzo commented Feb 12, 2016

I used this driver config in my kitchen.yml file

driver:
  name: vagrant
  provision: true
  vagrantfiles:
    - test/integration/Vagrantfile.rb

Then I created the Vagrant file to include the following

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
  config.vm.provision 'shell', inline: $script
end

$script = <<SCRIPT
$ChkFile = "C:\Windows\Temp\Windows6.1-KB2819745-x64-MultiPkg.msu"
$FileExists = Test-Path $ChkFile
If ($FileExists -eq $False) {
  (New-Object System.Net.WebClient).DownloadFile('https://download.microsoft.com/download/3/D/6/3D61D262-8549-4769-A660-230B67E15B25/Windows6.1-KB2819745-x64-MultiPkg.msu', 'C:\Windows\Temp\Windows6.1-KB2819745-x64-MultiPkg.msu')
  wusa.exe C:\Windows\Temp\Windows6.1-KB2819745-x64-MultiPkg.msu /quiet
  Start-Sleep 120
}
SCRIPT

@chris-rock
Copy link
Contributor

@geerzo Awesome, we are going to fix the version detection with inspec/train#70
Windows-specific resources like registry_key or security_policy will still require an updated Windows Management Framework, but basic resources like file and command will work out of the box then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Feature not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants