1Rex::Commands::Gather(3U)ser Contributed Perl DocumentatiRoenx::Commands::Gather(3)
2
3
4

NAME

6       Rex::Commands::Gather - Hardware and Information gathering
7

DESCRIPTION

9       With this module you can gather hardware and software information.
10
11       All these functions will not be reported. These functions don't modify
12       anything.
13

SYNOPSIS

15        operating_system_is("SuSE");
16

EXPORTED FUNCTIONS

18   get_operating_system
19       Will return the current operating system name.
20
21        task "get-os", "server01", sub {
22          say get_operating_system();
23        };
24
25       Aliased by operating_system().
26
27   operating_system
28       Alias for get_operating_system()
29
30   get_system_information
31       Will return a hash of all system information. These Information will be
32       also used by the template function.
33
34   kernelname
35       Will return the kernel name of the operating system. For example on a
36       linux system it will return Linux.
37
38   dump_system_information
39       This function dumps all known system information on stdout.
40
41   operating_system_is($string)
42       Will return 1 if the operating system is $string.
43
44        task "is_it_suse", "server01", sub {
45          if( operating_system_is("SuSE") ) {
46            say "This is a SuSE system.";
47          }
48        };
49
50   operating_system_version()
51       Will return the os release number as an integer. For example, it will
52       convert 5.10 to 510, 10.04 to 1004 or 6.0.3 to 603.
53
54        task "prepare", "server01", sub {
55          if( operating_system_version() >= 510 ) {
56            say "OS Release is higher or equal to 510";
57          }
58        };
59
60   operating_system_release()
61       Will return the os release number as is.
62
63   network_interfaces
64       Return an HashRef of all the networkinterfaces and their configuration.
65
66        task "get_network_information", "server01", sub {
67          my $net_info = network_interfaces();
68        };
69
70       You can iterate over the devices as follow
71
72        my $net_info = network_interfaces();
73        for my $dev ( keys %{ $net_info } ) {
74          say "$dev has the ip: " . $net_info->{$dev}->{"ip"} . " and the netmask: " . $net_info->{$dev}->{"netmask"};
75        }
76
77   memory
78       Return an HashRef of all memory information.
79
80        task "get_memory_information", "server01", sub {
81          my $memory = memory();
82
83          say "Total:  " . $memory->{"total"};
84          say "Free:   " . $memory->{"free"};
85          say "Used:   " . $memory->{"used"};
86          say "Cached:  " . $memory->{"cached"};
87          say "Buffers: " . $memory->{"buffers"};
88        };
89
90   is_freebsd
91       Returns true if the target system is a FreeBSD.
92
93        task "foo", "server1", "server2", sub {
94          if(is_freebsd) {
95            say "This is a freebsd system...";
96          }
97          else {
98            say "This is not a freebsd system...";
99          }
100        };
101
102   is_redhat
103        task "foo", "server1", sub {
104          if(is_redhat) {
105            # do something on a redhat system (like RHEL, Fedora, CentOS, Scientific Linux
106          }
107        };
108
109   is_fedora
110        task "foo", "server1", sub {
111          if(is_fedora) {
112            # do something on a fedora system
113          }
114        };
115
116   is_suse
117        task "foo", "server1", sub {
118          if(is_suse) {
119            # do something on a suse system
120          }
121        };
122
123   is_mageia
124        task "foo", "server1", sub {
125          if(is_mageia) {
126            # do something on a mageia system (or other Mandriva followers)
127          }
128        };
129
130   is_debian
131        task "foo", "server1", sub {
132          if(is_debian) {
133            # do something on a debian system
134          }
135        };
136
137   is_alt
138        task "foo", "server1", sub {
139          if(is_alt) {
140            # do something on a ALT Linux system
141          }
142        };
143
144   is_netbsd
145       Returns true if the target system is a NetBSD.
146
147        task "foo", "server1", "server2", sub {
148          if(is_netbsd) {
149            say "This is a netbsd system...";
150          }
151          else {
152            say "This is not a netbsd system...";
153          }
154        };
155
156   is_openbsd
157       Returns true if the target system is an OpenBSD.
158
159        task "foo", "server1", "server2", sub {
160          if(is_openbsd) {
161            say "This is an openbsd system...";
162          }
163          else {
164            say "This is not an openbsd system...";
165          }
166        };
167
168   is_linux
169       Returns true if the target system is a Linux System.
170
171        task "prepare", "server1", "server2", sub {
172          if(is_linux) {
173           say "This is a linux system...";
174          }
175          else {
176           say "This is not a linux system...";
177          }
178        };
179
180   is_bsd
181       Returns true if the target system is a BSD System.
182
183        task "prepare", "server1", "server2", sub {
184          if(is_bsd) {
185           say "This is a BSD system...";
186          }
187          else {
188           say "This is not a BSD system...";
189          }
190        };
191
192   is_solaris
193       Returns true if the target system is a Solaris System.
194
195        task "prepare", "server1", "server2", sub {
196          if(is_solaris) {
197           say "This is a Solaris system...";
198          }
199          else {
200           say "This is not a Solaris system...";
201          }
202        };
203
204   is_windows
205       Returns true if the target system is a Windows System.
206
207   is_openwrt
208       Returns true if the target system is an OpenWrt System.
209
210   is_gentoo
211       Returns true if the target system is a Gentoo System.
212
213   is_arch
214        task "foo", "server1", sub {
215          if(is_arch) {
216            # do something on a arch system
217          }
218        };
219
220   is_void
221       Returns true if the target system is a Void Linux system.
222
223
224
225perl v5.36.0                      2022-07-20          Rex::Commands::Gather(3)
Impressum