Skip to content

Commit a80608a

Browse files
authored
[disk] add support for new options (#508)
* [disk] add support for new options * [disk] fix optional type for deprecated types
1 parent 5ad6cf3 commit a80608a

3 files changed

Lines changed: 94 additions & 7 deletions

File tree

manifests/integrations/disk.pp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,19 @@
3232
# excluded_disk_re => '/dev/sd[e-z]*'
3333
# }
3434
class datadog_agent::integrations::disk (
35-
String $use_mount = 'no',
36-
$excluded_filesystems = undef,
37-
$excluded_disks = undef,
38-
$excluded_disk_re = undef,
39-
$excluded_mountpoint_re = undef,
40-
$all_partitions = undef,
41-
$tag_by_filesystem = undef
35+
String $use_mount = 'no',
36+
$all_partitions = undef,
37+
$tag_by_filesystem = undef,
38+
Optional[Array[String]] $filesystem_blacklist = undef,
39+
Optional[Array[String]] $device_blacklist = undef,
40+
Optional[Array[String]] $mountpoint_blacklist = undef,
41+
Optional[Array[String]] $filesystem_whitelist = undef,
42+
Optional[Array[String]] $device_whitelist = undef,
43+
Optional[Array[String]] $mountpoint_whitelist = undef,
44+
Optional[Variant[String, Array[String]]] $excluded_filesystems = undef, # deprecated in agent versions >6.9
45+
Optional[Variant[String, Array[String]]] $excluded_disks = undef, # deprecated in agent versions >6.9
46+
Optional[String] $excluded_disk_re = undef, # deprecated in agent versions >6.9
47+
Optional[String] $excluded_mountpoint_re = undef, # deprecated in agent versions >6.9
4248
) inherits datadog_agent::params {
4349
include datadog_agent
4450

spec/classes/datadog_agent_integrations_disk_spec.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,51 @@
6767
excluded_disk_re: /dev/sdb.*
6868
excluded_mountpoint_re: /mnt/other.*
6969
all_partitions: yes
70+
tag_by_filesystem: no
71+
HEREDOC
72+
}
73+
it { is_expected.to contain_file(conf_file).with_content(yaml_conf) }
74+
end
75+
76+
context 'we handle new disk configuration option' do
77+
let(:params) {{
78+
use_mount: 'yes',
79+
filesystem_blacklist: ['tmpfs', 'dev'],
80+
device_blacklist: ['/dev/sda1'],
81+
mountpoint_blacklist: ['/mnt/foo'],
82+
filesystem_whitelist: ['ext4', 'hdfs', 'reiserfs'],
83+
device_whitelist: ['/dev/sdc1', '/dev/sdc2', '/dev/sdd2'],
84+
mountpoint_whitelist: ['/mnt/logs', '/mnt/builds'],
85+
all_partitions: 'yes',
86+
tag_by_filesystem: 'no'
87+
}}
88+
let(:yaml_conf) {
89+
<<-HEREDOC
90+
### MANAGED BY PUPPET
91+
92+
init_config:
93+
94+
instances:
95+
- use_mount: yes
96+
file_system_blacklist:
97+
- tmpfs
98+
- dev
99+
device_blacklist:
100+
- /dev/sda1
101+
mount_point_blacklist:
102+
- /mnt/foo
103+
file_system_whitelist:
104+
- ext4
105+
- hdfs
106+
- reiserfs
107+
device_whitelist:
108+
- /dev/sdc1
109+
- /dev/sdc2
110+
- /dev/sdd2
111+
mount_point_whitelist:
112+
- /mnt/logs
113+
- /mnt/builds
114+
all_partitions: yes
70115
tag_by_filesystem: no
71116
HEREDOC
72117
}

templates/agent-conf.d/disk.yaml.erb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,42 @@ init_config:
44

55
instances:
66
- use_mount: <%= @use_mount %>
7+
<% if @filesystem_blacklist -%>
8+
file_system_blacklist:
9+
<% (Array(@filesystem_blacklist)).each do |fs| -%>
10+
- <%= fs %>
11+
<%- end -%>
12+
<% end -%>
13+
<% if @device_blacklist -%>
14+
device_blacklist:
15+
<% (Array(@device_blacklist)).each do |disk| -%>
16+
- <%= disk %>
17+
<% end -%>
18+
<% end -%>
19+
<% if @mountpoint_blacklist -%>
20+
mount_point_blacklist:
21+
<% (Array(@mountpoint_blacklist)).each do |mount| -%>
22+
- <%= mount %>
23+
<% end -%>
24+
<% end -%>
25+
<% if @filesystem_whitelist -%>
26+
file_system_whitelist:
27+
<% (Array(@filesystem_whitelist)).each do |fs| -%>
28+
- <%= fs %>
29+
<%- end -%>
30+
<% end -%>
31+
<% if @device_whitelist -%>
32+
device_whitelist:
33+
<% (Array(@device_whitelist)).each do |disk| -%>
34+
- <%= disk %>
35+
<% end -%>
36+
<% end -%>
37+
<% if @mountpoint_whitelist -%>
38+
mount_point_whitelist:
39+
<% (Array(@mountpoint_whitelist)).each do |mount| -%>
40+
- <%= mount %>
41+
<% end -%>
42+
<% end -%>
743
<% if @excluded_filesystems -%>
844
excluded_filesystems:
945
<% (Array(@excluded_filesystems)).each do |fs| -%>

0 commit comments

Comments
 (0)