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

Update to beta and add runtime_assets to sensu_handler and sensu_mutator #1001

Merged
merged 2 commits into from
Oct 29, 2018
Merged
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
5 changes: 5 additions & 0 deletions lib/puppet/type/sensu_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
defaultto 'default'
end

newproperty(:runtime_assets, :array_matching => :all, :parent => PuppetX::Sensu::ArrayProperty) do
desc "An array of Sensu assets (names), required at runtime for the execution of the command"
newvalues(/.*/, :absent)
end

newproperty(:socket_host) do
desc "The socket host address (IP or hostname) to connect to."
end
Expand Down
5 changes: 5 additions & 0 deletions lib/puppet/type/sensu_mutator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
newvalues(/^[0-9]+$/, :absent)
end

newproperty(:runtime_assets, :array_matching => :all, :parent => PuppetX::Sensu::ArrayProperty) do
desc "An array of Sensu assets (names), required at runtime for the execution of the command"
newvalues(/.*/, :absent)
end

newproperty(:env_vars, :array_matching => :all, :parent => PuppetX::Sensu::ArrayProperty) do
desc "An array of environment variables to use with command execution."
newvalues(/.*/, :absent)
Expand Down
14 changes: 7 additions & 7 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@
} else {
$repo_release = $facts['os']['release']['major']
}
# TODO: change from nightly to stable once there are stable releases
# TODO: change from beta to stable once there are stable releases
yumrepo { 'sensu':
descr => 'sensu',
baseurl => "https://packagecloud.io/sensu/nightly/el/${repo_release}/\$basearch",
baseurl => "https://packagecloud.io/sensu/beta/el/${repo_release}/\$basearch",
repo_gpgcheck => 1,
gpgcheck => 0,
enabled => 1,
gpgkey => 'https://packagecloud.io/sensu/nightly/gpgkey',
gpgkey => 'https://packagecloud.io/sensu/beta/gpgkey',
sslverify => 1,
sslcacert => '/etc/pki/tls/certs/ca-bundle.crt',
metadata_expire => 300,
}
}
'Debian': {
#TODO: change from nightly to stable once there are stable releases
#TODO: change from beta to stable once there are stable releases
apt::source { 'sensu':
ensure => 'present',
location => "https://packagecloud.io/sensu/nightly/${downcase($facts['os']['name'])}/",
location => "https://packagecloud.io/sensu/beta/${downcase($facts['os']['name'])}/",
repos => 'main',
release => $facts['os']['distro']['codename'],
include => {
'src' => true,
},
key => {
'id' => 'EB17E7F42AD4720A6679044309F9A5D85A56B390',
'source' => 'https://packagecloud.io/sensu/nightly/gpgkey',
'id' => '0B3B86AFEF2D99B085BEDC6A4263180AAE8AAE03',
'source' => 'https://packagecloud.io/sensu/beta/gpgkey',
},
}
}
Expand Down
22 changes: 13 additions & 9 deletions spec/acceptance/sensu_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
pp = <<-EOS
include ::sensu::backend
sensu_handler { 'test':
type => 'pipe',
command => 'notify.rb',
socket_host => '127.0.0.1',
socket_port => 1234,
type => 'pipe',
command => 'notify.rb',
socket_host => '127.0.0.1',
socket_port => 1234,
runtime_assets => ['test'],
}
EOS

Expand All @@ -24,6 +25,7 @@
data = JSON.parse(stdout)
expect(data['command']).to eq('notify.rb')
expect(data['socket']).to eq({'host' => '127.0.0.1', 'port' => 1234})
expect(data['runtime_assets']).to eq(['test'])
end
end
end
Expand All @@ -33,11 +35,12 @@
pp = <<-EOS
include ::sensu::backend
sensu_handler { 'test':
type => 'pipe',
command => 'notify.rb',
filters => ['production'],
socket_host => 'localhost',
socket_port => 5678,
type => 'pipe',
command => 'notify.rb',
filters => ['production'],
socket_host => 'localhost',
socket_port => 5678,
runtime_assets => ['test2'],
}
EOS

Expand All @@ -51,6 +54,7 @@
data = JSON.parse(stdout)
expect(data['filters']).to eq(['production'])
expect(data['socket']).to eq({'host' => 'localhost', 'port' => 5678})
expect(data['runtime_assets']).to eq(['test2'])
end
end
end
Expand Down
10 changes: 7 additions & 3 deletions spec/acceptance/sensu_mutator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
pp = <<-EOS
include ::sensu::backend
sensu_mutator { 'test':
command => 'test',
command => 'test',
runtime_assets => ['test'],
}
EOS

Expand All @@ -20,6 +21,7 @@
on node, 'sensuctl mutator info test --format json' do
data = JSON.parse(stdout)
expect(data['command']).to eq('test')
expect(data['runtime_assets']).to eq(['test'])
end
end
end
Expand All @@ -29,8 +31,9 @@
pp = <<-EOS
include ::sensu::backend
sensu_mutator { 'test':
command => 'test',
timeout => 60,
command => 'test',
timeout => 60,
runtime_assets => ['test2'],
}
EOS

Expand All @@ -43,6 +46,7 @@
on node, 'sensuctl mutator info test --format json' do
data = JSON.parse(stdout)
expect(data['timeout']).to eq(60)
expect(data['runtime_assets']).to eq(['test2'])
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/classes/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
let(:facts) { facts }
case os
when /(redhat-6|centos-6|amazon-2017|amazon-2018)-x86_64/
baseurl = "https://packagecloud.io/sensu/nightly/el/6/$basearch"
baseurl = "https://packagecloud.io/sensu/beta/el/6/$basearch"
when /(redhat-7|centos-7|amazonlinux-2)-x86_64/
baseurl = "https://packagecloud.io/sensu/nightly/el/7/$basearch"
baseurl = "https://packagecloud.io/sensu/beta/el/7/$basearch"
else
baseurl = nil
end
Expand All @@ -20,7 +20,7 @@
'repo_gpgcheck' => 1,
'gpgcheck' => 0,
'enabled' => 1,
'gpgkey' => 'https://packagecloud.io/sensu/nightly/gpgkey',
'gpgkey' => 'https://packagecloud.io/sensu/beta/gpgkey',
'sslverify' => 1,
'sslcacert' => '/etc/pki/tls/certs/ca-bundle.crt',
'metadata_expire' => 300,
Expand All @@ -30,13 +30,13 @@
it {
should contain_apt__source('sensu').with({
'ensure' => 'present',
'location' => "https://packagecloud.io/sensu/nightly/#{facts[:os]['name'].downcase}/",
'location' => "https://packagecloud.io/sensu/beta/#{facts[:os]['name'].downcase}/",
'repos' => 'main',
'release' => facts[:os]['distro']['codename'],
'include' => { 'src' => 'true' },
'key' => {
'id' => 'EB17E7F42AD4720A6679044309F9A5D85A56B390',
'source' => 'https://packagecloud.io/sensu/nightly/gpgkey',
'id' => '0B3B86AFEF2D99B085BEDC6A4263180AAE8AAE03',
'source' => 'https://packagecloud.io/sensu/beta/gpgkey',
},
})
}
Expand Down
1 change: 1 addition & 0 deletions spec/unit/sensu_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
:filters,
:env_vars,
:handlers,
:runtime_assets,
].each do |property|
it "should accept valid #{property}" do
config[property] = ['foo', 'bar']
Expand Down
3 changes: 2 additions & 1 deletion spec/unit/sensu_mutator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@

# Array properties
[
:env_vars
:env_vars,
:runtime_assets,
].each do |property|
it "should accept valid #{property}" do
config[property] = ['foo', 'bar']
Expand Down