Skip to content

Commit 08962c5

Browse files
Amazon 1 tests (#35)
* created auditd test branch * don't reassign that variable * move that down a bit in the case statements * fix amazon linux repo url and auditd disabling * updated spec for yum/amazon test * use old style os fact * ensure facts are in specs * wow, okay. missed another spot. * disable auditd on rhel like oses * don't set param twice * updated readme and changelog * updated metadata * fix amazon linux 1 compatibility * fix style * make sure debian has this param defined, just in case * fix amazon linux 1 spec tests * fact wasn't defined * and another one * updated changelog, readme
1 parent cbdfcda commit 08962c5

File tree

9 files changed

+90
-29
lines changed

9 files changed

+90
-29
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
We'll track changes here starting with details about the 2.0 release and reference to earlier releases.
44

5+
## 2.0.2
6+
### Fixed
7+
- fixed amazon linux 1 support and tests
8+
59
## 2.0.1
610
### Changed
711
- added optional parameter `disable_auditd` to handle issues users reported installing on RHEL-like OSes

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Parameters
4141
* `threatstack::configure_agent` [optiona bool] - Set to false to just install agent without configuring. Useful for image building.
4242
* `threatstack::agent_config_args` [optional array of hashes] - Extra arguments to pass during agent activation. Useful for enabling new platform features.
4343
* `threatstack::disable_auditd` [optional bool] - Disable `auditd` service to avoid installation issues. (Default is 'true' on RHEL-like OSes.)
44+
* `threatstack::disable_auditd_cmd` [optional string] - related to `threatstack::disable_auditd`, the OS version dependent command to disable auditd (Default: set in `threatstack::params` based on operating system)
4445
* `threatstack::extra_args` [optional array of hashes] - optional array of hashes to define setup options for the threatstack agent (Default: `undef`)
4546
* `threatstack::confdir` [optional string] - path to config directory for the threatstack service (Default: '/opt/threatstack/etc')
4647
* `threatstack::ts_hostname` [optional string] - hostname of your node (Default: `$::fqdn`)

manifests/init.pp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# Required to work around issues with auditd on some distros
1313
# type: bool
1414
#
15+
# [*disable_auditd_cmd*]
16+
# Systemd vs. SysV init, related to above
17+
# type: string
18+
#
1519
# [*extra_args*]
1620
# Extra arguments to pass on the command line during agent activation.
1721
# type: array of hashes
@@ -80,18 +84,19 @@
8084
# Copyright 2016 Threat Stack, Inc.
8185
#
8286
class threatstack (
83-
$deploy_key = undef,
84-
$package_version = $::threatstack::params::package_version,
85-
$configure_agent = true,
86-
$extra_args = $::threatstack::params::extra_args,
87-
$agent_config_args = undef,
88-
$repo_class = $::threatstack::params::repo_class,
89-
$repo_url = $::threatstack::params::repo_url,
90-
$gpg_key = $::threatstack::params::gpg_key,
91-
$rulesets = $::threatstack::params::rulesets,
92-
$confdir = $::threatstack::params::confdir,
93-
$ts_hostname = $::fqdn,
94-
$disable_auditd = $::threatstack::params::disable_auditd
87+
$deploy_key = undef,
88+
$package_version = $::threatstack::params::package_version,
89+
$configure_agent = true,
90+
$extra_args = $::threatstack::params::extra_args,
91+
$agent_config_args = undef,
92+
$repo_class = $::threatstack::params::repo_class,
93+
$repo_url = $::threatstack::params::repo_url,
94+
$gpg_key = $::threatstack::params::gpg_key,
95+
$rulesets = $::threatstack::params::rulesets,
96+
$confdir = $::threatstack::params::confdir,
97+
$ts_hostname = $::fqdn,
98+
$disable_auditd = $::threatstack::params::disable_auditd,
99+
$disable_auditd_cmd = $::threatstack::params::disable_auditd_cmd
95100
) inherits ::threatstack::params {
96101

97102
$ts_package = $::threatstack::params::ts_package

manifests/package.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828

2929
exec { 'disable_auditd':
30-
command => '/bin/systemctl disable auditd',
30+
command => $::threatstack::disable_auditd_cmd,
3131
require => Exec['stop_auditd']
3232
}
3333

manifests/params.pp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,31 @@
3636

3737
case $facts['os']['name'] {
3838
'Amazon': {
39-
$repo_url = "https://pkg.threatstack.com/v2/Amazon/${::operatingsystemmajrelease}"
40-
}
39+
if $facts['os']['release']['major'] =~ /^201\d$/ {
40+
$releasever = '1'
41+
$disable_auditd_cmd = '/sbin/chkconfig auditd off'
42+
} else {
43+
$releasever = $facts['os']['release']['major']
44+
$disable_auditd_cmd = '/bin/systemctl disable auditd'
45+
}
46+
$repo_url = "https://pkg.threatstack.com/v2/Amazon/${releasever}"
47+
}
4148
/(CentOS|RedHat)/: {
42-
$repo_url = "https://pkg.threatstack.com/v2/EL/${::operatingsystemmajrelease}"
43-
}
49+
$repo_url = "https://pkg.threatstack.com/v2/EL/${::operatingsystemmajrelease}"
50+
$disable_auditd_cmd = '/bin/systemctl disable auditd'
51+
}
4452
default: { fail("Module ${module_name} does not support ${::operatingsystem}") }
4553
}
4654
}
4755
'Debian': {
48-
$repo_class = '::threatstack::apt'
49-
$repo_url = 'https://pkg.threatstack.com/v2/Ubuntu'
50-
$repo_gpg_id = 'ACCC2B02EA3A2409557B0AB991BB3B3C6EE04BD4'
51-
$release = $facts['os']['distro']['codename']
52-
$repos = 'main'
53-
$gpg_key = 'https://app.threatstack.com/APT-GPG-KEY-THREATSTACK'
54-
$disable_auditd = false
56+
$repo_class = '::threatstack::apt'
57+
$repo_url = 'https://pkg.threatstack.com/v2/Ubuntu'
58+
$repo_gpg_id = 'ACCC2B02EA3A2409557B0AB991BB3B3C6EE04BD4'
59+
$release = $facts['os']['distro']['codename']
60+
$repos = 'main'
61+
$gpg_key = 'https://app.threatstack.com/APT-GPG-KEY-THREATSTACK'
62+
$disable_auditd = false
63+
$disable_auditd_cmd = '/bin/systemctl disable auditd'
5564
}
5665
default: {
5766
fail("Module ${module_name} does not support ${::operatingsystem}")

spec/classes/configure_spec.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
)}
6060
end
6161

62-
context 'on Amazon Linux' do
62+
context 'on Amazon Linux 2' do
6363
let(:facts) { {'operatingsystemmajrelease' => '2', 'os' => { 'release' => { 'major' => '2'}, 'name' => 'Amazon', 'family' => 'RedHat'} } }
6464
let(:pre_condition) { "class { 'threatstack': deploy_key => '#{deploy_key}', ts_hostname => '#{ts_hostname}', rulesets => ['Default Ruleset', 'Service Ruleset'], agent_config_args => [{'log.level' => 'debug'}]}" }
6565

@@ -68,4 +68,13 @@
6868
)}
6969
end
7070

71+
context 'on Amazon Linux 1' do
72+
let(:facts) { {'operatingsystemmajrelease' => '2018', 'os' => { 'release' => { 'major' => '2018'}, 'name' => 'Amazon', 'family' => 'RedHat'} } }
73+
let(:pre_condition) { "class { 'threatstack': deploy_key => '#{deploy_key}', ts_hostname => '#{ts_hostname}', rulesets => ['Default Ruleset', 'Service Ruleset'], agent_config_args => [{'log.level' => 'debug'}]}" }
74+
75+
it { should contain_exec('threatstack-agent-setup').with(
76+
:command => "/usr/bin/tsagent setup --deploy-key='#{deploy_key}' --hostname='#{ts_hostname}' --ruleset='Default Ruleset' --ruleset='Service Ruleset'"
77+
)}
78+
end
79+
7180
end

spec/classes/init_spec.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060

6161
end
6262

63-
context 'on Amazon' do
64-
let(:facts) { { 'operatingsystemmajrelease' => '2', 'os' => { 'name' => 'Amazon', 'family' => 'RedHat'} } }
63+
context 'on Amazon Linux 2' do
64+
let(:facts) { { 'operatingsystemmajrelease' => '2', 'os' => { 'name' => 'Amazon', 'family' => 'RedHat', 'release' => { 'major' => '2'}} } }
6565
let(:params) { { :deploy_key => "#{deploy_key}" } }
6666

6767
it 'should compile' do should create_class('threatstack') end
@@ -71,5 +71,15 @@
7171
end
7272

7373

74+
context 'on Amazon Linux 1' do
75+
let(:facts) { { 'operatingsystemmajrelease' => '2018', 'os' => { 'name' => 'Amazon', 'family' => 'RedHat', 'release' => { 'major' => '2018'}} } }
76+
let(:params) { { :deploy_key => "#{deploy_key}" } }
77+
78+
it 'should compile' do should create_class('threatstack') end
79+
it { should contain_class('threatstack::package') }
80+
it { should contain_class('threatstack::configure') }
81+
82+
end
83+
7484

7585
end

spec/classes/package_spec.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
end
2222
end
2323

24-
context 'on Amazon Linux' do
24+
context 'on Amazon Linux 2' do
2525
let(:facts) { {'operatingsystemmajrelease' => '2', 'os' => { 'release' => { 'major' => '2'}, 'name' => 'Amazon', 'family' => 'RedHat'} } }
2626
let(:pre_condition) { "class { 'threatstack': deploy_key => '#{deploy_key}', gpg_key => 'https://app.threatstack.com/RPM-GPG-KEY-THREATSTACK', repo_class => '::threatstack::yum' }" }
2727

@@ -30,6 +30,15 @@
3030
end
3131
end
3232

33+
context 'on Amazon Linux 1' do
34+
let(:facts) { {'operatingsystemmajrelease' => '1', 'os' => { 'release' => { 'major' => '1'}, 'name' => 'Amazon', 'family' => 'RedHat'} } }
35+
let(:pre_condition) { "class { 'threatstack': deploy_key => '#{deploy_key}', gpg_key => 'https://app.threatstack.com/RPM-GPG-KEY-THREATSTACK', repo_class => '::threatstack::yum' }" }
36+
37+
context 'package' do
38+
it { should contain_package('threatstack-agent').with_ensure('installed') }
39+
end
40+
end
41+
3342
context 'on Debian 8' do
3443
let(:facts) { {'osfamily' => 'Debian', 'os' => { 'name' => 'Debian', 'release' => {'full' => '8.11', 'major' => '8', 'minor' => '11'}, 'distro' => {'codename' => 'jessie'}, 'family' => 'Debian'} } }
3544
let(:pre_condition) { "class { 'threatstack': deploy_key => '#{deploy_key}', gpg_key => 'https://app.threatstack.com/APT-GPG-KEY-THREATSTACK', repo_class => '::threatstack::apt' }" }

spec/classes/yum_spec.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
end
3636
end
3737

38-
context 'on Amazon' do
38+
context 'on Amazon Linux 2' do
3939
let(:facts) { {'operatingsystemmajrelease' => '2', 'os' => { 'release' => { 'major' => '2'}, 'name' => 'Amazon', 'family' => 'RedHat'} } }
4040
let(:pre_condition) { "class { 'threatstack': deploy_key => '#{deploy_key}', gpg_key => 'https://app.threatstack.com/RPM-GPG-KEY-THREATSTACK' }" }
4141

@@ -50,4 +50,18 @@
5050
end
5151
end
5252

53+
context 'on Amazon Linux 1' do
54+
let(:facts) { {'operatingsystemmajrelease' => '2018', 'os' => { 'release' => { 'major' => '2018'}, 'name' => 'Amazon', 'family' => 'RedHat'} } }
55+
let(:pre_condition) { "class { 'threatstack': deploy_key => '#{deploy_key}', gpg_key => 'https://app.threatstack.com/RPM-GPG-KEY-THREATSTACK' }" }
56+
57+
context 'default' do
58+
it { should contain_yumrepo('threatstack').with(
59+
:descr => 'Threat Stack Package Repository',
60+
:enabled => 1,
61+
:baseurl => 'https://pkg.threatstack.com/v2/Amazon/1',
62+
:gpgcheck => 1,
63+
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-THREATSTACK'
64+
) }
65+
end
66+
end
5367
end

0 commit comments

Comments
 (0)