Compare commits
15 Commits
1.0.0
...
1.1.0-3.20
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ff1a23e12 | |||
| e53a3acc1d | |||
| 8e92ea1393 | |||
| f4cb7198b3 | |||
| 4a9d594758 | |||
| 167d56d32a | |||
| c1be1108f9 | |||
| 06f1db823b | |||
| 16f534b5d2 | |||
| 08c263d34c | |||
| f5e8c5b5c8 | |||
| 80e629bc5c | |||
|
|
77572efa1a | ||
|
|
c1333f711d | ||
|
|
e6efa11010 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ Gemfile.lock
|
|||||||
FileList
|
FileList
|
||||||
.scannerwork
|
.scannerwork
|
||||||
.vscode
|
.vscode
|
||||||
|
.puppet-lint.rc
|
||||||
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"cSpell.words": [
|
|
||||||
"phpmyadmin",
|
|
||||||
"userdir"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
4
Jenkinsfile
vendored
4
Jenkinsfile
vendored
@@ -69,7 +69,7 @@ pipeline {
|
|||||||
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
|
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
|
||||||
sh '''
|
sh '''
|
||||||
/opt/sonar-scanner/bin/sonar-scanner \
|
/opt/sonar-scanner/bin/sonar-scanner \
|
||||||
-Dsonar.projectKey=cconfdroid_apache \
|
-Dsonar.projectKey=confdroid_apache \
|
||||||
-Dsonar.sources=. \
|
-Dsonar.sources=. \
|
||||||
-Dsonar.host.url=https://sonarqube.confdroid.com \
|
-Dsonar.host.url=https://sonarqube.confdroid.com \
|
||||||
-Dsonar.token=$SONAR_TOKEN
|
-Dsonar.token=$SONAR_TOKEN
|
||||||
@@ -114,7 +114,7 @@ pipeline {
|
|||||||
git rm -f Jenkinsfile
|
git rm -f Jenkinsfile
|
||||||
git rm -r --cached .vscode || echo "No .vscode to remove from git"
|
git rm -r --cached .vscode || echo "No .vscode to remove from git"
|
||||||
git commit --amend --no-edit --allow-empty
|
git commit --amend --no-edit --allow-empty
|
||||||
git remote add master https://gitea.confdroid.com/confdroid/confdroid_apache.git
|
git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_apache.git
|
||||||
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
|
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
|
||||||
push master --mirror
|
push master --mirror
|
||||||
'''
|
'''
|
||||||
|
|||||||
57
README.md
57
README.md
@@ -1,6 +1,8 @@
|
|||||||
# README
|
# README
|
||||||
|
|
||||||
[](https://jenkins.confdroid.com/job/confdroid_apache/)
|
[](https://jenkins.confdroid.com/job/confdroid_apache/)
|
||||||
|
[](https://sonarqube.confdroid.com/dashboard?id=confdroid_apache)
|
||||||
|
[](https://sonarqube.confdroid.com/dashboard?id=confdroid_apache)
|
||||||
|
|
||||||
- [README](#readme)
|
- [README](#readme)
|
||||||
- [Synopsis](#synopsis)
|
- [Synopsis](#synopsis)
|
||||||
@@ -16,7 +18,6 @@
|
|||||||
- [Contact Us](#contact-us)
|
- [Contact Us](#contact-us)
|
||||||
- [Disclaimer](#disclaimer)
|
- [Disclaimer](#disclaimer)
|
||||||
|
|
||||||
|
|
||||||
## Synopsis
|
## Synopsis
|
||||||
|
|
||||||
`Apache httpd` is a very powerful and widely used web server.
|
`Apache httpd` is a very powerful and widely used web server.
|
||||||
@@ -25,47 +26,49 @@
|
|||||||
|
|
||||||
## WARNING
|
## WARNING
|
||||||
|
|
||||||
***Attention: Never use this puppet module on systems which have been previously configured manually. It is impossible to predict how and what would have been configured, hence previous configurations outside the scope of this module may be overwritten! Automated configurations require a test environment to verify that the module suits the purpose intended by the user, as well as tune the parameters, before deploying into live production***
|
---Attention: Never use this puppet module on systems which have been previously configured manually. It is impossible to predict how and what would have been configured, hence previous configurations outside the scope of this module may be overwritten! Automated configurations require a test environment to verify that the module suits the purpose intended by the user, as well as tune the parameters, before deploying into live production---
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
|
|
||||||
* install required binaries and dependencies
|
- install required binaries and dependencies
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
|
|
||||||
* manage directory structure (optional)
|
- manage directory structure (optional)
|
||||||
* manage configuration files (optional):
|
- manage configuration files (optional):
|
||||||
* file system permissions
|
- file system permissions
|
||||||
* selinux context
|
- selinux context
|
||||||
* manage firewall settings (optional)
|
- manage firewall settings (optional)
|
||||||
* manage nagios monitoring (optional)
|
- manage nagios monitoring for the service (optional)
|
||||||
|
|
||||||
|
Optional
|
||||||
|
|
||||||
|
- manage remoteIP logging if running behind a Loadbalancer like HAproxy: if `ae_use_lb` is set to `true`, a configuration file `etc/httpd/conf.d/loadbalancer-remoteip.conf`is created and configures apache/httpd to use the remote header. This allows proper fail2ban protection even behind the Loadbalancer. Make sure to set `ae_trusted_proxy`to the proper IP or range for the loadbalancer!
|
||||||
|
|
||||||
Maintenance
|
Maintenance
|
||||||
|
|
||||||
* manage the service
|
- manage the service
|
||||||
|
|
||||||
### vHosts
|
### vHosts
|
||||||
|
|
||||||
As stated in the synopsis, this module was written particularly for usage as base module. `Apache httpd` has a great number of use cases where it actually is not used directly as full-blown web server by itself, but instead as platform for other applications. Examples here would be:
|
As stated in the synopsis, this module was written particularly for usage as base module. `Apache httpd` has a great number of use cases where it actually is not used directly as full-blown web server by itself, but instead as platform for other applications. Examples here would be:
|
||||||
|
|
||||||
* front-end proxy for other applications to avoid having to put the port number into the URL
|
- front-end proxy for other applications to avoid having to put the port number into the URL
|
||||||
* applications like phpMyAdmin, phpPgAdmin
|
- applications like phpMyAdmin, phpPgAdmin
|
||||||
* WordPress
|
- WordPress
|
||||||
* Nagios etc.
|
- Nagios etc.
|
||||||
|
|
||||||
With those use cases, you would provide the vHosts at the Puppet module for the application, not the base module. Also, if you plan to use this module to run a plain fully fledged web server, you would use a role- or profile class/module on top of `confdroid_apache` to set up your vHost exactly as needed. Examples for regular basic vHost configuration files are included in the examples directory as parameterized .erb files. You would create a define for vHosts, i.e. using the example parameters, and simply add `confdroid_apache` as requirement (i.e. require confdroid_apache) so it gets installed automatically.
|
With those use cases, you would provide the vHosts at the Puppet module for the application, not the base module. Also, if you plan to use this module to run a plain fully fledged web server, you would use a role- or profile class/module on top of `confdroid_apache` to set up your vHost exactly as needed. Examples for regular basic vHost configuration files are included in the examples directory as parameterized .erb files. You would create a define for vHosts, i.e. using the example parameters, and simply add `confdroid_apache` as requirement (i.e. require confdroid_apache) so it gets installed automatically.
|
||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|
||||||
All dependencies must be included in the catalogue.
|
All listed dependencies must be included in the catalogue.
|
||||||
|
|
||||||
* [cd_resources](https://gitlab.confdroid.com/puppet/cd_resources) for managing yum repo resources.
|
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
* native Puppet deployment
|
- native Puppet deployment
|
||||||
|
|
||||||
via site.pp or nodes.pp
|
via site.pp or nodes.pp
|
||||||
|
|
||||||
@@ -75,9 +78,9 @@ node 'example.example.net' {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* through Foreman:
|
- through Foreman:
|
||||||
|
|
||||||
In order to apply parameters through Foreman, **__confdroid_apache::params__** must be added to the host or host group in question.
|
In order to apply parameters through Foreman, --__confdroid_apache::params__-- must be added to the host or host group in question.
|
||||||
|
|
||||||
See [more details about class deployment on Confdroid.com](https://confdroid.com/2017/05/deploying-our-puppet-modules/).
|
See [more details about class deployment on Confdroid.com](https://confdroid.com/2017/05/deploying-our-puppet-modules/).
|
||||||
|
|
||||||
@@ -91,16 +94,16 @@ All files and directories are configured with correct selinux context. If selinu
|
|||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
* OS: Rocky 9
|
- OS: Rocky 9
|
||||||
* Puppet 8
|
- Puppet 8
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
* Puppet Lint
|
- Puppet Lint
|
||||||
* Puppet Parser
|
- Puppet Parser
|
||||||
* ERB Template Parser
|
- ERB Template Parser
|
||||||
* Test for unwanted UTF8 files in the Puppet code (see tests/UTF_Files)
|
- Test for unwanted UTF8 files in the Puppet code (see tests/UTF_Files)
|
||||||
* Sonar Quality Gate
|
- Sonar Quality Gate
|
||||||
|
|
||||||
## Contact Us
|
## Contact Us
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,7 @@
|
|||||||
class confdroid_apache::monitoring::target (
|
class confdroid_apache::monitoring::target (
|
||||||
|
|
||||||
) inherits confdroid_apache::params {
|
) inherits confdroid_apache::params {
|
||||||
case $ae_incl_target {
|
if $ae_incl_target == true {
|
||||||
false: { notify { 'Nagios Service target for check_httpd has been disabled via parameters / ENC override': }
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
@@nagios_service { "check_http_${fqdn}":
|
@@nagios_service { "check_http_${fqdn}":
|
||||||
check_command => 'check_http',
|
check_command => 'check_http',
|
||||||
use => 'generic-service',
|
use => 'generic-service',
|
||||||
@@ -20,8 +17,7 @@ class confdroid_apache::monitoring::target (
|
|||||||
owner => 'nagios',
|
owner => 'nagios',
|
||||||
group => 'nagios',
|
group => 'nagios',
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
contacts => 'ops',
|
contacts => $ae_target_contacts,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,25 +5,6 @@
|
|||||||
# inherited by all classes except defines.
|
# inherited by all classes except defines.
|
||||||
# @param [String] pkg_ensure Specify which
|
# @param [String] pkg_ensure Specify which
|
||||||
# package type to use, i.e. `latest`, `present` or `absent`.
|
# package type to use, i.e. `latest`, `present` or `absent`.
|
||||||
# @param [Boolean] ae_manage_user Whether or not to manage details for the
|
|
||||||
# httpd service user. This is generally only required when using httpd on
|
|
||||||
# a number of servers sharing storage resources, i.e. NFS, where UID and GID
|
|
||||||
# settings must be same across all nodes.
|
|
||||||
# @param [String] ae_user_name Specify the user name for the httpd user.
|
|
||||||
# only active if ae_manage_user is set to true.
|
|
||||||
# @param [String] ae_user_uid Specify the UID for the httpd service user.
|
|
||||||
# only active if `ae_manage_user` is set to true.
|
|
||||||
# @param [String] ae_u_comment Specify the user comment for /etc/passwd.
|
|
||||||
# Shows up in email notifications as sender information.
|
|
||||||
# only active if `ae_manage_user` is set to true.
|
|
||||||
# @param [String] ae_u_groups Specify any secondary groups the httpd service
|
|
||||||
# user should be in. Must not contain the primary group.
|
|
||||||
# only active if `ae_manage_user` is set to true.
|
|
||||||
# @param [String] ae_user_home Specify the home of the httpd service user.
|
|
||||||
# only active if `ae_manage_user` is set to true.
|
|
||||||
# @param [String] ae_user_shell Specify the shell for the httpd service user,
|
|
||||||
# which normally should not be allowed to log in .
|
|
||||||
# only active if `ae_manage_user` is set to true.
|
|
||||||
# @param [Boolean] ae_manage_cfg Whether or not to manage the httpd
|
# @param [Boolean] ae_manage_cfg Whether or not to manage the httpd
|
||||||
# configuration. httpd is very often a sub system used by many other services,
|
# configuration. httpd is very often a sub system used by many other services,
|
||||||
# and the required configuration depends on the use case. If using httpd as
|
# and the required configuration depends on the use case. If using httpd as
|
||||||
@@ -40,8 +21,18 @@
|
|||||||
# @param [String] ae_http_port the port to use for the http protocol
|
# @param [String] ae_http_port the port to use for the http protocol
|
||||||
# @param [String] ae_https_port the port to use for the https protocol
|
# @param [String] ae_https_port the port to use for the https protocol
|
||||||
# @param [String] ae_target_service which service to monitor with nagios
|
# @param [String] ae_target_service which service to monitor with nagios
|
||||||
|
# @param [String] ae_target_contacts which contacts to notify for nagios alerts
|
||||||
# @param [Boolean] ae_manage_fw whether to manage firewall settings
|
# @param [Boolean] ae_manage_fw whether to manage firewall settings
|
||||||
# @param [Array] reqpackages List of packages to install.
|
# @param [Array] reqpackages List of packages to install.
|
||||||
|
# @param [Boolean] ae_use_lb whether to use load balancer or not. If true,
|
||||||
|
# a configuration file will be created to allow reading the client ips
|
||||||
|
# from the X-Forwarded-For header, and the httpd service will be restarted
|
||||||
|
# to apply the changes. This is required when using httpd behind a
|
||||||
|
# load balancer like haproxy, otherwise all client ips will be logged
|
||||||
|
# as the load balancer ip.
|
||||||
|
# @param [String] ae_trusted_proxy the IP address of the trusted proxy,
|
||||||
|
# i.e. the load balancer. This is required when `ae_use_lb` is set to
|
||||||
|
# true, and defaults to '10.0.1.0/24'.
|
||||||
###########################################################################
|
###########################################################################
|
||||||
class confdroid_apache::params (
|
class confdroid_apache::params (
|
||||||
|
|
||||||
@@ -55,15 +46,20 @@ class confdroid_apache::params (
|
|||||||
Boolean $ae_allow_user_dirs = false,
|
Boolean $ae_allow_user_dirs = false,
|
||||||
|
|
||||||
# nagios
|
# nagios
|
||||||
Boolean $ae_incl_target = false,
|
Boolean $ae_incl_target = true,
|
||||||
String $ae_target_service = '/etc/nagios/conf.d/httpd_service.cfg',
|
String $ae_target_service = '/etc/nagios/conf.d/httpd_service.cfg',
|
||||||
|
String $ae_target_contacts = 'nagiosadmin',
|
||||||
|
|
||||||
# firewall
|
# firewall
|
||||||
Boolean $ae_manage_fw = false,
|
Boolean $ae_manage_fw = true,
|
||||||
String $ae_order_no = '50',
|
String $ae_order_no = '50',
|
||||||
String $ae_http_port = '80',
|
String $ae_http_port = '80',
|
||||||
String $ae_https_port = '443',
|
String $ae_https_port = '443',
|
||||||
|
|
||||||
|
# loadbalancer
|
||||||
|
Boolean $ae_use_lb = false,
|
||||||
|
String $ae_trusted_proxy = '10.0.1.0/24',
|
||||||
|
|
||||||
) {
|
) {
|
||||||
# facts
|
# facts
|
||||||
$fqdn = $facts['networking']['fqdn']
|
$fqdn = $facts['networking']['fqdn']
|
||||||
@@ -102,6 +98,8 @@ class confdroid_apache::params (
|
|||||||
$ae_userdir_erb = 'confdroid_apache/userdir_conf.erb'
|
$ae_userdir_erb = 'confdroid_apache/userdir_conf.erb'
|
||||||
$ae_index_file = '/var/www/html/index.html'
|
$ae_index_file = '/var/www/html/index.html'
|
||||||
$ae_index_erb = 'confdroid_apache/index_html.erb'
|
$ae_index_erb = 'confdroid_apache/index_html.erb'
|
||||||
|
$ae_remoteip_file = '/etc/httpd/conf.d/loadbalancer-remoteip.conf'
|
||||||
|
$ae_remoteip_erb = 'confdroid_apache/loadbalancer/remoteip.conf.erb'
|
||||||
|
|
||||||
# includes must be last
|
# includes must be last
|
||||||
include confdroid_apache::main::config
|
include confdroid_apache::main::config
|
||||||
|
|||||||
@@ -92,6 +92,21 @@ class confdroid_apache::server::files (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if $ae_use_lb == true {
|
||||||
|
file { $ae_remoteip_file:
|
||||||
|
ensure => file,
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
mode => '0644',
|
||||||
|
selrange => s0,
|
||||||
|
selrole => object_r,
|
||||||
|
seltype => httpd_conf_t,
|
||||||
|
seluser => system_u,
|
||||||
|
content => template($ae_remoteip_erb),
|
||||||
|
notify => Service['httpd'],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# manage index.html
|
# manage index.html
|
||||||
|
|
||||||
file { $ae_index_file:
|
file { $ae_index_file:
|
||||||
|
|||||||
12
templates/loadbalancer/remoteip.conf.erb
Normal file
12
templates/loadbalancer/remoteip.conf.erb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
###############################################################################
|
||||||
|
########## parameterized remoteip config created by Puppet ##########
|
||||||
|
########## manual changes will be overwritten !!! ##########
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
RemoteIPHeader X-Forwarded-For
|
||||||
|
RemoteIPTrustedProxy <%= @ae_trusted_proxy %>
|
||||||
|
RemoteIPInternalProxy <%= @ae_trusted_proxy %>
|
||||||
|
|
||||||
|
# mod_remoteip rewrites client address for %a; use it in common/combined logs.
|
||||||
|
LogFormat "%a %l %u %t \"%r\" %>s %b" common
|
||||||
|
LogFormat "%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
|
||||||
Reference in New Issue
Block a user