line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Rex::Group::Lookup::File - read hostnames from a file. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
With this module you can define hostgroups out of a file. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Rex::Group::Lookup::File; |
16
|
|
|
|
|
|
|
group "webserver" => lookup_file("./hosts.lst"); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 EXPORTED FUNCTIONS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Rex::Group::Lookup::File; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
24
|
use v5.12.5; |
|
1
|
|
|
|
|
17
|
|
26
|
1
|
|
|
1
|
|
17
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
80
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '1.14.3'; # VERSION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
require Exporter; |
31
|
1
|
|
|
1
|
|
15
|
use base qw(Exporter); |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
201
|
|
32
|
1
|
|
|
1
|
|
15
|
use vars qw(@EXPORT); |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
273
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
@EXPORT = qw(lookup_file); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 lookup_file($file) |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
With this function you can read hostnames from a file. Every hostname in one line. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
group "webserver" => lookup_file("./webserver.lst"); |
41
|
|
|
|
|
|
|
group "mailserver" => lookup_file("./mailserver.lst"); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub lookup_file { |
46
|
0
|
|
|
0
|
1
|
|
my ($file) = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
open( my $fh, "<", $file ) or die($!); |
49
|
0
|
|
|
|
|
|
my @content = grep { !/^\s*$|^#/ } <$fh>; |
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
close($fh); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
chomp @content; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return @content; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |