Skip to content

Commit 4fe1532

Browse files
authored
Merge pull request #209 from beezly/feature/fix_unmanged_repos
Add the ability to override package_source
2 parents aa42444 + 4364238 commit 4fe1532

File tree

5 files changed

+116
-63
lines changed

5 files changed

+116
-63
lines changed

manifests/forwarder.pp

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
# [*server*]
99
# The address of a server to send logs to.
1010
#
11+
# [*manage_package_source*]
12+
# By default, this class will handle downloading the Splunk module you need
13+
# but you can set this to false if you do not want that behaviour
14+
#
1115
# [*package_source*]
1216
# The source URL for the splunk installation media (typically an RPM, MSI,
1317
# etc). If a $src_root parameter is set in splunk::params, this will be
@@ -51,43 +55,50 @@
5155
# Requires: nothing
5256
#
5357
class splunk::forwarder (
54-
$server = $splunk::params::server,
55-
$package_source = $splunk::params::forwarder_pkg_src,
56-
$package_name = $splunk::params::forwarder_pkg_name,
57-
$package_ensure = $splunk::params::forwarder_pkg_ensure,
58-
$logging_port = $splunk::params::logging_port,
59-
$splunkd_port = $splunk::params::splunkd_port,
60-
$install_options = $splunk::params::forwarder_install_options,
61-
$splunk_user = $splunk::params::splunk_user,
62-
$splunkd_listen = '127.0.0.1',
63-
$purge_deploymentclient = false,
64-
$purge_inputs = false,
65-
$purge_outputs = false,
66-
$purge_props = false,
67-
$purge_transforms = false,
68-
$purge_web = false,
69-
$pkg_provider = $splunk::params::pkg_provider,
70-
$forwarder_confdir = $splunk::params::forwarder_confdir,
71-
$forwarder_output = $splunk::params::forwarder_output,
72-
$forwarder_input = $splunk::params::forwarder_input,
73-
$create_password = $splunk::params::create_password,
74-
$addons = {},
58+
String $server = $splunk::params::server,
59+
Boolean $manage_package_source = true,
60+
Optional[String] $package_source = undef,
61+
String $package_name = $splunk::params::forwarder_pkg_name,
62+
String $package_ensure = $splunk::params::forwarder_pkg_ensure,
63+
Stdlib::Port $logging_port = $splunk::params::logging_port,
64+
Stdlib::Port $splunkd_port = $splunk::params::splunkd_port,
65+
Optional[Array] $install_options = $splunk::params::forwarder_install_options,
66+
String $splunk_user = $splunk::params::splunk_user,
67+
Stdlib::Host $splunkd_listen = '127.0.0.1',
68+
Boolean $purge_deploymentclient = false,
69+
Boolean $purge_inputs = false,
70+
Boolean $purge_outputs = false,
71+
Boolean $purge_props = false,
72+
Boolean $purge_transforms = false,
73+
Boolean $purge_web = false,
74+
Optional[String] $pkg_provider = $splunk::params::pkg_provider,
75+
String $forwarder_confdir = $splunk::params::forwarder_confdir,
76+
Hash $forwarder_output = $splunk::params::forwarder_output,
77+
Hash $forwarder_input = $splunk::params::forwarder_input,
78+
Boolean $create_password = $splunk::params::create_password,
79+
Hash $addons = {},
7580
) inherits splunk::params {
7681

7782
$virtual_service = $splunk::params::forwarder_service
7883
$staging_subdir = $splunk::params::staging_subdir
7984

8085
$path_delimiter = $splunk::params::path_delimiter
86+
87+
$_package_source = $manage_package_source ? {
88+
true => $splunk::params::forwarder_pkg_src,
89+
false => $package_source,
90+
}
91+
8192
#no need for staging the source if we have yum or apt
8293
if $pkg_provider != undef and $pkg_provider != 'yum' and $pkg_provider != 'apt' and $pkg_provider != 'chocolatey' {
8394
include ::archive::staging
8495

85-
$src_pkg_filename = basename($package_source)
96+
$src_pkg_filename = basename($_package_source)
8697
$pkg_path_parts = [$archive::path, $staging_subdir, $src_pkg_filename]
8798
$staged_package = join($pkg_path_parts, $path_delimiter)
8899

89100
archive { $staged_package:
90-
source => $package_source,
101+
source => $_package_source,
91102
extract => false,
92103
before => Package[$package_name],
93104
}
@@ -98,7 +109,10 @@
98109
Package {
99110
source => $pkg_provider ? {
100111
'chocolatey' => undef,
101-
default => pick($staged_package, $package_source),
112+
default => $manage_package_source ? {
113+
true => pick($staged_package, $_package_source),
114+
false => $_package_source,
115+
}
102116
},
103117
}
104118

manifests/init.pp

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#
55
# Parameters:
66
#
7+
# [*manage_package_source*]
8+
# By default, this class will handle downloading the Splunk module you need
9+
# but you can set this to false if you do not want that behaviour
10+
#
711
# [*package_source*]
812
# The source URL for the splunk installation media (typically an RPM, MSI,
913
# etc). If a $src_root parameter is set in splunk::params, this will be
@@ -44,57 +48,66 @@
4448
# Requires: nothing
4549
#
4650
class splunk (
47-
$package_source = $splunk::params::server_pkg_src,
48-
$package_name = $splunk::params::server_pkg_name,
49-
$package_ensure = $splunk::params::server_pkg_ensure,
50-
$server_service = $splunk::params::server_service,
51-
$logging_port = $splunk::params::logging_port,
52-
$splunkd_port = $splunk::params::splunkd_port,
53-
$splunk_user = $splunk::params::splunk_user,
54-
$pkg_provider = $splunk::params::pkg_provider,
55-
$splunkd_listen = '127.0.0.1',
56-
$web_port = '8000',
57-
$purge_alert_actions = false,
58-
$purge_authentication = false,
59-
$purge_authorize = false,
60-
$purge_deploymentclient = false,
61-
$purge_distsearch = false,
62-
$purge_indexes = false,
63-
$purge_inputs = false,
64-
$purge_limits = false,
65-
$purge_outputs = false,
66-
$purge_props = false,
67-
$purge_server = false,
68-
$purge_serverclass = false,
69-
$purge_transforms = false,
70-
$purge_uiprefs = false,
71-
$purge_web = false,
51+
Boolean $manage_package_source = true,
52+
Optional[String] $package_source = undef,
53+
String $package_name = $splunk::params::server_pkg_name,
54+
String $package_ensure = $splunk::params::server_pkg_ensure,
55+
Variant[Array[String],String] $server_service = $splunk::params::server_service,
56+
Stdlib::Port $logging_port = $splunk::params::logging_port,
57+
Stdlib::Port $splunkd_port = $splunk::params::splunkd_port,
58+
String $splunk_user = $splunk::params::splunk_user,
59+
Optional[String] $pkg_provider = $splunk::params::pkg_provider,
60+
Stdlib::Host $splunkd_listen = '127.0.0.1',
61+
Stdlib::Port $web_port = 8000,
62+
Boolean $purge_alert_actions = false,
63+
Boolean $purge_authentication = false,
64+
Boolean $purge_authorize = false,
65+
Boolean $purge_deploymentclient = false,
66+
Boolean $purge_distsearch = false,
67+
Boolean $purge_indexes = false,
68+
Boolean $purge_inputs = false,
69+
Boolean $purge_limits = false,
70+
Boolean $purge_outputs = false,
71+
Boolean $purge_props = false,
72+
Boolean $purge_server = false,
73+
Boolean $purge_serverclass = false,
74+
Boolean $purge_transforms = false,
75+
Boolean $purge_uiprefs = false,
76+
Boolean $purge_web = false,
7277
) inherits splunk::params {
7378

7479
$virtual_service = $server_service
7580
$staging_subdir = $splunk::params::staging_subdir
7681

7782
$path_delimiter = $splunk::params::path_delimiter
7883

84+
$_package_source = $manage_package_source ? {
85+
true => $splunk::params::server_pkg_src,
86+
false => $package_source
87+
}
88+
7989
if $pkg_provider != undef and $pkg_provider != 'yum' and $pkg_provider != 'apt' and $pkg_provider != 'chocolatey' {
8090
include ::archive::staging
81-
$src_pkg_filename = basename($package_source)
91+
$src_pkg_filename = basename($_package_source)
8292
$pkg_path_parts = [$archive::path, $staging_subdir, $src_pkg_filename]
8393
$staged_package = join($pkg_path_parts, $path_delimiter)
8494

8595
archive { $staged_package:
86-
source => $package_source,
96+
source => $_package_source,
8797
extract => false,
8898
before => Package[$package_name],
8999
}
90100
} else {
91101
$staged_package = undef
92102
}
93103

94-
Package {
95-
source => $pkg_provider ? {
104+
Package {
105+
source => $pkg_provider ? {
96106
'chocolatey' => undef,
97-
default => pick($staged_package, $package_source),
107+
default => $manage_package_source ? {
108+
true => pick($staged_package, $_package_source),
109+
false => $_package_source,
110+
}
98111
},
99112
}
100113

manifests/params.pp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@
8181
# Requires: nothing
8282
#
8383
class splunk::params (
84-
$version = '7.0.0',
85-
$build = 'c8a78efdd40f',
86-
$src_root = 'https://download.splunk.com',
87-
$splunkd_port = '8089',
88-
$logging_port = '9997',
89-
$server = 'splunk',
90-
$forwarder_installdir = undef,
91-
$server_installdir = undef,
92-
$splunk_user = $facts['os']['family'] ? {
84+
String $version = '7.0.0',
85+
String $build = 'c8a78efdd40f',
86+
String $src_root = 'https://download.splunk.com',
87+
Stdlib::Port $splunkd_port = 8089,
88+
Stdlib::Port $logging_port = 9997,
89+
String $server = 'splunk',
90+
Optional[String] $forwarder_installdir = undef,
91+
Optional[String] $server_installdir = undef,
92+
String $splunk_user = $facts['os']['family'] ? {
9393
'Windows' => 'Administrator',
9494
default => 'root'
9595
}

spec/classes/forwarder_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@
2020

2121
it { is_expected.to compile.with_all_deps }
2222
end
23+
24+
context 'with pkg_provider set to yum and manage_package_source set to false' do
25+
let(:params) do
26+
{
27+
'pkg_provider' => 'yum',
28+
'package_name' => 'splunk_forwarder_X',
29+
'manage_package_source' => false
30+
}
31+
end
32+
33+
it { is_expected.to compile.with_all_deps }
34+
it { is_expected.to contain_package('splunk_forwarder_X').with_provider('yum').without_source }
35+
end
2336
end
2437
end
2538
end

spec/classes/splunk_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@
1919
it { is_expected.to contain_service('splunk') }
2020
it { is_expected.to contain_package('splunk').with_ensure('installed') }
2121
end
22+
23+
context 'with pkg_provider set to yum and manage_package_source set to false' do
24+
let(:params) do
25+
{
26+
'pkg_provider' => 'yum',
27+
'package_name' => 'splunk_server_X',
28+
'manage_package_source' => false
29+
}
30+
end
31+
32+
it { is_expected.to compile.with_all_deps }
33+
it { is_expected.to contain_package('splunk_server_X').with_provider('yum').without_source }
34+
end
2235
end
2336
end
2437
end

0 commit comments

Comments
 (0)