NAME
Config::HAProxy - Parser for HAProxy configuration file
SYNOPSIS
use Config::HAProxy;
$cfg = new Config::HAProxy([$filename, $lint_program]);
$cfg->parse;
$name = $cfg->filename;
@frontends = $cfg->select(name => 'frontend');
$itr = $cfg->iterator(inorder => 1);
while (defined($node = $itr->next)) {
# do something with $node
}
$cfg->lint(enable => 1, command => 'haproxy -c -f',
path => '/sbin:/usr/sbin')
$cfg->save(%hash);
$cfg->write($file_or_handle, %hash);
$cfg->backup;
$name = $self->backup_name;
$cfg->reset;
$cfg->push($node);
$node = $cfg->pop;
$node = $cfg->tos;
$node = $cfg->tree;
DESCRIPTION
The Config::HAProxy class is a parser that converts the HAProxy configuration file to a parse tree and provides methods for various operations on this tree, such as: searching, modifying and saving it to a file.
An object of this class contains a parse tree representing the configuration read from the file (or created from scratch). See "PARSE TREE" in Config::Proxy, for a detailed discussion.
CONFIGURATION SECTIONS
By default, the following four HAProxy keywords begin compound statements (or sections): backend, defaults, frontend, global, resolvers. If need be, this list can be modified using the following class methods:
declare_section
$cfg = Config::HAProxy->declare_section($name)
Declares $name as a top-level section.
undeclare_section
$cfg = Config::HAProxy->undeclare_section($name)
Cancels declaration of $name as a section.
CONSTRUCTOR
$cfg = new Config::HAProxy([$filename, $linter]);
Creates and returns a new object for manipulating the HAProxy configuration. Optional $filename specifies the name of the file to read configuration from. It defaults to /etc/haproxy/haproxy.cfg. Optional $linter parameter supplies a shell command to be called in order to check configuration file syntax. The command will be called by save and write methods before saving the configuration file. See "save" in Config::Proxy and "write" in Config::Proxy. Default linter command is haproxy -c -f.
METHODS AND ATTRIBUTES
See Config::Proxy, for a detailed discussion of these.
SEE ALSO
Config::Proxy, Config::Proxy::Node, Config::Proxy::Node::Comment, Config::Proxy::Node::Empty, Config::Proxy::Node::Root, Config::Proxy::Node::Section, Config::Proxy::Node::Statement, Config::Proxy::Iterator.
AUTHOR
Sergey Poznyakoff, <gray@gnu.org>
COPYRIGHT AND LICENSE
Copyright (C) 2018, 2024 by Sergey Poznyakoff
This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this library. If not, see <http://www.gnu.org/licenses/>.