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

NAME

6       Rex::Commands::Augeas - An augeas module for (R)?ex
7

DESCRIPTION

9       This is a simple module to manipulate configuration files with the help
10       of augeas.
11

SYNOPSIS

13        my $k = augeas exists => "/files/etc/hosts/*/ipaddr", "127.0.0.1";
14
15        augeas insert => "/files/etc/hosts",
16                  label => "01",
17                  after => "/7",
18                  ipaddr => "192.168.2.23",
19                  canonical => "test";
20
21        augeas dump => "/files/etc/hosts";
22
23        augeas modify =>
24           "/files/etc/ssh/sshd_config/PermitRootLogin" => "without-password",
25           on_change => sub {
26              service ssh => "restart";
27           };
28

EXPORTED FUNCTIONS

30   augeas($action, @options)
31       It returns 1 on success and 0 on failure.
32
33       Actions:
34
35       modify
36           This modifies the keys given in @options in $file.
37
38            augeas modify =>
39                      "/files/etc/hosts/7/ipaddr"    => "127.0.0.2",
40                      "/files/etc/hosts/7/canonical" => "test01",
41                      on_change                      => sub { say "I changed!" };
42
43       remove
44           Remove an entry.
45
46            augeas remove    => "/files/etc/hosts/2",
47                   on_change => sub { say "I changed!" };
48
49       insert
50           Insert an item into the file. Here, the order of the options is
51           important. If the order is wrong it won't save your changes.
52
53            augeas insert => "/files/etc/hosts",
54                      label     => "01",
55                      after     => "/7",
56                      ipaddr    => "192.168.2.23",
57                      alias     => "test02",
58                      on_change => sub { say "I changed!" };
59
60       dump
61           Dump the contents of a file to STDOUT.
62
63            augeas dump => "/files/etc/hosts";
64
65       exists
66           Check if an item exists.
67
68            my $exists = augeas exists => "/files/etc/hosts/*/ipaddr" => "127.0.0.1";
69            if($exists) {
70                say "127.0.0.1 exists!";
71            }
72
73       get Returns the value of the given item.
74
75            my $val = augeas get => "/files/etc/hosts/1/ipaddr";
76
77
78
79perl v5.38.0                      2023-08-07          Rex::Commands::Augeas(3)
Impressum