Skip to content

Commit

Permalink
Add support for log rotate on Windows (#607)
Browse files Browse the repository at this point in the history
* support for windows

* string to int

* support for windows

* each os version should point to their own repo url

* default msi url back to attributes files, only distinguish in os version and cpu architecture
  • Loading branch information
evandervecht authored and majormoses committed May 8, 2018
1 parent a4f8182 commit 703983e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
6 changes: 4 additions & 2 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
end

# installation
default["sensu"]["version"] = "0.28.4-1"
default["sensu"]["version"] = "1.2.0-1"
default["sensu"]["version_suffix"] = nil
default["sensu"]["apt_repo_codename"] = nil
default["sensu"]["yum_repo_releasever"] = nil
default["sensu"]["use_unstable_repo"] = false
default["sensu"]["log_level"] = "info"
default["sensu"]["log_rotate_file_size"] = 10240
default["sensu"]["log_rotate_file_keep"] = 10
default["sensu"]["use_ssl"] = true
default["sensu"]["use_embedded_ruby"] = true
default["sensu"]["service_max_wait"] = 10
Expand All @@ -33,8 +35,8 @@

default["sensu"]["apt_repo_url"] = "http://repositories.sensuapp.org/apt"
default["sensu"]["yum_repo_url"] = "http://repositories.sensuapp.org"
default['sensu']['msi_repo_url'] = "https://repositories.sensuapp.org/msi"
default['sensu']['yum_flush_cache'] = nil
default["sensu"]["msi_repo_url"] = "https://repositories.sensuapp.org/msi"
default["sensu"]["aix_package_root_url"] = "https://sensu.global.ssl.fastly.net/aix"
default["sensu"]["add_repo"] = true
default['sensu']['apt_key_url'] = 'https://sensu.global.ssl.fastly.net/apt/pubkey.gpg'
Expand Down
18 changes: 17 additions & 1 deletion recipes/_windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@

windows = node["sensu"]["windows"].dup

if node['kernel']['machine'] =~ /x86_64/
kernel = 'x64'
else
kernel = 'x86'
end

if node['platform_version'].to_f == 6.1
version = '2008r2'
elsif node['platform_version'].to_f == 6.2
version = '2012'
elsif node['platform_version'].to_f == 6.3
version = '2012r2'
elsif node['platform_version'].to_f == 10.0
version = '2016'
end

user node["sensu"]["user"] do
password Sensu::Helpers.random_password(20, true, true, true, true)
not_if { Sensu::Helpers.windows_user_exists?(node["sensu"]["user"]) }
Expand All @@ -35,7 +51,7 @@
end

package "Sensu" do
source "#{node['sensu']['msi_repo_url']}/sensu-#{node['sensu']['version']}.msi"
source "#{node['sensu']['msi_repo_url']}/#{version}/sensu-#{node['sensu']['version']}-#{kernel}.msi"
options windows["package_options"]
version node["sensu"]["version"].tr("-", ".")
notifies :create, "ruby_block[sensu_service_trigger]", :immediately
Expand Down
7 changes: 5 additions & 2 deletions templates/default/sensu.xml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
<argument><%= node["sensu"]["directory"] %>\conf.d</argument>
<argument>-e</argument>
<argument><%= node["sensu"]["directory"] %>\extensions</argument>
<argument>-l</argument>
<argument><%= node["sensu"]["log_directory"] %>\<%= @service %>.log</argument>
<argument>-L</argument>
<argument><%= node["sensu"]["log_level"] %></argument>
<logpath><%= node["sensu"]["log_directory"] %>\</logpath>
<log mode="roll-by-size">
<sizeThreshold><%= node["sensu"]["log_rotate_file_size"] %></sizeThreshold>
<keepFiles><%= node["sensu"]["log_rotate_file_keep"] %></keepFiles>
</log>
</service>

0 comments on commit 703983e

Please sign in to comment.