diff --git a/README.md b/README.md index b4c8454..be4c421 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Supports - ubuntu - mac_os_x - solaris +- windows Usage ===== diff --git a/libraries/omnitrucker.rb b/libraries/omnitrucker.rb index 0179dd3..26ec00d 100644 --- a/libraries/omnitrucker.rb +++ b/libraries/omnitrucker.rb @@ -72,6 +72,8 @@ def collect_attributes(node, args={}) @attrs = {:platform => set[:platform], :platform_version => set[:platform_version].to_i} elsif(set[:platform_family] == 'mac_os_x') @attrs = {:platform => set[:platform_family], :platform_version => [set[:platform_version].to_f, 10.7].min} + elsif(set[:platform_family] == 'windows') + @attrs ={:platform => set[:platform], :platform_version => '2008r2'} else @attrs = {:platform => set[:platform], :platform_version => set[:platform_version]} end diff --git a/metadata.rb b/metadata.rb index 0d642ed..88e5248 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,6 +6,9 @@ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version "1.0.7" -%w(redhat centos amazon scientific oracle debian ubuntu mac_os_x solaris).each do |plat| +%w(redhat centos amazon scientific oracle debian ubuntu mac_os_x solaris windows).each do |plat| supports plat end + +source_url 'https://github.com/hw-cookbooks/omnibus_updater' if respond_to?(:source_url) +issues_url 'https://github.com/hw-cookbooks/omnibus_updater/issues' if respond_to?(:issues_url) diff --git a/recipes/downloader.rb b/recipes/downloader.rb index 5b3d2b8..064e0ab 100644 --- a/recipes/downloader.rb +++ b/recipes/downloader.rb @@ -47,7 +47,12 @@ action :create_if_missing only_if do unless(version = node[:omnibus_updater][:version]) - version = node[:omnibus_updater][:full_url].scan(%r{chef[_-](\d+\.\d+.\d+)}).flatten.first + case node['platform_family'] + when 'windows' + version = node[:omnibus_updater][:full_url].scan(%r{chef-windows|client-(\d+\.\d+.\d+)}).flatten.first + else + version = node[:omnibus_updater][:full_url].scan(%r{chef[_-](\d+\.\d+.\d+)}).flatten.first + end end if(node[:omnibus_updater][:always_download]) # warn if there may be unexpected behavior diff --git a/recipes/installer.rb b/recipes/installer.rb index bfea578..c242cde 100644 --- a/recipes/installer.rb +++ b/recipes/installer.rb @@ -20,51 +20,59 @@ include_recipe 'omnibus_updater' remote_path = node[:omnibus_updater][:full_url].to_s -file '/tmp/nocheck' do - content 'conflict=nocheck\naction=nocheck' - only_if { node['os'] =~ /^solaris/ } -end +if(node[:platform] == 'windows') + version = node[:omnibus_updater][:version] || remote_path.scan(%r{chef-windows|client-(\d+\.\d+.\d+)}).flatten.first -service 'chef-client' do - action :nothing -end + windows_package "Chef Client v#{version}" do + source remote_path + end +else + file '/tmp/nocheck' do + content 'conflict=nocheck\naction=nocheck' + only_if { node['os'] =~ /^solaris/ } + end -ruby_block 'omnibus chef killer' do - block do - raise 'New omnibus chef version installed. Killing Chef run!' + service 'chef-client' do + action :nothing end - action :nothing - only_if do - node[:omnibus_updater][:kill_chef_on_upgrade] + + ruby_block 'omnibus chef killer' do + block do + raise 'New omnibus chef version installed. Killing Chef run!' + end + action :nothing + only_if do + node[:omnibus_updater][:kill_chef_on_upgrade] + end end -end -execute "omnibus_install[#{File.basename(remote_path)}]" do - case File.extname(remote_path) - when '.deb' - command "dpkg -i #{File.join(node[:omnibus_updater][:cache_dir], File.basename(remote_path))}" - when '.rpm' - command "rpm -Uvh --oldpackage #{File.join(node[:omnibus_updater][:cache_dir], File.basename(remote_path))}" - when '.sh' - command "/bin/sh #{File.join(node[:omnibus_updater][:cache_dir], File.basename(remote_path))}" - when '.solaris' - command "pkgadd -n -d #{File.join(node[:omnibus_updater][:cache_dir], File.basename(remote_path))} -a /tmp/nocheck chef" - else - raise "Unknown package type encountered for install: #{File.extname(remote_path)}" + execute "omnibus_install[#{File.basename(remote_path)}]" do + case File.extname(remote_path) + when '.deb' + command "dpkg -i #{File.join(node[:omnibus_updater][:cache_dir], File.basename(remote_path))}" + when '.rpm' + command "rpm -Uvh --oldpackage #{File.join(node[:omnibus_updater][:cache_dir], File.basename(remote_path))}" + when '.sh' + command "/bin/sh #{File.join(node[:omnibus_updater][:cache_dir], File.basename(remote_path))}" + when '.solaris' + command "pkgadd -n -d #{File.join(node[:omnibus_updater][:cache_dir], File.basename(remote_path))} -a /tmp/nocheck chef" + else + raise "Unknown package type encountered for install: #{File.extname(remote_path)}" + end + action :nothing + if(node[:omnibus_updater][:restart_chef_service]) + notifies :restart, resources(:service => 'chef-client'), :immediately + end + notifies :create, resources(:ruby_block => 'omnibus chef killer'), :immediately end - action :nothing - if(node[:omnibus_updater][:restart_chef_service]) - notifies :restart, resources(:service => 'chef-client'), :immediately + + ruby_block 'Omnibus Chef install notifier' do + block{ true } + action :nothing + subscribes :create, resources(:remote_file => "omnibus_remote[#{File.basename(remote_path)}]"), :immediately + notifies :run, resources(:execute => "omnibus_install[#{File.basename(remote_path)}]"), :delayed + only_if { node['chef_packages']['chef']['version'] != node['omnibus_updater']['version'] } end - notifies :create, resources(:ruby_block => 'omnibus chef killer'), :immediately -end -ruby_block 'Omnibus Chef install notifier' do - block{ true } - action :nothing - subscribes :create, resources(:remote_file => "omnibus_remote[#{File.basename(remote_path)}]"), :immediately - notifies :run, resources(:execute => "omnibus_install[#{File.basename(remote_path)}]"), :delayed - only_if { node['chef_packages']['chef']['version'] != node['omnibus_updater']['version'] } + include_recipe 'omnibus_updater::old_package_cleaner' end - -include_recipe 'omnibus_updater::old_package_cleaner'