Skip to content

Commit

Permalink
Merge pull request #282 from martijndegouw/freebsd
Browse files Browse the repository at this point in the history
Add support for FreeBSD
  • Loading branch information
bastelfreak authored Nov 3, 2020
2 parents 0bb6189 + 7e25b78 commit 48b5d9c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manifests/forwarder.pp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
# This is a module that supports multiple platforms. For some platforms
# there is non-generic configuration that needs to be declared in addition
# to the agnostic resources declared here.
if $facts['kernel'] in ['Linux', 'SunOS'] {
if $facts['kernel'] in ['Linux', 'SunOS', 'FreeBSD'] {
contain 'splunk::forwarder::service::nix'
Class['splunk::forwarder::config']
-> Class['splunk::forwarder::service::nix']
Expand Down
27 changes: 27 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,27 @@
$supports_systemd = false
}
}
'FreeBSD': {
$path_delimiter = '/'
$forwarder_src_subdir = 'freebsd'
$forwarder_seed_config_file = "${forwarder_homedir}/etc/system/local/user-seed.conf"
$enterprise_seed_config_file = "${enterprise_homedir}/etc/system/local/user-seed.conf"
$forwarder_password_config_file = "${forwarder_homedir}/etc/passwd"
$enterprise_password_config_file = "${enterprise_homedir}/etc/passwd"
$forwarder_secret_file = "${forwarder_homedir}/etc/splunk.secret"
$enterprise_secret_file = "${enterprise_homedir}/etc/splunk.secret"
$forwarder_confdir = "${forwarder_homedir}/etc"
$enterprise_src_subdir = 'freebsd'
$enterprise_confdir = "${enterprise_homedir}/etc"
$forwarder_install_options = ['-f'] # ignore the wrong os major version specified in the package
$enterprise_install_options = []
$enterprise_service = 'splunk'
$forwarder_service = 'splunk'
$enterprise_service_file = '/etc/rc.d/splunk'
$forwarder_service_file = '/etc/rc.d/splunk'
$boot_start_args = ''
$supports_systemd = false
}
'windows': {
$path_delimiter = '\\'
$forwarder_src_subdir = 'windows'
Expand Down Expand Up @@ -261,6 +282,7 @@
'Debian': { $package_provider = 'dpkg' }
'Solaris': { $package_provider = 'sun' }
'Suse': { $package_provider = 'rpm' }
'FreeBSD': { $package_provider = 'pkgng' }
'windows': { $package_provider = 'windows' }
default: { $package_provider = undef } # Don't define a $package_provider
}
Expand Down Expand Up @@ -317,6 +339,11 @@
$forwarder_package_name = 'splunkforwarder'
$enterprise_package_name = 'splunk'
}
'FreeBSD amd64': {
$package_suffix = "${version}-${build}-freebsd-11.1-amd64.txz"
$forwarder_package_name = 'splunkforwarder'
$enterprise_package_name = 'splunk'
}
default: { fail("unsupported osfamily/arch ${facts['os']['family']}/${facts['os']['architecture']}") }
}

Expand Down
6 changes: 6 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
"12"
]
},
{
"operatingsystem": "FreeBSD",
"operatingsystemrelease": [
"12"
]
},
{
"operatingsystem": "Windows",
"operatingsystemrelease": [
Expand Down
14 changes: 10 additions & 4 deletions spec/classes/forwarder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,24 @@

context 'when forwarder not already installed' do
let(:facts) do
facts.merge(splunkforwarder_version: nil, service_provider: 'systemd')
facts.merge(splunkforwarder_version: nil, service_provider: facts[:kernel] == 'FreeBSD' ? 'freebsd' : 'systemd')
end
let(:pre_condition) do
"class { 'splunk::params': version => '7.2.2' }"
end
let(:accept_tos_command) do
'/opt/splunkforwarder/bin/splunk stop && /opt/splunkforwarder/bin/splunk start --accept-license --answer-yes && /opt/splunkforwarder/bin/splunk stop'
end
let(:service_name) do
facts[:kernel] == 'FreeBSD' ? 'splunk' : 'SplunkForwarder'
end

it_behaves_like 'splunk forwarder'
it do
is_expected.to contain_exec('splunk-forwarder-accept-tos').with(
command: accept_tos_command,
user: 'root',
before: 'Service[SplunkForwarder]',
before: "Service[#{service_name}]",
subscribe: nil,
require: 'Exec[enable_splunkforwarder]',
refreshonly: 'true'
Expand All @@ -255,21 +258,24 @@

context 'when forwarder already installed' do
let(:facts) do
facts.merge(splunkforwarder_version: '7.3.3', service_provider: 'systemd')
facts.merge(splunkforwarder_version: '7.3.3', service_provider: facts[:kernel] == 'FreeBSD' ? 'freebsd' : 'systemd')
end
let(:pre_condition) do
"class { 'splunk::params': version => '7.2.2' }"
end
let(:accept_tos_command) do
'/opt/splunkforwarder/bin/splunk stop && /opt/splunkforwarder/bin/splunk start --accept-license --answer-yes && /opt/splunkforwarder/bin/splunk stop'
end
let(:service_name) do
facts[:kernel] == 'FreeBSD' ? 'splunk' : 'SplunkForwarder'
end

it_behaves_like 'splunk forwarder'
it do
is_expected.to contain_exec('splunk-forwarder-accept-tos').with(
command: accept_tos_command,
user: 'root',
before: 'Service[SplunkForwarder]',
before: "Service[#{service_name}]",
subscribe: 'Package[splunkforwarder]',
require: 'Exec[enable_splunkforwarder]',
refreshonly: 'true'
Expand Down

0 comments on commit 48b5d9c

Please sign in to comment.