Giter Club home page Giter Club logo

puppetlabs-apache's Introduction

apache

Table of Contents

  1. Module description - What is the apache module, and what does it do?
  2. Setup - The basics of getting started with apache
  3. Usage - The classes and defined types available for configuration
  4. Reference - An under-the-hood peek at what the module is doing and how
  5. Limitations - OS compatibility, etc.
  6. [License][License]
  7. Development - Guide for contributing to the module

Module description

Apache HTTP Server (also called Apache HTTPD, or simply Apache) is a widely used web server. This Puppet module simplifies the task of creating configurations to manage Apache servers in your infrastructure. It can configure and manage a range of virtual host setups and provides a streamlined way to install and configure Apache modules.

Setup

What the apache module affects:

  • Configuration files and directories (created and written to)
    • WARNING: Configurations not managed by Puppet will be purged.
  • Package/service/configuration files for Apache
  • Apache modules
  • Virtual hosts
  • Listened-to ports
  • /etc/make.conf on FreeBSD and Gentoo

On Gentoo, this module depends on the gentoo/puppet-portage Puppet module. Note that while several options apply or enable certain features and settings for Gentoo, it is not a supported operating system for this module.

Warning: This module modifies Apache configuration files and directories and purges any configuration not managed by Puppet. Apache configuration should be managed by Puppet, as unmanaged configuration files can cause unexpected failures.

To temporarily disable full Puppet management, set the purge_configs parameter in the apache class declaration to false. We recommend this only as a temporary means of saving and relocating customized configurations.

Beginning with Apache

To have Puppet install Apache with the default parameters, declare the apache class:

class { 'apache': }

When you declare this class with the default options, the module:

  • Installs the appropriate Apache software package and required Apache modules for your operating system.
  • Places the required configuration files in a directory, with the default location Depends on operating system.
  • Configures the server with a default virtual host and standard port (80) and address ('*') bindings.
  • Creates a document root directory Depends on operating system, typically /var/www.
  • Starts the Apache service.

Apache defaults depend on your operating system. These defaults work in testing environments but are not suggested for production. We recommend customizing the class's parameters to suit your site.

For instance, this declaration installs Apache without the apache module's default virtual host configuration, allowing you to customize all Apache virtual hosts:

class { 'apache':
  default_vhost => false,
}

Note: When default_vhost is set to false, you have to add at least one apache::vhost resource or Apache will not start. To establish a default virtual host, either set the default_vhost in the apache class or use the apache::vhost defined type. You can also configure additional specific virtual hosts with the apache::vhost defined type.

Usage

Configuring virtual hosts

The default apache class sets up a virtual host on port 80, listening on all interfaces and serving the docroot parameter's default directory of /var/www.

To configure basic name-based virtual hosts, specify the port and docroot parameters in the apache::vhost defined type:

apache::vhost { 'vhost.example.com':
  port    => 80,
  docroot => '/var/www/vhost',
}

See the apache::vhost defined type's reference for a list of all virtual host parameters.

Note: Apache processes virtual hosts in alphabetical order, and server administrators can prioritize Apache's virtual host processing by prefixing a virtual host's configuration file name with a number. The apache::vhost defined type applies a default priority of 25, which Puppet interprets by prefixing the virtual host's file name with 25-. This means that if multiple sites have the same priority, or if you disable priority numbers by setting the priority parameter's value to false, Apache still processes virtual hosts in alphabetical order.

To configure user and group ownership for docroot, use the docroot_owner and docroot_group parameters:

apache::vhost { 'user.example.com':
  port          => 80,
  docroot       => '/var/www/user',
  docroot_owner => 'www-data',
  docroot_group => 'www-data',
}

Configuring virtual hosts with SSL

To configure a virtual host to use SSL encryption and default SSL certificates, set the ssl parameter. You must also specify the port parameter, typically with a value of 443, to accommodate HTTPS requests:

apache::vhost { 'ssl.example.com':
  port    => 443,
  docroot => '/var/www/ssl',
  ssl     => true,
}

To configure a virtual host to use SSL and specific SSL certificates, use the paths to the certificate and key in the ssl_cert and ssl_key parameters, respectively:

apache::vhost { 'cert.example.com':
  port     => 443,
  docroot  => '/var/www/cert',
  ssl      => true,
  ssl_cert => '/etc/ssl/fourth.example.com.cert',
  ssl_key  => '/etc/ssl/fourth.example.com.key',
}

To configure a mix of SSL and unencrypted virtual hosts at the same domain, declare them with separate apache::vhost defined types:

# The non-ssl virtual host
apache::vhost { 'mix.example.com non-ssl':
  servername => 'mix.example.com',
  port       => 80,
  docroot    => '/var/www/mix',
}

# The SSL virtual host at the same domain
apache::vhost { 'mix.example.com ssl':
  servername => 'mix.example.com',
  port       => 443,
  docroot    => '/var/www/mix',
  ssl        => true,
}

To configure a virtual host to redirect unencrypted connections to SSL, declare them with separate apache::vhost defined types and redirect unencrypted requests to the virtual host with SSL enabled:

apache::vhost { 'redirect.example.com non-ssl':
  servername      => 'redirect.example.com',
  port            => 80,
  docroot         => '/var/www/redirect',
  redirect_status => 'permanent',
  redirect_dest   => 'https://redirect.example.com/'
}

apache::vhost { 'redirect.example.com ssl':
  servername => 'redirect.example.com',
  port       => 443,
  docroot    => '/var/www/redirect',
  ssl        => true,
}

Configuring virtual host port and address bindings

Virtual hosts listen on all IP addresses ('*') by default. To configure the virtual host to listen on a specific IP address, use the ip parameter:

apache::vhost { 'ip.example.com':
  ip      => '127.0.0.1',
  port    => 80,
  docroot => '/var/www/ip',
}

You can also configure more than one IP address per virtual host by using an array of IP addresses for the ip parameter:

apache::vhost { 'ip.example.com':
  ip      => ['127.0.0.1','169.254.1.1'],
  port    => 80,
  docroot => '/var/www/ip',
}

You can configure multiple ports per virtual host by using an array of ports for the port parameter:

apache::vhost { 'ip.example.com':
  ip      => ['127.0.0.1'],
  port    => [80, 8080]
  docroot => '/var/www/ip',
}

To configure a virtual host with aliased servers, refer to the aliases using the serveraliases parameter:

apache::vhost { 'aliases.example.com':
  serveraliases => [
    'aliases.example.org',
    'aliases.example.net',
  ],
  port          => 80,
  docroot       => '/var/www/aliases',
}

To set up a virtual host with a wildcard alias for the subdomain mapped to a directory of the same name, such as 'http://example.com.loc' mapped to /var/www/example.com, define the wildcard alias using the serveraliases parameter and the document root with the virtual_docroot parameter:

apache::vhost { 'subdomain.loc':
  vhost_name      => '*',
  port            => 80,
  virtual_docroot => '/var/www/%-2+',
  docroot         => '/var/www',
  serveraliases   => ['*.loc',],
}

To configure a virtual host with filter rules, pass the filter directives as an array using the filters parameter:

apache::vhost { 'subdomain.loc':
  port    => 80,
  filters => [
    'FilterDeclare  COMPRESS',
    'FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html',
    'FilterChain    COMPRESS',
    'FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no',
  ],
  docroot => '/var/www/html',
}

Configuring virtual hosts for apps and processors

To configure a virtual host to use the Web Server Gateway Interface (WSGI) for Python applications, use the wsgi set of parameters:

apache::vhost { 'wsgi.example.com':
  port                        => 80,
  docroot                     => '/var/www/pythonapp',
  wsgi_application_group      => '%{GLOBAL}',
  wsgi_daemon_process         => 'wsgi',
  wsgi_daemon_process_options => {
    processes    => 2,
    threads      => 15,
    display-name => '%{GROUP}',
  },
  wsgi_import_script          => '/var/www/demo.wsgi',
  wsgi_import_script_options  => {
    process-group     => 'wsgi',
    application-group => '%{GLOBAL}',
  },
  wsgi_process_group          => 'wsgi',
  wsgi_script_aliases         => { '/' => '/var/www/demo.wsgi' },
}

As of Apache 2.2.16, Apache supports FallbackResource, a simple replacement for common RewriteRules. You can set a FallbackResource using the fallbackresource parameter:

apache::vhost { 'wordpress.example.com':
  port             => 80,
  docroot          => '/var/www/wordpress',
  fallbackresource => '/index.php',
}

Note: The fallbackresource parameter only supports the 'disabled' value since Apache 2.2.24.

To configure a virtual host with a designated directory for Common Gateway Interface (CGI) files, use the scriptalias parameter to define the cgi-bin path:

apache::vhost { 'cgi.example.com':
  port        => 80,
  docroot     => '/var/www/cgi',
  scriptalias => '/usr/lib/cgi-bin',
}

To configure a virtual host for Rack, use the rack_base_uri parameter:

apache::vhost { 'rack.example.com':
  port           => 80,
  docroot        => '/var/www/rack',
  rack_base_uri => ['/rackapp1', '/rackapp2'],
}

Configuring IP-based virtual hosts

You can configure IP-based virtual hosts to listen on any port and have them respond to requests on specific IP addresses. In this example, the server listens on ports 80 and 81, because the example virtual hosts are not declared with a port parameter:

apache::listen { '80': }

apache::listen { '81': }

Configure the IP-based virtual hosts with the ip_based parameter:

apache::vhost { 'first.example.com':
  ip       => '10.0.0.10',
  docroot  => '/var/www/first',
  ip_based => true,
}

apache::vhost { 'second.example.com':
  ip       => '10.0.0.11',
  docroot  => '/var/www/second',
  ip_based => true,
}

You can also configure a mix of IP- and name-based virtual hosts in any combination of SSL and unencrypted configurations.

In this example, we add two IP-based virtual hosts on an IP address (in this example, 10.0.0.10). One uses SSL and the other is unencrypted:

apache::vhost { 'The first IP-based virtual host, non-ssl':
  servername => 'first.example.com',
  ip         => '10.0.0.10',
  port       => 80,
  ip_based   => true,
  docroot    => '/var/www/first',
}

apache::vhost { 'The first IP-based vhost, ssl':
  servername => 'first.example.com',
  ip         => '10.0.0.10',
  port       => 443,
  ip_based   => true,
  docroot    => '/var/www/first-ssl',
  ssl        => true,
}

Next, we add two name-based virtual hosts listening on a second IP address (10.0.0.20):

apache::vhost { 'second.example.com':
  ip      => '10.0.0.20',
  port    => 80,
  docroot => '/var/www/second',
}

apache::vhost { 'third.example.com':
  ip      => '10.0.0.20',
  port    => 80,
  docroot => '/var/www/third',
}

To add name-based virtual hosts that answer on either 10.0.0.10 or 10.0.0.20, you must disable the Apache default Listen 80, as it conflicts with the preceding IP-based virtual hosts. To do this, set the add_listen parameter to false:

apache::vhost { 'fourth.example.com':
  port       => 80,
  docroot    => '/var/www/fourth',
  add_listen => false,
}

apache::vhost { 'fifth.example.com':
  port       => 80,
  docroot    => '/var/www/fifth',
  add_listen => false,
}

Installing Apache modules

There are two ways to install Apache modules using the Puppet apache module:

Installing specific modules

The Puppet apache module supports installing many common Apache modules, often with parameterized configuration options. For a list of supported Apache modules, see the apache::mod::<MODULE NAME> class references.

For example, you can install the mod_ssl Apache module with default settings by declaring the apache::mod::ssl class:

class { 'apache::mod::ssl': }

apache::mod::ssl has several parameterized options that you can set when declaring it. For instance, to enable mod_ssl with compression enabled, set the ssl_compression parameter to true:

class { 'apache::mod::ssl':
  ssl_compression => true,
}

You can pass the SSL Ciphers to override the default ciphers.

class { 'apache::mod::ssl':
  ssl_cipher => 'PROFILE=SYSTEM',
}

You can also pass the different ssl_cipher for different SSL protocols. This allows you to fine-tune the ciphers based on the specific SSL/TLS protocol version being used.

class { 'apache::mod::ssl':
  ssl_cipher => {
    'TLSv1.1' => 'RSA:!EXP:!NULL:+HIGH:+MEDIUM'
  },
}

Note that some modules have prerequisites, which are documented in their references under apache::mod::<MODULE NAME>.

Installing arbitrary modules

You can pass the name of any module that your operating system's package manager can install to the apache::mod defined type to install it. Unlike the specific-module classes, the apache::mod defined type doesn't tailor the installation based on other installed modules or with specific parameters---Puppet only grabs and installs the module's package, leaving detailed configuration up to you.

For example, to install the mod_authnz_external Apache module, declare the defined type with the 'mod_authnz_external' name:

apache::mod { 'mod_authnz_external': }

There are several optional parameters you can specify when defining Apache modules this way. See the defined type's reference for details.

Load balancing examples

Apache supports load balancing across groups of servers through the mod_proxy Apache module. Puppet supports configuring Apache load balancing groups (also known as balancer clusters) through the apache::balancer and apache::balancermember defined types.

To enable load balancing with exported resources, export the apache::balancermember defined type from the load balancer member server:

@@apache::balancermember { "${::fqdn}-puppet00":
  balancer_cluster => 'puppet00',
  url              => "ajp://${::fqdn}:8009",
  options          => ['ping=5', 'disablereuse=on', 'retry=5', 'ttl=120'],
}

Then, on the proxy server, create the load balancing group:

apache::balancer { 'puppet00': }

To enable load balancing without exporting resources, declare the following on the proxy server:

apache::balancer { 'puppet00': }

apache::balancermember { "${::fqdn}-puppet00":
  balancer_cluster => 'puppet00',
  url              => "ajp://${::fqdn}:8009",
  options          => ['ping=5', 'disablereuse=on', 'retry=5', 'ttl=120'],
}

Then declare the apache::balancer and apache::balancermember defined types on the proxy server.

To use the ProxySet directive on the balancer, use the proxy_set parameter of apache::balancer:

apache::balancer { 'puppet01':
  proxy_set => {
    'stickysession' => 'JSESSIONID',
    'lbmethod'      => 'bytraffic',
  },
}

Load balancing scheduler algorithms (lbmethod) are listed in mod_proxy_balancer documentation.

Reference

For information on classes, types and functions see the REFERENCE.md

Templates

The Apache module relies heavily on templates to enable the apache::vhost and apache::mod defined types. These templates are built based on Facter facts that are specific to your operating system. Unless explicitly called out, most templates are not meant for configuration.

Tasks

The Apache module has a task that allows a user to reload the Apache config without restarting the service. Please refer to to the PE documentation or Bolt documentation on how to execute a task.

Limitations

For an extensive list of supported operating systems, see metadata.json

FreeBSD

In order to use this module on FreeBSD, you must use apache24-2.4.12 (www/apache24) or newer.

Gentoo

On Gentoo, this module depends on the gentoo/puppet-portage Puppet module. Although several options apply or enable certain features and settings for Gentoo, it is not a supported operating system for this module.

RHEL/CentOS

The apache::mod::auth_cas, apache::mod::passenger, apache::mod::proxy_html and apache::mod::shib classes are not functional on RH/CentOS without providing dependency packages from extra repositories.

See their respective documentation below for related repositories and packages.

RHEL/CentOS 5

The apache::mod::passenger and apache::mod::proxy_html classes are untested because repositories are missing compatible packages.

RHEL/CentOS 6

The apache::mod::passenger class is not installing, because the EL6 repository is missing compatible packages.

RHEL/CentOS 7

The apache::mod::passenger and apache::mod::proxy_html classes are untested because the EL7 repository is missing compatible packages, which also blocks us from testing the apache::vhost defined type's rack_base_uri parameter.

SELinux and custom paths

If SELinux is in enforcing mode and you want to use custom paths for logroot, mod_dir, vhost_dir, and docroot, you need to manage the files' context yourself.

You can do this with Puppet:

exec { 'set_apache_defaults':
  command => 'semanage fcontext -a -t httpd_sys_content_t "/custom/path(/.*)?"',
  path    => '/bin:/usr/bin/:/sbin:/usr/sbin',
  require => Package['policycoreutils-python'],
}

package { 'policycoreutils-python':
  ensure => installed,
}

exec { 'restorecon_apache':
  command => 'restorecon -Rv /apache_spec',
  path    => '/bin:/usr/bin/:/sbin:/usr/sbin',
  before  => Class['Apache::Service'],
  require => Class['apache'],
}

class { 'apache': }

host { 'test.server':
  ip => '127.0.0.1',
}

file { '/custom/path':
  ensure => directory,
}

file { '/custom/path/include':
  ensure  => present,
  content => '#additional_includes',
}

apache::vhost { 'test.server':
  docroot             => '/custom/path',
  additional_includes => '/custom/path/include',
}

NOTE: On RHEL 8, the SELinux packages contained in policycoreutils-python have been replaced by the policycoreutils-python-utils package. See here for more details.

You must set the contexts using semanage fcontext instead of chcon because Puppet's file resources reset the values' context in the database if the resource doesn't specify it.

Development

Testing

To run the unit tests, install the necessary gems:

bundle install

And then execute the command:

bundle exec rake parallel_spec

To check the code coverage, run:

COVERAGE=yes bundle exec rake parallel_spec

Acceptance tests for this module leverage puppet_litmus. To run the acceptance tests follow the instructions here. You can also find a tutorial and walkthrough of using Litmus and the PDK on YouTube.

License

This codebase is licensed under the Apache2.0 licensing, however due to the nature of the codebase the open source dependencies may also use a combination of AGPL, BSD-2, BSD-3, GPL2.0, LGPL, MIT and MPL Licensing.

Development Support

If you run into an issue with this module, or if you would like to request a feature, please file a ticket. Every Monday the Puppet IA Content Team has office hours in the Puppet Community Slack, alternating between an EMEA friendly time (1300 UTC) and an Americas friendly time (0900 Pacific, 1700 UTC).

If you have problems getting this module up and running, please contact Support.

If you submit a change to this module, be sure to regenerate the reference documentation as follows:

puppet strings generate --format markdown --out REFERENCE.md

Apache MOD Test & Support Lifecycle

Adding Support for a new Apache MOD

Support for new Apache Modules can be added under the apache::mod namespace. Acceptance tests should be added for each new Apache Module added. Ideally, the acceptance tests should run on all compatible platforms that this module is supported on (see metdata.json), however there are cases when a more niche module is difficult to set up and install on a particular Linux distro. This could be for one or more of the following reasons:

  • Package not available in default repositories of distro
  • Package dependencies not available in default repositories of distro
  • Package (and/or its dependencies) are only available in a specific version of an OS

In these cases, it is possible to exclude a module from a test platform using a specific tag, defined above the class declaration:

# @note Unsupported platforms: OS: ver, ver; OS: ver, ver, ver; OS: all
class apache::mod::foobar {
...
}

For example:

# @note Unsupported platforms: RedHat: 5, 6; Ubuntu: 14.04; SLES: all; Scientific: 11 SP1
class apache::mod::actions {
...
}

Please be aware of the following format guidelines for the tag:

  • All OS/Version declarations must be preceded with @note Unsupported platforms:
  • The tag must be declared ABOVE the class declaration (i.e. not as footer at the bottom of the file)
  • Each OS/Version declaration must be separated by semicolons (;)
  • Each version must be separated by a comma (,)
  • Versions CANNOT be declared in ranges (e.g. RedHat:5-7), they should be explicitly declared (e.g. RedHat:5,6,7)
  • However, to declare all versions of an OS as unsupported, use the word all (e.g. SLES:all)
  • OSs with word characters as part of their versions are acceptable (e.g. Scientific: 11 SP1, 11 SP2, 12, 13)
  • Spaces are permitted between OS/Version declarations and version numbers within a declaration
  • Refer to the operatingsystem_support values in the metadata.json to find the acceptable OS name and version syntax:
    • E.g. OracleLinux OR oraclelinux, not: Oracle or OraLinux
    • E.g. RedHat OR redhat, not: Red Hat Enterprise Linux, RHEL, or Red Hat

If the tag is incorrectly formatted, a warning will be printed out at the end of the test run, indicating what tag(s) could not be parsed. This will not halt the execution of other tests.

Once the class is tagged, it is possible to exclude a test for that particular Apache MOD using RSpec's filtering and a helper method:

describe 'auth_oidc', if: mod_supported_on_platform('apache::mod::auth_openidc') do

The mod_supported_on_platform helper method takes the Apache Module class definition as defined in the manifests under manifest/mod.

This functionality can be disabled by setting the DISABLE_MOD_TEST_EXCLUSION environment variable. When set, all exclusions will be ignored.

Test Support Lifecycle

The puppetlabs-apache module supports a large number of compatible platforms and Apache Modules. As a result, Apache Module tests can fail because a package or package dependency has been removed from a Linux distribution repository. The CAT Team will try to resolve these issues and keep instructions updated, but due to limited resources this won’t always be possible. In these cases, we will exclude test(s) from certain platforms. As always, we welcome help from our community members, and the CAT(Content & Tooling) team is here to assist and answer questions.

puppetlabs-apache's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppetlabs-apache's Issues

Allow declaration to override $httpd_dir via parameter

Particularly on RHEL versions, the bundled httpd is many versions behind. For feature or security reasons, many build their own Apache versions and install them in locations with conf dirs other than /etc/httpd.

I propose an httpd_dir parameter passable at class declaration which overrides the OS-default for apache::params::httpd_dir, as follows:

class { 'apache':
httpd_dir = '/usr/local',
}

Cut a new release to moduleforge so mrepo module can be used

Presently the version of the puppetlabs-mrepo module published on module forge requires functionality in puppetlabs-apache that is not in the released version of puppetlabs-apache (namely $custom_fragment in apache::vhost). As such, the mrepo module on moduleforge is useless. Any chance of cutting a new release of this apache module to module forge? (And shooting the mrepo maintainer for not coordinating his/her release with the apache module owners).

ProxyPass configuration should be more flexible and stable

http://www.apachetutor.org/admin/reverseproxies documents the recommended pattern for configuring reverse proxies in a flexible and stable manner. (More resilient to shaky redirects from the backend)

# /foo/bar is handled by the front-end
ProxyPass ! /foo/bar
ProxyPass /foo/ http://backend01-prod/foo/
<Location /foo/>
  ProxyPassReverse /
</Location>

I strongly recommend using this pattern. But more importantly, it would be nice to be able to configure the URI that's supposed to be proxied, rather than just '/'. The exclusion of patterns is a nice-to-have.

Test config before stopping apache

Is it possible to have the module test the apache config before it stops apache?

It could not stop apache is error were detected in the config files, then error out on puppet level, but leaving apache running... Good idea?

Debian not supported?

Hi, i was trying to use this module in my puppet...
but i got this error

Error 400 on SERVER: Class['apache::params']: Unsupported operatingsystem: Debian at /etc/puppet/modules/apache/manifests/params.pp:93 on ....

it may be related to the use of an older version of puppet ... (2.6.X)
isn't it supposed to work?

Thanks

Possibility of setting Apache user groups

I want to use Apache as a webserver for git visualization tool like GitLab or GitList.
Unfortunatelly I need to have option to set that user www-data is part of group git.

But when I tried to set following:

user { 
    'www-data':
        groups => [ 'git', 'www-data' ];
}

I recieve an error, that User with this name is already defined in modules/apache/manifest/init.pp on line 72.

`directories` should support any relevant ability

Currently the apache::vhost::directories parameter takes a hash that can contain:

  • path
  • options
  • allow_override
  • order
  • deny
  • addhandlers
  • extensions
  • passenger_enabled

(NB: these are not fully documented yet.)

It should be modified to support configuration via the other templates/vhost/_*.erb template fragments, ie _rewrite.erb and _custom_fragment.erb via the matching parameters for the fragment without code duplication.

Applying module from manifest using mcollective set .load files wrong

When using the command mco puppet runonce --wi computername from an mcollective server, the .load files do not get set right and apache is unable to start. The error from apache is Starting httpd: httpd: Syntax error on line 139 of /etc/httpd/conf/httpd.conf: Syntax error on line 1 of /etc/httpd/mod.d/actions.load: Cannot load /var/lib/puppet/lib/facter:/var/lib/puppet/facts into server: /var/lib/puppet/lib/facter:/var/lib/puppet/facts: cannot open shared object file: No such file or directory

Actions.load file is as follows:
LoadModule actions_module /var/lib/puppet/lib/facter:/var/lib/puppet/facts

BUT when the puppet agent is run on the machine itself with the command puppet agent --no-daemonize --debug the .load files get set right and apache is able to start without issues.

The environment is CentOS 6.2 Final 64-bit with Apache/2.2.15

Add multiple RackBaseURI (for supporting Passenger)

I'd like to add the ability to specify multiple RackBaseURI for supporting instances with Passenger, where there are multiple rails/rack environments on one virtual host.

As far as I can tell, there's no way to do this in this module right now and its difficult for me to add from the outside (because of the fact that VHost files are managed centrally by the apache module). Therefore the only way for me is to incorporate this feature locally, I'd prefer to get it in the master. Please let me know what you think.

** MORE DETAILS **

For example, I have in my VHost the following configuration. I would like to reproduce this using Apache module.

< VirtualHost *:80>
.....

http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rails_to_sub_uri

Main vhost

DocumentRoot /webroot/
< Directory /webroot/>
.....
< /Directory>

Rack vhost 1

RackBaseURI /vhost1
< Directory /vhost1.files/>
Options -MultiViews
< /Directory>

Rack vhost 2

RackBaseURI /vhost2
< Directory /vhost2.files/>
Options -MultiViews
< /Directory>

..

< /VirtualHost>

Configuration files for mod_php5 should not be installed in vdir on Ubuntu/Debian

Currently a configuration file for mod_php5 gets installed as ${apache::params::vdir}/php.conf. This $apache::params::vdir is ${httpd_dir}/conf.d on RHEL/CentOS and /etc/apache2/sites-enabled on Ubuntu/Debian.

I don't think this is the correct behaviour for Ubuntu/Debian. There, /etc/apache2/sites-enabled should be used solely for virtual host configurations. Regular configuration snippets should be placed in /etc/apache2/conf.d.

In the case of an Apache module the configuration is probably even better placed in /etc/apache2/mods-enabled/<modname>.conf. The php5 module itself is configured this way by the native operating system package (libapache2-mod-php5), so the configuration apache::mod::php manages might even better be merged with that. This goes for other modules as well, such as proxy, userdir and disk_cache, but that is probably better discussed in a separate issue.

In any case I think a variable $apache::params::conf_dir should be introduced for Ubuntu/Debian that points to /etc/apache2/conf.d and used for installing configuration snippets, so /etc/apache2/sites-enabled only contains virtual host definitions. I might submit a PR later when I had some time to test this out.

create_resources vhost support

As it is, it doesn't appear that there's a built in way in this module to create vhosts purely in hiera. This would be something like the various apach::mod::* classes, just calling create resources on a data structure pulled from hiera.

something like this (these names are just placeholders, of course)

class apache::hiera_vhosts ($vhost_data) {

  create_resources('apache::vhost', $vhost_data)

}

apache mod php

i´m using apache2, debian 7 and php 5.3.x

when im trying

apache::mod { 'php': }

its not working. php module not found.

if i try

apache::mod { 'php5': }

its working. but php5.conf will be not created

vhosts configuration file mode

Hello,

I think you should change the vhost file mode in manifests/vhost.pp from 777 to 644.
Why do you want 777 on your vhost configuration files?

Regards,

mookie-

Set default port to listen to?

Is it possible to set the default port to listen to within /etc/apache2/ports.conf?

I am using apache behing nginx and so want the default port to be 81 rather than 80. I can't see any way of doing this at the moment.

Ports file attempted to be created before Apache installed

class { 'apache': }

attempts to create ports.conf file before actual installation of Apache -- before the /etc/apache or similar folder has been created.

Error: Could not set 'file' on ensure: No such file or directory - /etc/apache2/ports.conf.puppettmp_7934 at 154:/tmp/vagrant-puppet/modules-0/concat/manifests/init.pp
Error: Could not set 'file' on ensure: No such file or directory - /etc/apache2/ports.conf.puppettmp_7934 at 154:/tmp/vagrant-puppet/modules-0/concat/manifests/init.pp
Wrapped exception:
No such file or directory - /etc/apache2/ports.conf.puppettmp_7934
Error: /Stage[main]/Apache/Concat[/etc/apache2/ports.conf]/File[/etc/apache2/ports.conf]/ensure: change from absent to file failed: Could not set 'file' on ensure: No such file or directory - /etc/apache2/ports.conf.puppettmp_7934 at 154:/tmp/vagrant-puppet/modules-0/concat/manifests/init.pp

`<Proxy *> deny from all` a horrible default.

<Proxy *> (or any parameter other than *) should only be needed when we configure a forward proxy. That is, when we explicitly configure a forward proxy, that is, when we explicitly set ProxyRequests On. That is by default off in httpd; off in Debian, but Debian goes the extra mile of making all proxy configurations more complicated by having to account for a global setting of <proxy *> deny from all</proxy>

a <Proxy *> block should only be necessary, when ProxyRequests is set to On. In an ideal world, the * would be configurable, too, but lets not get too far ahead of ourselves.

apache::mod::dav_fs uses wrong template

file { 'dav_fs.conf':
  ensure  => file,
  path    => "${apache::mod_dir}/dav_fs.conf",
  content => template('apache/mod/php.conf.erb'),
}

should be:

file { 'dav_fs.conf':
  ensure  => file,
  path    => "${apache::mod_dir}/dav_fs.conf",
  content => template('apache/mod/dav_fs.conf.erb'),
}

[FRQ] Use symlinks on Debian

Feature request: use symlinks in Debian-style configuration tree. Create the actual file in sites-available; create a symlink with target => ../sites-available/${priority}-${name}. Ensure the symlink does not exist if the vhost is disabled.

Real files in /etc/apache2/mods-enabled block package installation

This issue effects Debian based distributions only.

Any packages provided by apt-get that use a2enmod to verify that an apache module has been enabled will fail if there are real files in/etc/apache2/mods-enabled with the error:

ERROR: Module headers not properly enabled: /etc/apache2/mods-enabled/ssl.load is a real file, not touching it

When a package is installed with apt-get you see:

# apt-get install puppetmaster-passenger
Reading package lists... Done
Building dependency tree
Reading state information... Done
puppetmaster-passenger is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Setting up puppetmaster-passenger (3.1.0-1puppetlabs1) ...
ERROR: Module ssl not properly enabled: /etc/apache2/mods-enabled/ssl.load is a real file, not touching it
dpkg: error processing puppetmaster-passenger (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 puppetmaster-passenger
E: Sub-process /usr/bin/dpkg returned an error code (1)

or with puppet:

# puppet apply /etc/puppet/manifests/site.pp
Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install puppetmaster-passenger' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
puppetmaster-passenger is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up puppetmaster-passenger (3.1.0-1puppetlabs1) ...
ERROR: Module ssl not properly enabled: /etc/apache2/mods-enabled/ssl.load is a real file, not touching it
dpkg: error processing puppetmaster-passenger (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 puppetmaster-passenger
E: Sub-process /usr/bin/dpkg returned an error code (1)

Where to put custom vhost templates?

Where should new virtual host templates be located when using this module? Suppose we want to host multiple site-specific Redmine instances in one virtual host that runs behind a reverse proxy (also Apache). I'd write a template that looks like the one below. Where would I put this template? Probably in /etc/puppet/modules/apache/templates, right? But doesn't this violate the principle that one shouldn't have to touch a (3rd-party) module at all just to use it?

The vhost declaration would look like this:

  apache::vhost { $::fqdn:
    ssl                => false,
    priority           => '10',
    port               => '80',
    docroot            => "/var/www/${::fqdn}",
    template           => 'apache/vhost-multiple-redmines.erb',
    configure_firewall => false,
    serveraliases      => [ 'projects.example.com', 'www.projects.example.com', ],
  }

Here's the vhost template:

# vhost-multiple-redmines.conf.erb

<VirtualHost <%= vhost_name %>:<%= port %>>
    ServerName <%= srvname %>
<% if serveradmin %>
    ServerAdmin <%= serveradmin %>
<% end %>

    DocumentRoot <%= docroot %>
    <Directory <%= docroot %>>
        Options <%= options %>
        AllowOverride <%= Array(override).join(' ') %>
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog <%= logroot %>/<%= name %>_error.log
    LogLevel notice
    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined_forwarded
    SetEnvIfNoCase X-Forwarded-For "." from_proxy=1
    ErrorLog  <%= logroot %>/<%= name %>_error.log
    CustomLog <%= logroot %>/<%= name %>_access.log combined env=!from_proxy
    CustomLog <%= logroot %>/<%= name %>_access.log combined_forwarded env=from_proxy

    RackBaseURI /redmineA
    <Directory <%= docroot %>/redmineA>
        Options -MultiViews
    </Directory>   

    RackBaseURI /redmineB
    <Directory <%= docroot %>/redmineB>
        Options -MultiViews
    </Directory>   

    RackBaseURI /redmineC
    <Directory <%= docroot %>/redmineC>
        Options -MultiViews
    </Directory>   

    ServerSignature Off
</VirtualHost>

Vhost should explicitly be name-based, ip-based, or port-based

Currently the apache::vhost accepts a port parameter or an ip_based parameter. If both of these are omitted then it creates a name-based vhost.

apache::vhost should not implicitly resort to port-based, name-based, or ip-based vhosts. It should require one of port => '<integer>', name_based => <bool>, or ip_based => <bool> to determine the type of vhost.

All the use cases from http://httpd.apache.org/docs/current/vhosts/examples.html should still be available.

This would simplify or remove the https://github.com/puppetlabs/puppetlabs-apache/blob/master/manifests/vhost.pp#L203-L223 logic.

Module does not correctly handle multiple RHEL based OS versions.

As the module is written now it cannot handle both RHEL 5 and RHEL 5 based OSes. (This includes the latest Amazon image which appears to be RHEL 6 based.) The issues are:

  • On a RHEL 6 based host Apache cannot start because apache::mod::default references modules that are not present in the Apache package that ships with this OS version.
  • On RHEL based hosts files created by Apache module packages are installed into /etc/httpd/conf.d but are then deleted by this puppet module.
  • The httpd.conf file for RHEL is not usable in a large environment with multiple Apache setups where some hosts may require individualized setup and tweaking.

I think the root of this issue is the module is attempting to manage the contents of httpd.conf unlike it does on Debian. (I understand the reason for this is in the differences between how Debian and RHEL manage Apache setup.) For RHEL what I would propose is the following:

  • Have the module stop managing the contents of httpd.conf. If a consumer needs to manage it's settings they should do it from their infrastructure module.
  • Change $vdir for RHEL to point to ${httpd_dir}/vhosts.d
    • A file can then be dropped into ${httpd_dir}/conf.d to include the config files in ${httpd_dir}/vhosts.d
  • Introduce $confd for both RHEL and Debian and set to ${httpd_dir}/conf.d.
    • Modules that were dropping config files into $vdir should be updated to use $confd
  • Stop using ${httpd_dir}/mod.d on RHEL.
    • RHEL does not have the concept of modules-{available, enabled}. A module is enabled when it is installed on RHEL
  • Stop managing the default modules on RHEL hosts.
    • If httpd.conf is not having its contents managed by the module then it's no longer necessary to do this on RHEL.

Thoughts on these ideas?

default_ssl_vhost is not reconized inside apache

class {'apache': 
    default_ssl_vhost => true,
 }

Drops an error:
Error: Invalid parameter default_ssl_vhost at ......

Or did I misunderstood the usage of the default_ssl_vhost option? Please drop me an example in that case please.

Bug in manifests/mod.pp on SL 6 x86-64

Bug on SL 6 x86-64.

Files /etc/httpd/conf.d/*.conf contains wrond LoadModule line:


LoadModule actions_module modules/


Please add quotation marks in manifests/mod.pp
diff is listed below:


$mod_lib = $mod_libs[$mod] # 2.6 compatibility hack
if $lib {
$lib_REAL = $lib

  • } elsif $mod_lib {
  • } elsif "$mod_lib" {
    $lib_REAL = $mod_lib
    } else {
    $lib_REAL = "mod_${mod}.so"

The -rc1 suffix breaks librarian-puppet

This isn't directly an issue with the puppetlabs-apache project, but it does affect its users, so I thought I'd raise it for discussion.

librarian-puppet uses Rubygems' versioning scheme internally, which does not expect - characters. For pre-release versions, Rubygems uses the format 0.5.0.rc1. In my own fork, I've done a quick-and-dirty hack that allows some mapping between these version formats (dgoodlad/librarian-puppet@996eb9a) but it feels like overkill. Since there's a fair bit of Ruby-focused tooling growing around Puppet, it might be worthwhile following Rubygems' versioning conventions (barring the 0.1.x format, which is already more widely used).

There doesn't seem to be any official guidance from Puppet Labs' documentation around prerelease versions, but I'd argue that it would be best to settle on the Rubygems style.

debian virtual hosts should be created in sites-available with symlink in sites-enabled

The debian convention is to make a file in /etc/apache2/sites-available for each virtual host, and then use the a2ensite script to enable that virtual host.

The a2ensite script sets up a symbolic link pointing to the file from sites-enabled.

This puppet module instead just drops the file right in sites-enabled.

It works OK, but it isn't conventional.

How to disable/uninstall a module?

How can I disable or uninstall an apache module?

For example, if I stop using mod rewrite, I should be able to stop it from being loaded.

Is that functionality that has yet to be written?

"template" parameter is gone

As some colleagues were using this apache module with their hand-rolled templates (which have not so much in common with the template that's coming with the module), 0.7.0 is not really usable for us.

I don't know If I'm the only one running into problems because of this and if it's worth to bring back template support in the old way, but if yes, please tell me here.

make default mods configurable

Right now there are two options, either to enable a rather broad batch of modules that someone found to be a good default set, or to leave them unmanaged all-together.

It would be better to give users the ability to manage their set of default modules.

Dependency problems when vhost configuration/template requires activated module, results in failed puppetrun

The puppetlabs-apache module activates configured apache::vhosts before installing or activating Apache modules like WSGI or Passenger (for the latter I will submit a pull request soon). This is problematic when a (custom) vhost template is to be used that requires, for example, WSGI or Passenger.

An example configuration:

node web01.example.com {
  include 'repos::mod_passenger'
  include 'apache'
  include 'apache::mod::passenger'
  include 'rubygems'

  Class['repos::mod_passenger']
  -> Class['apache']
  -> Class['apache::mod::passenger']
  -> Class['rubygems']

  apache::vhost { $::fqdn:
    priority           => '10',
    port               => '80',
    docroot            => "/var/www/${::fqdn}",
    template           => 'apache/vhost-redmine.conf.erb',
    configure_firewall => false,
  }

Notice the vhost template, which is used to deploy Redmine with Passenger. It contains a stanza like this:

    RackBaseURI /redmine
    <Directory <%= docroot %>/redmine>
        Options -MultiViews
    </Directory> 

What happens here on a pristine node is this:

  1. Apache gets installed, along with explicit dependencies of the vhost, like SSL
  2. The configured vhost gets installed and activated, which notifies the Apache service
  3. Apache wants to restart but chokes because the newly activated vhost contains keywords and configuration stanzas provided by modules that are not yet activated, in this case RackBaseURI. The puppetrun then throws an error because Apache couldn't restart:
Error: /Stage[main]/Apache/Service[httpd]: Could not start Service[httpd]: Execution of '/etc/init.d/apache2 start' returned 1: 
  1. Only now, after Apache couldn't be restarted, the passenger package gets installed and activated:
/Stage[main]/Apache::Mod::Passenger/Package[mod_passenger_package]/ensure: ensure changed 'purged' to 'present'

A subsequent puppetrun is needed for Apache to restart correctly, because now the missing module (passenger) is installed and activated.

What is the proper way to deal with this kind of situation? Explicitly having Apache::Vhost[$::fqdn] depend on Class['apache::mod::passenger'] doesn't work because that introduces a dependency cycle.

Ideally vhosts would only get activated after all modules are installed and enabled. But the way the vhost defined type is written I don't see how this could be done without causing dependency cycles.

Comma in class parameters

Hi,
I use puppet 2.6.18, and my puppet return errors at some manifest files. Errors are related with last comma in class parameters list.

Explanation:
class (
<parameter 1>,
<parameter 2>,
<parameter 3>, # <-- This comma cause error
) {
...
}

Attribute configure_firewall available at the base apache class level

Currently it is only available in the type apache::vhost

If you just use the base class you install apache but you can't open the http port.

You could add an independent firewall resource, but if you include apache more than once (ex : apache required by many other modules), then :

  • you get errors because of multiple declaration if you use the same resource name
    or
  • you have many rules in the live firewall, just to open port 80, and this is not clean

Currently I use a separate module 'apachefw' that just opens the http port and I

include apache
include apachefw

I can't use apache::vhost for the same reason : I include it in other modules and then I would have multiple declarations of the vhost

Cannot specify multiple rewrite_rules

I've tried the obvious

rewrite_rule =>['rule1', 'rule2', ...]

but that didn't work, is there any way to specify multiple rewrite rules for a vhost?

Allow apache::mod to specify explicit module identifier and module path

puppetlabs-apache currently enforces a few standards on module formats which may not be appropriate.

For instance, in the shibboleth module, this is the standard form for declaring the module to apache:

LoadModule mod_shib /opt/shibboleth-sp/lib/shibboleth/mod_shib_22.so

However, this is how puppetlabs-apache creates the LoadModule line:

content => "LoadModule ${mod}_module ${lib_path}/${lib_REAL}\n",

I propose that the apache::mod type accept two new parameters: "identifier" and "path." $path would be override $lib if present, and would allow for explicit setting of the second parameter of the LoadModule configuration directive.

I should have code to submit soon.

vhost flie naming (${priority}-${name}.conf) is not flexible enough

I would like to overwrite some of the apache confs installed by various packages. As an example, on $::osfamily = redhat the ganglia-web rpm provides this file: /etc/httpd/conf.d/ganglia.conf. I would like to directly overwrite that file instead of having to delete it and provide a separate configuration. Would a patch to allow specifying the absolute path of the apache::vhost config file be accepted?

Syntax error at ')' at /etc/puppet/modules/apache/manifests/init.pp:41

Using stdlib-2.6.0 and concat-0.2.0 and apache-0.8.0 via tarballs renamed to stdlib, concat, and apache respectively. No additions, deletions, or edits made to any of the files in the 3 tarballs. Using centos-6.3 with puppet-2.6.17 for master and agent.

The error comes at the end of the parameter list with:
) inherits apache::params {

I can see no syntax error there or anywhere else in that file. I'm using pluginsync = true in case that matters.

Any suggestions?

Any suggestions

Add support for Amazon Linux via 'Linux' OS family fact

Added additional OS family of 'Linux' in case statements and selectors. Currently only the 'debian' and 'redhat' families are supported, but Amazon Linux AMI's report back 'Linux' as their OS family fact.

Also added support for $distrelease to be '3' in params.pp since Amazon reports that fact differently as well.

In all the cases I modified, I used the same parameter as RedHat, since Amazon seems to still very closely match RHEL.

apache::vhost::directories : Allow should not be defined with "deny from all"

Example:

directories => [ { path => '/var/www/youshouldnotbehere', deny => 'from all' } ]

Creates:

  <Directory /var/www/youshouldnotbehere>
    AllowOverride None
    Order allow,deny
    Deny from all
    Allow from all
  </Directory>

The Allow from all part is in fact disabling the Deny from all part.
Defining allow => '' or allow => false has no effect.

I think defining allow => false should remove the Allow rule from the vhost configuration entirely.

Creating a simple vhost leads to depencency cycle

I've created a simple vhost:

    apache::vhost{'default_p':
            port => 80,
            docroot => '/var/www',
    }

Which seems to create a dependency cycle. This happens regardless of if I've previously declared /var/www as a File resource

cycle3

I'm using the master branch of the git repository for the module, and running Puppet 3.1.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.