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

WIP: allow injecting of arbitrary env variables #629

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ cookbook. Please see HISTORY.md for changes from older versions of this project.

## [Unreleased]

### Security
- locked down permissions of `/etc/default/sensu` to be owned and grouped by `root` and to only be readable or writable by its owner (@majormoses)

### Added
- support for injecting arbitrary env vars into `/etc/default/sensu` (@majormoses)

## [5.4.0] - 2018-09-14
### Added
- exposed `package_name` as an optional parameter to the `sensu_gem` resource in case you need to install multiple versions of a gem. (@majormoses)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ for Sensu to start/stop.

`node["sensu"]["loaded_tempfile_dir"]` - Where Sensu stores temporary files. Set a persistent directory if you use hardened system that cleans temporary directory regularly.

`node['sensu']['env_vars]` - A hash of key value pairs that will be written to `/etc/default/sensu` which will be passed to the sensu proces as ENV vars. This defaults to `nil` and only triggers when it is not `nil`.

`node['sensu']['etc_default_sensu']['cookbook']` - A string that allows you to choose the cookbook that you wish to pull the template for writing `/etc/default/sensu` from, this is useful in the case of wanting to write your own template in your wrapper cookbook. This defaults to `'sensu'` which is this cookbook.

### Windows

Sensu requires Microsoft's .Net Framework to run on Windows. The following attributes influence the installation of .Net via this cookbook:
Expand Down
4 changes: 4 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@
default["sensu"]["data_bag"]["ssl_item"] = "ssl"
default["sensu"]["data_bag"]["config_item"] = "config"
default["sensu"]["data_bag"]["enterprise_item"] = "enterprise"

# inject arbitrary env vars into the sensu process
default['sensu']['env_vars'] = nil
default['sensu']['etc_default_sensu']['cookbook'] = 'sensu'
4 changes: 4 additions & 0 deletions recipes/_linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,9 @@

template "/etc/default/sensu" do
source "sensu.default.erb"
cookbook node['sensu']['etc_default_sensu']['cookbook']
mode '400'
user 'root'
group 'root'
notifies :create, "ruby_block[sensu_service_trigger]"
end
5 changes: 5 additions & 0 deletions templates/default/sensu.default.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ SERVICE_MAX_WAIT=<%= node["sensu"]["service_max_wait"] %>
CLIENT_DEREGISTER_ON_STOP=<%= node["sensu"]["client_deregister_on_stop"] %>
<%= node["sensu"]["client_deregister_handler"] ? %|CLIENT_DEREGISTER_HANDLER=#{node["sensu"]["client_deregister_handler"]}| : nil %>
<%= node["sensu"]["loaded_tempfile_dir"] ? %|export SENSU_LOADED_TEMPFILE_DIR=#{node["sensu"]["loaded_tempfile_dir"]}| : nil %>

<% unless node['sensu']['env_vars'].nil? do |k, v| -%>
<%= k %>=<%= v %>
<% end %>
<% end %>