adds haproxy user

This commit is contained in:
Arne Teuke
2018-12-10 14:36:54 +01:00
parent f1ced15fee
commit 2f3afa420b
10 changed files with 194 additions and 40 deletions

View File

@@ -28,28 +28,16 @@ class cd_haproxy::firewall::iptables (
require cd_haproxy::main::files
if $hy_proxy_mode == 'http' {
firewall { "${hy_fw_order_no}80 tcp port 80":
proto => 'tcp',
dport => '80',
action => 'accept',
}
firewall { "${hy_fw_order_no}${hy_http_port} tcp port ${hy_http_port}":
proto => 'tcp',
dport => $hy_http_port,
action => 'accept',
}
if $hy_proxy_mode == 'tcp' {
firewall { "${hy_fw_order_no}${hy_fe_port} tcp port ${hy_fe_port}":
proto => 'tcp',
dport => $hy_fe_port,
action => 'accept',
}
firewall { "${hy_fw_order_no}${hy_https_port} tcp port ${hy_https_port}":
proto => 'tcp',
dport => $hy_https_port,
action => 'accept',
}
}
if $fqdn == $hy_host_fqdn {
require cd_haproxy::main::files
}
}

View File

@@ -25,6 +25,6 @@ class cd_haproxy::main::config (
) inherits cd_haproxy::params {
require cd_haproxy::server::service
include cd_haproxy::server::service
}

View File

@@ -25,9 +25,7 @@ class cd_haproxy::main::dirs (
) inherits cd_haproxy::params {
if $fqdn == $hy_host_fqdn {
require cd_haproxy::main::install
require cd_haproxy::main::user
}

View File

@@ -25,8 +25,6 @@ class cd_haproxy::main::files (
) inherits cd_haproxy::params {
if $fqdn == $hy_host_fqdn {
require cd_haproxy::main::dirs
}
}

View File

@@ -25,7 +25,9 @@ class cd_haproxy::main::install (
) inherits cd_haproxy::params {
package {$reqpackages:
ensure => $pkg_ensure,
if $fqdn == $hy_host_fqdn {
package {$reqpackages:
ensure => $pkg_ensure,
}
}
}

48
manifests/main/user.pp Normal file
View File

@@ -0,0 +1,48 @@
## cd_haproxy::main::user.pp
# Module name: cd_haproxy
# Author: Arne Teuke (arne_teuke@ConfDroid.com)
# # License:
# This file is part of cd_haproxy.
#
# cd_haproxy is used for providing automatic configuration of HAproxy
# Copyright (C) 2016 ConfDroid (copyright@ConfDroid.com)
# This program 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.
#
# This program 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 program. If not, see <http://www.gnu.org/licenses/>.
# @summary Class manages service users for cd_haproxy.
#############################################################################
class cd_haproxy::main::user (
) inherits cd_haproxy::params {
if $fqdn == $hy_host_fqdn {
require cd_haproxy::main::install
# manage user
user { $hy_user:
ensure => present,
name => $hy_user,
allowdupe => false,
comment => $hy_user_comment,
gid => $hy_user,
managehome => true,
home => $hy_user_home,
shell => $hy_user_shell,
}
group { $hy_user:
ensure => present,
name => $hy_user,
allowdupe => false,
}
}
}

View File

@@ -39,26 +39,34 @@
##############################################################################
class cd_haproxy::params (
$pkg_ensure = 'latest',
$reqpackages = ['haproxy'],
$pkg_ensure = 'latest',
$reqpackages = ['haproxy'],
$hy_host_fqdn = "proxy.${::domain}",
$hy_host_fqdn = "proxy.${::domain}",
# firewall
$hy_manage_fw = true,
$hy_fw_order_no = '50',
$hy_manage_fw = true,
$hy_fw_order_no = '50',
# main config
$hy_proxy_mode = 'http',
$hy_fe_port = '',
$hy_be_port = '',
$hy_http_port = '80',
$hy_https_port = '443',
# user
$hy_user_name = 'haproxy',
$hy_user_comment = 'haproxy user',
$hy_user_home = '/var/lib/haproxy',
$hy_user_shell = '/sbin/nologin',
) {
# service
$hy_service = 'haproxy'
$hy_service = 'haproxy'
# installation section
# directories
# files
# includes must be last

27
manifests/server/proxy.pp Normal file
View File

@@ -0,0 +1,27 @@
## cd_haproxy::server::proxy.pp
# Module name: cd_haproxy
# Author: Arne Teuke (arne_teuke@ConfDroid.com)
# # License:
# This file is part of cd_haproxy.
#
# cd_haproxy is used for providing automatic configuration of HAProxy
# Copyright (C) 2016 ConfDroid (copyright@ConfDroid.com)
# This program 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.
#
# This program 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 program. If not, see <http://www.gnu.org/licenses/>.
# @summary Define manages the proxies for cd_haproxy.
#############################################################################
define cd_haproxy::server::proxy (
) {
}