Giter Club home page Giter Club logo

httpd's Introduction

HTTPD Cookbook

Build Status Cookbook Version

The HTTPD Cookbook is a Library Cookbook that provides resource primitives for use in recipes. It is designed to be an example to reference for creating highly re-usable cross platform cookbooks.

DEPRECATED

This cookbook has been deprecated in favor of the traditional apache2 cookbook

Scope

This cookbook is concerned with The Apache HTTP Server, particularly those shipped with F/OSS Unix and Linux distributions. It does not address other httpd server implementations like Lighttpd, Nginx, or IIS.

Requirements

  • Chef 12.7 or higher
  • Network accessible package repositories

Platform Support

The following platforms have been tested with Test Kitchen:

|----------------+-----+-----|
|                | 2.2 | 2.4 |
|----------------+-----+-----|
| amazon linux   |     | X   |
|----------------+-----+-----|
| debian-8       |     | X   |
|----------------+-----+-----|
| debian-9       |     | X   |
|----------------+-----+-----|
| ubuntu-14.04   |     | X   |
|----------------+-----+-----|
| ubuntu-16.04   |     | X   |
|----------------+-----+-----|
| centos-6       | X   |     |
|----------------+-----+-----|
| centos-7       |     | X   |
|----------------+-----+-----|
| fedora         |     | X   |
|----------------+-----+-----|

Cookbook Dependencies

  • none

Usage

Place a dependency on the httpd cookbook in your cookbook's metadata.rb

depends 'httpd'

Then, in a recipe:

httpd_service 'default' do
  action [:create, :start]
end

httpd_config 'default' do
  source 'mysite.cnf.erb'
  notifies :restart, 'httpd_service[default]'
  action :create
end

Resources Overview

httpd_service

The httpd_service does minimal configuration to get the service up and running. Its parameters can select and tune the multi-processing module, along with a small selection of server-wide configuration options such as listen_ports and run_user.

The :create action handles package installation, support directories, socket files, and other operating system level concerns. The internal configuration file contains just enough to get the service up and running, then loads extra configuration from a conf.d directory. Further configurations are managed with the httpd_config resource.

The :start, :stop, :restart, and :reload actions use the appropriate provider for the platform to respectively start, stop, restart, and reload the service on the machine. You should omit the :start action in recipes designed to build containers.

httpd_service supports multiple Apache instances on a single machine, enabling advanced Apache configuration in scenarios where multiple servers need different loaded modules and global configurations.

Examples

httpd_service 'default' do
  action :create
end

httpd_service 'instance-1' do
  listen_ports ['81', '82']
  action :create
end

httpd_service 'an websites' do
  instance_name 'bob'
  servername 'www.computers.biz'
  version '2.4'
  mpm 'event'
  threadlimit '4096'
  listen_ports ['1234']
  action :create
end

Properties

Most of the parameters on the httpd_service resource map to their CamelCase equivalents found at http://httpd.apache.org/docs/2.4/mod/directives.html

  • contact - The email address rendered into the main configuration file as the ServerAdmin directive.
  • hostname_lookups - Enables DNS lookups on client IP addresses. Can be 'on' 'off' or 'double'. Defaults to 'off'.
  • instance - A string name to identify the httpd_service instance. By convention, this will result in configuration, log, and support directories being created and used in the form '/etc/instance-name', '/var/log/instance-name', etc. If set to 'default', the platform native defaults are used.
  • keepalive - Enables HTTP persistent connections. Values can be true or false.
  • keepalivetimeout - Amount of time the server will wait for subsequent requests on a persistent connection.
  • listen_addresses - IP addresses that the server listens to. Defaults to ['0.0.0.0'].
  • listen_ports - Ports that the server listens to. Defaults to ['80'].
  • log_level - Controls the verbosity of the ErrorLog. Defaults to 'warn'.
  • maxclients - Maximum number of connections that will be processed simultaneously. Valid only with prefork and worker MPMs.
  • maxconnectionsperchild - Limit on the number of connections that an individual child server will handle during its life. Valid with Apache 2.4 prefork, worker and event MPMs.
  • maxkeepaliverequests - Number of requests allowed on a persistent connection. Defaults to 100.
  • maxrequestsperchild - The Apache 2.2 version of maxconnectionsperchild. Still supported as of 2.4
  • maxrequestworkers - Maximum number of connections that will be processed simultaneously. Valid on prefork, worker, and event MPMs.
  • maxspareservers - Maximum number of idle child server processes. Valid only for prefork MPM.
  • maxsparethreads - Maximum number of idle threads. Valid only for worker and event MPMs.
  • minspareservers - Minimum number of idle child server processes. Valid only for preform MPM.
  • minsparethreads - Minimum number of idle threads available to handle request spikes. Valid only for worker and event MPMs.
  • modules - A list of initial Apache modules to be loaded inside the httpd_service instance. Defaults to Debian standard on 2.2 and 2.4.
  • mpm - The Multi-Processing Module to use for the httpd_service instance. Values can be 'prefork', 'worker', and 'event'. Defaults to 'worker' for Apache 2.2 and 'event' for Apache 2.4.
  • package_name - Name of the server package to install on the machine using the system package manager. Defaults to 'apache2' on Debian and 'httpd' on RHEL.
  • run_group - System group to start the httpd_service as. Defaults to 'www-data' on Debian and 'apache' on RHEL.
  • run_user - System user to start the httpd_service as. Defaults to 'www-data' on Debian and 'apache' on RHEL.
  • servername - Hostname and port that the server uses to identify itself. Syntax: [scheme://]fully-qualified-domain-name[:port]. Defaults to node['hostname'].
  • startservers - Number of child server processes created at startup. Valid for prefork, worker, and event MPMs. Default value differs from MPM to MPM.
  • threadlimit - Sets the upper limit on the configurable number of threads per child process. Valid on worker and event MPMs.
  • threadsperchild - Number of threads created by each child process. Valid on worker and event MPMs.
  • timeout - Amount of time the server will wait for certain events before failing a request. Defaults to '400'
  • version - Apache software version to use. Available options are '2.2', and '2.4', depending on platform. Defaults to latest available.

httpd_module

The httpd_module resource is responsible ensuring that an Apache module is installed on the system, as well as ensuring a load configuration snippet is dropped off at the appropriate location.

Examples

httpd_module 'ssl' do
  action :create
end

httpd_module 'el dap' do
  module_name 'ldap'
  action :create
end

httpd_module 'auth_pgsql' do
  instance 'instance-2'
  action :create
end

Properties

  • filename - The filename of the shared object to be rendered into the load config snippet. This can usually be omitted, and defaults to a generated value looked up in an internal map.
  • httpd_version - The version of the httpd_service this module is meant to be installed for. Useful on platforms that support multiple Apache versions. Defaults to the platform default.
  • instance - The httpd_service name to drop the load snippet off for. Defaults to 'default'.
  • module_name - The module name to install. Defaults to the httpd_module name.
  • package_name - The package name the module is found in. By default, this is looked up in an internal map.

httpd_config

The httpd_config resource is responsible for creating and deleting site specific configuration files on the system. There are slight differences in the resource implementation on platforms. The httpd_config resource is a thin wrapper around the core Chef template resource. Instead of a path parameter, httpd_config uses the instance parameter to calculate where the config is dropped off.

Check the Apache HTTP Server Project documentation for configuration specifics based on Apache version.

Examples

httpd_config 'mysite' do
  source 'mysite.erb'
  action :create
end

httpd_config 'computers dot biz ssl_config' do
  config_name 'ssl-config'
  instance 'computers_dot_biz'
  source 'ssl_config.erb'
  action :create
end

Properties

  • config_name - The name of the config on disk
  • cookbook - The cookbook that the source template is found in. Defaults to the current cookbook.
  • httpd_version - Used to calculate the configuration's disk path. Defaults to the platform's native Apache version.
  • instance - The httpd_service instance the config is meant for. Defaults to 'default'
  • source - The ERB format template source used to render the file.
  • variables - A hash of variables passed to the underlying template resource

Maintainers

This cookbook is maintained by Chef's Community Cookbook Engineering team. Our goal is to improve cookbook quality and to aid the community in contributing to cookbooks. To learn more about our team, process, and design goals see our team documentation. To learn more about contributing to cookbooks like this see our contributing documentation, or if you have general questions about this cookbook come chat with us in #cookbok-engineering on the Chef Community Slack

License

Copyright: 2008-2017, Chef Software, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

httpd's People

Contributors

ameir avatar darrylb-github avatar gitter-badger avatar grimm26 avatar hankehly avatar iennae avatar jkeiser avatar joemiller avatar joeybaer avatar juliandunn avatar karmix avatar lamont-granquist avatar mrala avatar nathwill avatar someara avatar tas50 avatar tpetchel avatar yskkin avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

httpd's Issues

allow error_log to be set as httpd_service parameter or node attribute

Cookbook version

0.3.6

Chef-client version

12.8.1

Platform Details

RHEL 7.2

Scenario:

setting the errorlog in httpd.conf to "syslog:local6"

Steps to Reproduce:

There is no support for setting the errorlog in either the httpd_service resource or in a node attribute

In httpd/libraries/httpd_service_rhel.rb, line 200 sets the error_log statically. Allow the use of a resource parameter or a node attribute if possible.

Suggestion: provide a mechanism to delete/manage configuration files

I like the principle behind the httpd_config resource. I would like for it to be able to delete files, as well. Also, allow setting owner/group/permission. A few configuration files might be root-only; Apache should only be able to read those before dropping privileges.

Also allow linking or copying configuration files in /etc/httpd/conf.d . Many RPMs drop their configuration file only there, and you may not necessarily want to manage all of them with chef.

Fails to start: File Not Found

Cookbook version

0.4.4

Chef-client version

12.17.44

Platform Details

CentOS 7.2 on AWS

Scenario:

I'm spinning up test kitchen with the docker driver I'm expecting the HTTP server to create and start.

Steps to Reproduce:

default.rb:

httpd_service 'default' do
  action [:create, :start]
end

append depends 'httpd', '~> 0.4' to your metadata.rb

Expected Result:

test kitchen should report that port 80 is listening.

Actual Result:

    +LoadModule status_module /usr/lib64/httpd/modules/mod_status.so
    - change mode from '' to '0644'
    - change owner from '' to 'root'
    - change group from '' to 'root'


     * httpd_service_rhel_sysvinit[instance1] action start
       * template[/etc/init.d/httpd-instance1] action create

         ================================================================================
         Error executing action `create` on resource 'template[/etc/init.d/httpd-instance1]'
         ================================================================================

         Chef::Exceptions::FileNotFound
         ------------------------------
         Cookbook 'httpd' (0.4.4) does not contain a file at any of these locations:
    templates/centos-7.3.1611/2.4/sysvinit/el-7/httpd.erb
    templates/centos/2.4/sysvinit/el-7/httpd.erb
    templates/default/2.4/sysvinit/el-7/httpd.erb
    templates/2.4/sysvinit/el-7/httpd.erb

         This cookbook _does_ contain: ['/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/mods/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/scripts/a2enmod.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/debian-7/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/el-5/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/el-6/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/ubuntu-10.04/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/ubuntu-12.04/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/mods/rhel/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/scripts/a2enmod.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/sysvinit/el-6/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/sysvinit/ubuntu-14.04/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/envvars.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/httpd.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/magic.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/module_load.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/rhel/sysconfig/httpd-2.2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/rhel/sysconfig/httpd-2.4.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/systemd/httpd.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/systemd/httpd.service.erb']

         Resource Declaration:
         ---------------------
         # In /tmp/kitchen/cache/cookbooks/httpd/libraries/httpd_service_rhel_sysvinit.rb

   12:       template "/etc/init.d/#{apache_name}" do
   13:         source "#{new_resource.version}/sysvinit/el-#{elversion}/httpd.erb"
   14:         owner 'root'
   15:         group 'root'
   16:         mode '0755'
   17:         variables(apache_name: apache_name)
   18:         cookbook 'httpd'
   19:         action :create
   20:       end
   21:

         Compiled Resource:
         ------------------
         # Declared in /tmp/kitchen/cache/cookbooks/httpd/libraries/httpd_service_rhel_sysvinit.rb:12:in `block in <class:HttpdServiceRhelSysvinit>'

         template("/etc/init.d/httpd-instance1") do
    action [:create]
    retries 0
    retry_delay 2
    default_guard_interpreter :default
    source "2.4/sysvinit/el-7/httpd.erb"
    cookbook "httpd"
    variables {:apache_name=>"httpd-instance1"}
    declared_type :template
    cookbook_name "my_cookbook"
    owner "root"
    group "root"
    mode "0755"
    path "/etc/init.d/httpd-instance1"
         end

         Platform:
         ---------
         x86_64-linux


       ================================================================================
       Error executing action `start` on resource 'httpd_service_rhel_sysvinit[instance1]'
       ================================================================================

       Chef::Exceptions::FileNotFound
       ------------------------------
       template[/etc/init.d/httpd-instance1] (/tmp/kitchen/cache/cookbooks/httpd/libraries/httpd_service_rhel_sysvinit.rb line 12) had an error: Chef::Exceptions::FileNotFound: Cookbook 'httpd' (0.4.4) does not contain a file at any of these locations:
         templates/centos-7.3.1611/2.4/sysvinit/el-7/httpd.erb
         templates/centos/2.4/sysvinit/el-7/httpd.erb
         templates/default/2.4/sysvinit/el-7/httpd.erb
         templates/2.4/sysvinit/el-7/httpd.erb

       This cookbook _does_ contain: ['/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/mods/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/scripts/a2enmod.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/debian-7/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/el-5/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/el-6/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/ubuntu-10.04/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/ubuntu-12.04/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/mods/rhel/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/scripts/a2enmod.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/sysvinit/el-6/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/sysvinit/ubuntu-14.04/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/envvars.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/httpd.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/magic.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/module_load.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/rhel/sysconfig/httpd-2.2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/rhel/sysconfig/httpd-2.4.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/systemd/httpd.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/systemd/httpd.service.erb']

       Resource Declaration:
       ---------------------
       # In /tmp/kitchen/cache/cookbooks/my_cookbook/recipes/default.rb

         7: httpd_service 'instance1' do
         8:   action [:create, :start]
         9: end

       Compiled Resource:
       ------------------
       # Declared in /tmp/kitchen/cache/cookbooks/my_cookbook/recipes/default.rb:7:in `from_file'

       httpd_service_rhel_sysvinit("instance1") do
         action [:create, :start]
         updated true
         retries 0
         retry_delay 2
         default_guard_interpreter :default
         declared_type :httpd_service
         cookbook_name "my_cookbook"
         recipe_name "default"
         version "2.4"
         package_name "httpd"
         instance "instance1"
         mpm "event"
         maxclients "0"
         maxconnectionsperchild "0"
         maxrequestworkers "150"
         maxsparethreads "75"
         minsparethreads "25"
         startservers "2"
         threadlimit "64"
         threadsperchild "25"
         run_group "apache"
         run_user "apache"
         servername "c4a061255496"
         modules ["authz_core", "authz_host", "authn_core", "auth_basic", "access_compat", "authn_file", "authz_user", "alias", "dir", "autoindex", "env", "mime", "negotiation", "setenvif", "filter", "deflate", "status"]
         timeout "400"
         log_level "warn"
         maxkeepaliverequests "100"
         keepalivetimeout "5"
         hostname_lookups "off"
         listen_addresses ["0.0.0.0"]
         listen_ports ["80"]
       end

       Platform:
       ---------
       x86_64-linux


   Running handlers:
   [2017-01-20T20:15:36+00:00] ERROR: Running exception handlers
   Running handlers complete
   [2017-01-20T20:15:36+00:00] ERROR: Exception handlers complete
   Chef Client failed. 61 resources updated in 27 seconds
   [2017-01-20T20:15:36+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   [2017-01-20T20:15:36+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
   [2017-01-20T20:15:36+00:00] ERROR: httpd_service_rhel_sysvinit[instance1] (my_cookbook::default line 7) had an error: Chef::Exceptions::FileNotFound: template[/etc/init.d/httpd-instance1] (/tmp/kitchen/cache/cookbooks/httpd/libraries/httpd_service_rhel_sysvinit.rb line 12) had an error: Chef::Exceptions::FileNotFound: Cookbook 'httpd' (0.4.4) does not contain a file at any of these locations:
     templates/centos-7.3.1611/2.4/sysvinit/el-7/httpd.erb
     templates/centos/2.4/sysvinit/el-7/httpd.erb

Support for Ubuntu 16.04

Placeholder in case this isn't on your roadmap yet. The cookbook needs a bit of work to support Ubuntu 16.04. Thanks in advance!

Small incongruency between docs and library code.

The README.md states:

listen_ports - Ports that the server listens to. Defaults to ['80', '443'].

However, libraries/httpd_service.rb states:

property :listen_ports, [String, Array], default: %w(80)

No big deal really, but thought you guys might want to remedy that.

Cookbook incompatibility with yum update

On CentOS (and probably other platforms) this cookbook is partially incompatible with yum update.

The problem is that the RPMs will attempt to restart the service "httpd", which is hardcoded. Restarting fails. Yum still continues, but updates will not be automatically applied.

When there are multiple instances of httpd, there obviously is no good solution for this problem.

When there is only a single instance, I would like to have a way to use the standard CentOS default instance, instead of the new httpd-default instance.

LocalJumpError after conversion to 12.5-style resources

not sure yet exactly what's going wrong here, but we just started hitting this with the latest version of the cookbook

    workspaces_console: [2015-10-26T22:50:21+00:00] INFO: template[/etc/httpd-workspaces/conf.modules.d/rewrite.load] owner changed to 0
    workspaces_console: [2015-10-26T22:50:21+00:00] INFO: template[/etc/httpd-workspaces/conf.modules.d/rewrite.load] group changed to 0
    workspaces_console: [2015-10-26T22:50:21+00:00] INFO: template[/etc/httpd-workspaces/conf.modules.d/rewrite.load] mode changed to 644
    workspaces_console: [2015-10-26T22:50:21+00:00] INFO: Processing httpd_module_rhel[php] action create (treehouse-images::httpd line 24)
    workspaces_console:
    workspaces_console: ================================================================================
    workspaces_console: Error executing action `create` on resource 'httpd_module_rhel[php]'
    workspaces_console: ================================================================================
    workspaces_console:
    workspaces_console: LocalJumpError
    workspaces_console: --------------
    workspaces_console: unexpected return
    workspaces_console:
    workspaces_console: Cookbook Trace:
    workspaces_console: ---------------
    workspaces_console: /tmp/packer-chef-solo/cookbooks-1/httpd/libraries/httpd_module.rb:28:in `block in <class:HttpdModule>'
    workspaces_console: /tmp/packer-chef-solo/cookbooks-1/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb:562:in `instance_exec'
    workspaces_console: /tmp/packer-chef-solo/cookbooks-1/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb:562:in `exec_in_resource'
    workspaces_console: /tmp/packer-chef-solo/cookbooks-1/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb:302:in `get'
    workspaces_console: /tmp/packer-chef-solo/cookbooks-1/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb:251:in `call'
    workspaces_console: /tmp/packer-chef-solo/cookbooks-1/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb:455:in `symbolname'
    workspaces_console: /tmp/packer-chef-solo/cookbooks-1/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:80:in `public_send'
    workspaces_console: /tmp/packer-chef-solo/cookbooks-1/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:80:in `symbolname'
    workspaces_console: /tmp/packer-chef-solo/cookbooks-1/httpd/libraries/httpd_module_rhel.rb:47:in `block (2 levels) in <class:HttpdModuleRhel>'
    workspaces_console: /tmp/packer-chef-solo/cookbooks-1/httpd/libraries/httpd_module_rhel.rb:41:in `block in <class:HttpdModuleRhel>'
    workspaces_console:
    workspaces_console: Resource Declaration:
    workspaces_console: ---------------------
    workspaces_console: # In /tmp/packer-chef-solo/cookbooks-0/treehouse-images/recipes/httpd.rb
    workspaces_console:
    workspaces_console: 24: httpd_module 'php' do
    workspaces_console: 25:   instance 'workspaces'
    workspaces_console: 26: end
    workspaces_console: 27:
    workspaces_console:
    workspaces_console: Compiled Resource:
    workspaces_console: ------------------
    workspaces_console: # Declared in /tmp/packer-chef-solo/cookbooks-0/treehouse-images/recipes/httpd.rb:24:in `from_file'
    workspaces_console:
    workspaces_console: httpd_module_rhel("php") do
    workspaces_console: action [:create]
    workspaces_console: retries 0
    workspaces_console: retry_delay 2
    workspaces_console: default_guard_interpreter :default
    workspaces_console: declared_type :httpd_module
    workspaces_console: cookbook_name :"treehouse-images"
    workspaces_console: recipe_name "httpd"
    workspaces_console: instance "workspaces"
    workspaces_console: module_name "php"
    workspaces_console: httpd_version "2.4"
    workspaces_console: package_name "php"
    workspaces_console: end
    workspaces_console:
    workspaces_console: [2015-10-26T22:50:21+00:00] INFO: Running queued delayed notifications before re-raising exception
    workspaces_console: [2015-10-26T22:50:21+00:00] ERROR: Running exception handlers
    workspaces_console: [2015-10-26T22:50:21+00:00] ERROR: Exception handlers complete
    workspaces_console: [2015-10-26T22:50:21+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out

Please add link to github in supermarket

In the Supermarket.chef.io site, the httpd cookbook does not have a direct link to the github source. That makes it somewhat difficult to find the source, report issues, etc.

package_name could not be resolved with new Amazon Linux 2017.03

Cookbook version

0.4.5

Chef-client version

all

Platform Details

Amazon Linux 2017.03

Scenario:

Install HTTPD

Steps to Reproduce:

Install HTTPD

Expected Result:

HTTPD installed

Actual Result:

Error Message: You must supply a name when declaring a package resource

package_name has no standard value and for AmazonLinux 2017.03 no package name could be found in the local map.
-> Cookbook failing

httpd_module "php" doesn't work on Debian

  httpd_module "php" do
    action :create
  end

This throws an error that the package name must be specified on line 8 of the debian helper.

It does not appear to find the correct module to install. Specifying php5 as the module name appears to work.

  httpd_module "php5" do
    action :create
  end

Cookbook conflicts with mysql (and php)

I came across a problem with a combination of three supermarket cookbooks that appears to be a bug in how they interact.

I am using the httpd cookbook (0.1.5) and the php cookbook (1.5.0). The php cookbook also includes mysql (6.0.3). All this is on CentOS 6.5, although I suspect the problem will affect all OS.

When I just install httpd without php, Apache is configured correctly and starts up flawlessly. When I add the php cookbook (and thus indirectly the mysql cookbook), /etc/httpd/conf/http.conf uses an invalid PidFile location; it uses a location that would be valid for mysql, but not for httpd. Since I'm not installing mysql, that directory doesn't exist.

My suspicion is that both the mysql and httpd cookbooks use the same name "pid_file" at some point, and thus clash.

Here is the generated httpd.conf

ServerName nctc-accounting-berkshelf.vagrant
ServerRoot /etc/httpd
PidFile /var/run/mysql-default/mysqld.pid
User apache
Group apache
Timeout 400
ErrorLog /var/log/httpd/error_log
LogLevel warn
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
DefaultType None
HostnameLookups off

Listen 0.0.0.0:80
Listen 0.0.0.0:443

Include conf.d/.conf
Include conf.d/
.load

httpd_module php for Amazon AMI

Cookbook version

0.4.4

Chef-client version

12.3.0

Platform Details

EC2 using Amazon AMI

Scenario:

Configuring httpd_module 'php' which is not working.
The same works with CentOS 7 with httpd2.4 installed

Steps to Reproduce:

httpd_module 'php' do
instance 'default'
end

Tried with php/ php5, httpd2.2 but it does not work with Amazon AMI.

Expected Result:

Actual Result:

ERROR: httpd_module_rhel[php](AppConfig::default line 26) had an error: ArgumentError: You must supply a name when declaring a package resource

Amazon Linux 2016.03 does not correctly determine package name for httpd_service

Cookbook version

0.4.0

Chef-client version

12.5.1

Platform Details

Amazon Linux 2016.03

Scenario:

Install httpd_service

Steps to Reproduce:

Single recipe with one resource:

httpd_service "default" do
  action [:create, :start]
end

Expected Result:

Installs httpd 2.4

Actual Result:

Stack trace:

  * httpd_service_rhel_sysvinit[default] action create[2016-07-06T11:46:02+00:00] WARN: Default value nil is invalid for property version of resource . Possible fixes: 1. Remove 'default: nil' if nil means 'undefined'. 2. Set a valid default value if there is a reasonable one. 3. Allow nil as a valid value of your property (for example, 'property :version, [ String, nil ], default: nil'). Error: Property version must be one of: String!  You passed nil. at /etc/chef/local-mode-cache/cache/cookbooks/httpd/libraries/helpers.rb:101:in `default_package_name'
[2016-07-06T11:46:02+00:00] WARN: Default value nil is invalid for property package_name of resource . Possible fixes: 1. Remove 'default: nil' if nil means 'undefined'. 2. Set a valid default value if there is a reasonable one. 3. Allow nil as a valid value of your property (for example, 'property :package_name, [ String, nil ], default: nil'). Error: Property package_name must be one of: String!  You passed nil. at /etc/chef/local-mode-cache/cache/cookbooks/httpd/libraries/httpd_service_rhel.rb:12:in `block in <class:HttpdServiceRhel>'


    ================================================================================
    Error executing action `create` on resource 'httpd_service_rhel_sysvinit[default]'
    ================================================================================

    ArgumentError
    -------------
    You must supply a name when declaring a package resource

    Cookbook Trace:
    ---------------
    /etc/chef/local-mode-cache/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_builder.rb:60:in `build'
    /etc/chef/local-mode-cache/cache/cookbooks/httpd/libraries/httpd_service_rhel.rb:12:in `block in <class:HttpdServiceRhel>'
    /etc/chef/local-mode-cache/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:124:in `instance_eval'
    /etc/chef/local-mode-cache/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:124:in `compile_and_converge_action'
    /etc/chef/local-mode-cache/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'

    Resource Declaration:
    ---------------------
    # In /etc/chef/local-mode-cache/cache/cookbooks/my-cookbook/recipes/default.rb

      1: httpd_service 'default' do
      2:   action [:create, :start]
      3: end

    Compiled Resource:
    ------------------
    # Declared in /etc/chef/local-mode-cache/cache/cookbooks/my-cookbook/recipes/default.rb:1:in `from_file'

    httpd_service_rhel_sysvinit("default") do
      action [:create, :start]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :httpd_service
      cookbook_name "my-cookbook"
      recipe_name "default"
    end


Running handlers:
[2016-07-06T11:46:02+00:00] ERROR: Running exception handlers
Running handlers complete
[2016-07-06T11:46:02+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 02 seconds
[2016-07-06T11:46:02+00:00] FATAL: Stacktrace dumped to /etc/chef/local-mode-cache/cache/chef-stacktrace.out
[2016-07-06T11:46:02+00:00] ERROR: httpd_service_rhel_sysvinit[default] (my-cookbook::default line 1) had an error: ArgumentError: You must supply a name when declaring a package resource
[2016-07-06T11:46:03+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Missing mime-type configuration

The generated configuration files do not contain the directives:

TypesConfig
DefaultType

These two directives belong to mod_mime.

At least in Apache 2.2, those two entries are necessary to prevent errors in the log file.

Please be careful fixing this; the change should be well documented since it can break some configurations. Some people, like me, may have already implemented a workaround (creating a new configuration file in conf.d that contains these two directives). Simply adding these two directives in httpd.conf would cause these directives to be duplicates.

CentOS 7 - mod_fcgid error

Cookbook version

0.4.0

Chef-client version

12.12.13

Platform Details

CentOS 7 (fully up-to-date)

Scenario:

Running the application Request Tracker behind httpd.
This requires mod_fcgid, or at least that's the one I'm trying to configure at the moment.

Documentation on this can be found here: https://docs.bestpractical.com/rt/4.4.1/web_deployment.html

Steps to Reproduce:

I have the following setup using a wrapper cookbook in front of the httpd cookbook.

# Create httpd instance
httpd_service 'webserver' do
  listen_ports ['80', '443']
  action [:create, :start]
end

# Install a few modules
%w{ssl unixd fcgid}.each do |mod|
  httpd_module mod do
    instance 'webserver'
    action :create
  end
end

# Create a vhost
httpd_config 'vhost1' do
  config_name 'vhost1'
  source 'vhost1.cnf.erb'
  instance 'webserver'
  notifies :restart, 'httpd_service[webserver]'
  action :create
end

When running I get the following error, this happens during the module installation (or so I think at least).

      Error executing action `start` on resource 'service[httpd-webserver]'

Thus, httpd can't start.

Expected Result:

I would expect everything to start without errors.

Actual Result:

The httpd service can't start. below the root cause of this problem:

systemctl status httpd-webserver -l
● httpd-webserver.service - The Apache HTTP Server
   Loaded: loaded (/etc/systemd/system/httpd-webserver.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since di 2016-07-19 11:28:16 CEST; 4min 54s ago
  Process: 17800 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 17178 ExecReload=/usr/sbin/httpd-webserver -f /etc/httpd-webserver/conf/httpd.conf -k graceful (code=exited, status=0/SUCCESS)
  Process: 17798 ExecStart=/usr/sbin/httpd-webserver -f /etc/httpd-webserver/conf/httpd.conf -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 17798 (code=exited, status=1/FAILURE)

jul 19 11:28:16 webserver.local systemd[1]: Starting The Apache HTTP Server...
jul 19 11:28:16 webserver.local httpd-webserver[17798]: httpd-webserver: Syntax error on line 19 of /etc/httpd-webserver/conf/httpd.conf: Syntax error on line 1 of /etc/httpd-webserver/conf.modules.d/fcgid.load: Cannot load /usr/lib64/httpd/modules/mod_fcgid.so into server: /usr/lib64/httpd/modules/mod_fcgid.so: undefined symbol: ap_unixd_setup_child
jul 19 11:28:16 webserver.local systemd[1]: httpd-webserver.service: main process exited, code=exited, status=1/FAILURE
jul 19 11:28:16 webserver.local kill[17800]: kill: cannot find process ""
jul 19 11:28:16 webserver.local systemd[1]: httpd-webserver.service: control process exited, code=exited status=1
jul 19 11:28:16 webserver.local systemd[1]: Failed to start The Apache HTTP Server.
jul 19 11:28:16 webserver.local systemd[1]: Unit httpd-webserver.service entered failed state.
jul 19 11:28:16 webserver.local systemd[1]: httpd-webserver.service failed.

This gives an error on loading mod_fcgid which is pointing to mod_unixd: "undefined symbol: ap_unixd_setup_child"

After some googeling this has to do with the order in which the modules are loaded. By default everything is loaded in alphabetic order, using this cookbook that means that all modules are loaded in this order:

ls -l /etc/httpd-webserver/conf.modules.d
totaal 104
-rw-r--r--. 1 root root 78 19 jul 11:24 access_compat.load
-rw-r--r--. 1 root root 62 19 jul 11:24 alias.load
-rw-r--r--. 1 root root 72 19 jul 11:24 auth_basic.load
-rw-r--r--. 1 root root 72 19 jul 11:24 authn_core.load
-rw-r--r--. 1 root root 72 19 jul 11:24 authn_file.load
-rw-r--r--. 1 root root 72 19 jul 11:24 authz_core.load
-rw-r--r--. 1 root root 72 19 jul 11:24 authz_host.load
-rw-r--r--. 1 root root 72 19 jul 11:24 authz_user.load
-rw-r--r--. 1 root root 70 19 jul 11:24 autoindex.load
-rw-r--r--. 1 root root 66 19 jul 11:24 deflate.load
-rw-r--r--. 1 root root 58 19 jul 11:24 dir.load
-rw-r--r--. 1 root root 58 19 jul 11:24 env.load
-rw-r--r--. 1 root root 62 19 jul 11:24 fcgid.load
-rw-r--r--. 1 root root 64 19 jul 11:24 filter.load
-rw-r--r--. 1 root root 72 19 jul 11:24 log_config.load
-rw-r--r--. 1 root root 62 19 jul 11:24 logio.load
-rw-r--r--. 1 root root 60 19 jul 11:24 mime.load
-rw-r--r--. 1 root root 70 19 jul 11:24 mpm_event.load
-rw-r--r--. 1 root root 74 19 jul 11:24 negotiation.load
-rw-r--r--. 1 root root 68 19 jul 11:24 setenvif.load
-rw-r--r--. 1 root root 58 19 jul 11:24 ssl.load
-rw-r--r--. 1 root root 64 19 jul 11:24 status.load
-rw-r--r--. 1 root root 66 19 jul 11:24 systemd.load
-rw-r--r--. 1 root root 62 19 jul 11:24 unixd.load
-rw-r--r--. 1 root root 66 19 jul 11:24 version.load
-rw-r--r--. 1 root root 68 19 jul 11:24 watchdog.load

Meaning mod_fcgid is loaded before mod_unixd.

This can be solved by changing the filenames in the directory "/etc/httpd-webserver/conf.modules.d". Being able to set names like e.g. 10-unixd and 20-fcgid would solve this issue.

I've tried doing this with the cookbook in it's current state, but that didn't give me the expected result (it changed the loadmodule line).

This is the snippet:

counter = 0
%w{ssl unixd fcgid}.each do |mod|
  counter = counter + 10
  httpd_module "#{counter}-#{mod}" do
    filename "#{counter}-#{mod}"
    module_name mod
    instance 'webserver'
    action :create
  end
end

This didn't do what I wanted, but if we were allowed to change the filename in conf.modules.d then this would be a way of setting the load order for these modules.

2.4 doesn't default mpm to event

Running this against CentOS 7.0, it's installing 2.4 as expected, but not defaulting mpm to 'event' as the documentation states. 2.2 on CentOS 6.x does default to mpm 'worker,' however. Creating the http_service and setting "mpm 'event'" also doesn't force the issue and still runs prefork on CentOS 7.0.

Resolve Foodcritic FC005 / FC023 warnings

Cookbook version

master

Chef-client version

12.9.38

Platform Details

All

FC005: Avoid repetition of resource declarations: ./libraries/httpd_service_debian.rb:144
FC005: Avoid repetition of resource declarations: ./libraries/httpd_service_debian.rb:304
FC023: Prefer conditional attributes: ./libraries/httpd_service_debian.rb:224
FC023: Prefer conditional attributes: ./libraries/httpd_service_rhel.rb:125
FC023: Prefer conditional attributes: ./libraries/httpd_service_rhel.rb:269
FC023: Prefer conditional attributes: ./libraries/httpd_service_rhel_systemd.rb:6
FC023: Prefer conditional attributes: ./libraries/httpd_service_rhel_sysvinit.rb:5

httpd_service fails if listen_addresses is set

The resource only allows the String type for listen_address even though the default is an Array. This means it will always fail because the template fails expecting an Array to use Array#each and the resource enforces a String and fails if given an Array. All tests currently use nil which is handled as a special case in the template.

httpd_service_rhel_sysvinit.rb wrong number of arguments (0 for 1)

Seeing this with the recent update to the cookbook.

centos6.6
Chef: 12.5.1

================================================================================
           Error executing action `start` on resource 'httpd_service_rhel_sysvinit[test]'
           ================================================================================

           ArgumentError
           -------------
           wrong number of arguments (0 for 1)

           Cookbook Trace:
           ---------------
           /tmp/kitchen/cookbooks/httpd/libraries/httpd_service_rhel_sysvinit.rb:13:in `block (2 levels) in <class:HttpdServiceRhelSysvinit>'
           /tmp/kitchen/cookbooks/httpd/libraries/httpd_service_rhel_sysvinit.rb:12:in `block in <class:HttpdServiceRhelSysvinit>'

what is the 'mysite.conf.erb' files supposed to look like/contain?

I see your readme references some example like mysite.conf.erb. Also in httpd/test/fixtures/cookbooks/httpd_config_test/recipes/default.rb there are some tests for hello.conf.erb and others.
I think some hello_world index files/examples are needed for this cookbook to show what structure/topology is needed to give some site information.

Error using the httpd_service resource when running on chef-client 12.3

After updating to chef-client 12.3 today, the chef-client run fails when attempting to use the httpd_service resource. I have copy and pasted the error output below.

Error executing action create on resource 'httpd_service[default]'

ArgumentError

wrong number of arguments (1 for 0)

Cookbook Trace:

/var/chef/cache/cookbooks/httpd/libraries/helpers_rhel.rb:13:in module_name' /var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb:45:inblock (3 levels) in class:Rhel'
/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb:44:in block (2 levels) in <class:Rhel>' /var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb:43:ineach'
/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb:43:in `block in class:Rhel'

Resource Declaration:

In /var/chef/cache/cookbooks/vshttpd/recipes/default.rb

38: httpd_service 'default' do
39: listen_ports ['80', '443']
40: mpm 'prefork'
41: run_group httpd_run_group
42: run_user httpd_run_user
43: action [:create, :start]
44: end
45:

Compiled Resource:

Declared in /var/chef/cache/cookbooks/vshttpd/recipes/default.rb:38:in `from_file'

httpd_service("default") do
action [:create, :start]
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :httpd_service
cookbook_name "vshttpd"
recipe_name "default"
listen_ports ["80", "443"]
mpm "prefork"
run_group "asterisk"
run_user "asterisk"
end

Suggestion: httpd_config should notify the instance to reload

The httpd_config resource should notify the corresponding instance to reload or restart. Or if it already does that, it should be documented.

The reason I am suggesting this is that the httpd_config resource already knows which service to notify, while the caller should not necessarily care about the service name.

httpd_config should not automatically append .conf

Currently, the httpd_config resource will automatically append .conf to the file name. That prevents this resource from being used with configuration files with other extensions. For instance, I have a file myauthentication.include that sets up some SSL client authentication and is reused/included in several configuration files.

When installing httpd_module 'php' it installs libphp5.so, even though my PHP version is 7

Cookbook version

0.4

Chef-client version

Latest from vagrant, chef_zero.

Platform Details

Vbox bento/centos-6.7

Scenario:

Installing Apache PHP module for PHP 7

Steps to Reproduce:

  1. Use yum-remi-chef for php 7
include_recipe 'yum-remi-chef::remi-php71'
  1. Install Apache module
httpd_module 'php' do
    instance 'apps'
end

Expected Result:

cat /etc/httpd-apps/conf.d/php.load would output libphp7.so

Actual Result:

cat /etc/httpd-apps/conf.d/php.load outputs libphp5.so

Resource creation fails on log_config module when using AWS Linux

I have a client node on AWS running on AWS Linux (RHEL) that is showing the following error during httpd_service creation. This error does not occur when testing locally with test kitchen on a CentOS VM.

Stack Trace from AWS node

Recipe: cascade::apache2
  * httpd_service[cascade-apache2] action create
    * yum_package[cascade-apache2 :create httpd] action install (up to date)
    * service[cascade-apache2 :create httpd] action stop (up to date)
    * service[cascade-apache2 :create httpd] action disable (up to date)
    * yum_package[cascade-apache2 :create net-tools] action install (up to date)
    * httpd_module[cascade-apache2 :create log_config] action create
      * yum_package[cascade-apache2 :create log_config :create ] action install
        * No candidate version available for cascade-apache2 :create log_config :create 
        ================================================================================
        Error executing action `install` on resource 'yum_package[cascade-apache2 :create log_config :create ]'
        ================================================================================

        Chef::Exceptions::Package
        -------------------------
        No candidate version available for cascade-apache2 :create log_config :create 

        Resource Declaration:
        ---------------------
        # In /var/chef/cache/cookbooks/httpd/libraries/provider_httpd_module_rhel.rb

         21:         package "#{new_resource.name} :create #{parsed_module_package_name}" do
         22:           package_name parsed_module_package_name
         23:           action :install
         24:         end
         25: 

        Compiled Resource:
        ------------------
        # Declared in /var/chef/cache/cookbooks/httpd/libraries/provider_httpd_module_rhel.rb:21:in `block in <class:HttpdModuleRhel>'

        yum_package("cascade-apache2 :create log_config :create ") do
          action [:install]
          retries 0
          retry_delay 2
          default_guard_interpreter :default
          package_name "cascade-apache2 :create log_config :create "
          flush_cache {:before=>false, :after=>false}
          declared_type :package
          cookbook_name "cascade"
        end


      ================================================================================
      Error executing action `create` on resource 'httpd_module[cascade-apache2 :create log_config]'
      ================================================================================

      Chef::Exceptions::Package
      -------------------------
      yum_package[cascade-apache2 :create log_config :create ] (/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_module_rhel.rb line 21) had an error: Chef::Exceptions::Package: No candidate version available for cascade-apache2 :create log_config :create 

      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb

       45:             httpd_module "#{new_resource.name} :create #{m}" do
       46:               module_name m
       47:               httpd_version parsed_version
       48:               instance new_resource.instance
       49:               action :create
       50:             end
       51:           end

      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb:45:in `block (2 levels) in <class:HttpdServiceRhel>'

      httpd_module("cascade-apache2 :create log_config") do
        action [:create]
        retries 0
        retry_delay 2
        default_guard_interpreter :default
        declared_type :httpd_module
        cookbook_name "cascade"
        instance "cascade-apache2"
        module_name "log_config"
      end


    ================================================================================
    Error executing action `create` on resource 'httpd_service[cascade-apache2]'
    ================================================================================

    Chef::Exceptions::Package
    -------------------------
    httpd_module[cascade-apache2 :create log_config] (/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb line 45) had an error: Chef::Exceptions::Package: yum_package[cascade-apache2 :create log_config :create ] (/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_module_rhel.rb line 21) had an error: Chef::Exceptions::Package: No candidate version available for cascade-apache2 :create log_config :create 

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/cascade/recipes/apache2.rb

     42: httpd_service 'cascade-apache2' do
     43:   modules ['rewrite', 'ssl', 'proxy', 'proxy_ajp']
     44:   package_name 'httpd'
     45:   action [:create, :start]
     46: end
     47: 

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/cascade/recipes/apache2.rb:42:in `from_file'

    httpd_service("cascade-apache2") do
      action [:create, :start]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :httpd_service
      cookbook_name "cascade"
      recipe_name "apache2"
      modules ["rewrite", "ssl", "proxy", "proxy_ajp"]
      package_name "httpd"
      instance "cascade-apache2"
    end


Running handlers:
[2015-08-06T13:06:22-05:00] ERROR: Running exception handlers
Running handlers complete
[2015-08-06T13:06:22-05:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 13.709229297 seconds
[2015-08-06T13:06:22-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-08-06T13:06:22-05:00] ERROR: httpd_service[cascade-apache2] (cascade::apache2 line 42) had an error: Chef::Exceptions::Package: httpd_module[cascade-apache2 :create log_config] (/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb line 45) had an error: Chef::Exceptions::Package: yum_package[cascade-apache2 :create log_config :create ] (/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_module_rhel.rb line 21) had an error: Chef::Exceptions::Package: No candidate version available for cascade-apache2 :create log_config :create 
[2015-08-06T13:06:23-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Stack Trace from Test Kitchen

Recipe: cascade::apache2
    * yum_package[cascade-apache2 :create httpd] action install (up to date)
 (up to date)
 (up to date)
 (up to date)

 (up to date)
 (up to date)
      * template[cascade-apache2 :create log_config :create /etc/httpd-cascade-apache2/conf.d/log_config.load] action create (up to date)
(up to date)

 (up to date)
 (up to date)
 (up to date)
(up to date)
 (up to date)
    * link[cascade-apache2 :create /usr/sbin/httpd-cascade-apache2.worker] action create (up to date)
    * link[cascade-apache2 :create /usr/sbin/httpd-cascade-apache2.event] action create (up to date)

      * directory[cascade-apache2 :create mpm_worker :create /etc/httpd-cascade-apache2/conf.d] action create (up to date)
 (up to date)
(up to date)
 (up to date)
 (up to date)
 (up to date)
 (up to date)
    * directory[cascade-apache2 :create /var/log/httpd-cascade-apache2] action create (up to date)
    * link[cascade-apache2 :create /etc/httpd-cascade-apache2/logs] action create (up to date)
    * link[cascade-apache2 :create /etc/httpd-cascade-apache2/modules] action create (up to date)
    * directory[cascade-apache2 :create /var/run/httpd-cascade-apache2] action create (up to date)
    * link[cascade-apache2 :create /etc/httpd-cascade-apache2/run] action create (up to date)
 (up to date)
 (up to date)

      * yum_package[cascade-apache2 :create rewrite :create httpd] action install (up to date)
 (up to date)
 (up to date)
(up to date)

 (up to date)
      * directory[cascade-apache2 :create ssl :create /etc/httpd-cascade-apache2/conf.d] action create (up to date)
 (up to date)
(up to date)

      * yum_package[cascade-apache2 :create proxy :create httpd] action install (up to date)
 (up to date)
 (up to date)
(up to date)

      * yum_package[cascade-apache2 :create proxy_ajp :create httpd] action install (up to date)
      * directory[cascade-apache2 :create proxy_ajp :create /etc/httpd-cascade-apache2/conf.d] action create (up to date)
 (up to date)
(up to date)
     (up to date)

 (up to date)
 (up to date)
 (up to date)
 (up to date)
     (up to date)

 (up to date)
 (up to date)
     (up to date)

Running handlers:
Running handlers complete
Chef Client finished, 0/78 resources updated in 9.334210483 seconds
Finished converging <default-centos-65> (0m12.81s).
-----> Kitchen is finished. (0m13.72s)

RHEL 7.2 mod_security module produces mod_security2.so

Cookbook version

0.4.4

Chef-client version

12.7.2

Platform Details

Red Hat Enterprise Linux Server release 7.2 (Maipo)

Scenario:

Install mod_security module

Steps to Reproduce:

Use the httpd_module resource:

httpd_module 'security' do
  action :create
end

Expected Result:

httpd configuration should be consistent, service should be able to start with mod_security enabled.

Actual Result:

  • /usr/lib64/httpd/modules/mod_security.so is not found.
  • httpd-default.service cannot start

Suggested workaround:

httpd_module 'security2' do
  action :create
  module_name 'security2'
  package_name 'mod_security'
end

Suggested fix:

https://github.com/kareiva/httpd/commit/68ef056e8de12fb4baba4d55e04783dcfb572188

Default apache installation

Is it not currently possible to have a default httpd instance with this cookbook? Having apache_name set to "httpd-#{instance}" can cause confusion when using the httpd binary for troubleshooting.

E.g., I was looking to verify which modules were loaded with httpd-#{instance} -M and it shows the modules loaded in /etc/httpd/conf/ and not /etc/httpd-#{instance}/conf.

The service httpd is dead

Cookbook version

[Version of the cookbook where you are encountering the issue]
0.4.4

Chef-client version

[Version of chef-client in your environment]
12.13.37

Platform Details

[Operating system distribution and release version. Cloud provider if running in the cloud]
bento/centos7.2

Scenario:

[What you are trying to achieve and you can't?]
I want httpd to be started and to keep being started

Steps to Reproduce:

[If you are filing an issue what are the things we need to do in order to repro your problem? How are you using this cookbook or any resources it includes?]
Install httpd using this code:

httpd_service 'apps' do
    mpm 'prefork'
    action [:create, :start]
    listen_ports ['80', '443']
    run_user node['webserver']['run_user']  # the value is "vagrant"
end

# Add the site configuration
httpd_config 'apps' do
    instance 'apps'
    source 'apps.conf.erb'
    notifies :restart, 'httpd_service[apps]'
end

# Create document rood directory
directory "#{node['webserver']['document_root']}" do
    recursive true
end

# Homepage
template "#{node['webserver']['document_root']}/index.php" do
    source 'index.php.erb'
    mode '0644'
    owner node['webserver']['user']
    group node['webserver']['group']
    action :create_if_missing
end

# Install the mod_php Apache module.
httpd_module 'php' do
    instance 'apps'
end

# Install memcached
package 'memcached'

# Install php-pecl-memcache
package 'php-pecl-memcache' do
    action :install
    notifies :restart, 'httpd_service[apps]'
end

# Install php-pecl-memcached
package 'php-pecl-memcached' do
    action :install
    notifies :restart, 'httpd_service[apps]'
end

# Install php-mysql
package 'php-mysql' do
    action :install
    notifies :restart, 'httpd_service[apps]'
end

# Install php-pdo
package 'php-pdo' do
    action :install
    notifies :restart, 'httpd_service[apps]'
end

# Install php-intl
package 'php-intl' do
    action :install
    notifies :restart, 'httpd_service[apps]'
end

# Install php-mssql
package 'php-mssql' do
  action :install
  notifies :restart, 'httpd_service[apps]'
end

Expected Result:

[What are you expecting to happen as the consequence of above reproduction steps?]
When I provision, httpd-apps is up and it keeps being up after every http request.

Actual Result:

[What actually happens after the reproduction steps? Include the error output or a link to a gist if possible.]
When I provision, httpd-apps is dead. After I start it (manually: service httpd-apps start) and execute an http request, it dies.

Logs and everything else is in this SO question

httpd service is not installed

Hi,
iam using the cookbook as described but the service installation will never start.
All i get is * httpd_service[default] action create (up to date).
Chef version is 11.10, hhttpd cookbook version 0.2.14 what can i do?

Choosing setup style

Is it possible to choose to use the debian style sites-available and sites-enabled when running on centos / rhel?

From what I can see it will only setup this structure if the platform is detected as debian.

Thanks,
D

ambiguous `version` helper for rhel_sysvinit service provider

https://github.com/chef-cookbooks/httpd/blob/master/libraries/httpd_service_rhel_sysvinit.rb#L13
and
https://github.com/chef-cookbooks/httpd/blob/master/libraries/httpd_service_rhel_sysvinit.rb#L23

refer to a version helper(?) that collides with chef-sugar when they are both in a node's run_list. Modifying both of these lines to use new_resource.version resolves the issue in my environment.

[2015-12-15T15:53:08-05:00] DEBUG: Re-raising exception: ArgumentError - shib_oauth2_bridge[default] (ectg-ucnext::_bridge line 48) had an error: ArgumentError: httpd_service_rhel_sysvinit[shib-oauth2-bridge-default] (/var/chef/cache/cookbooks/shib-oauth2-bridge/libraries/provider_shib_oauth2_bridge.rb line 19) had an error: ArgumentError: wrong number of arguments (0 for 1)
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-sugar-3.2.0/lib/chef/sugar/constraints.rb:137:in `version'
  /var/chef/cache/cookbooks/httpd/libraries/httpd_service_rhel_sysvinit.rb:13:in `block (2 levels) in <class:HttpdServiceRhelSysvinit>'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_builder.rb:77:in `instance_eval'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_builder.rb:77:in `build'
  /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb:109:in `build_resource'
  /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb:67:in `declare_resource'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/dsl/resources.rb:15:in `template'
  /var/chef/cache/cookbooks/httpd/libraries/httpd_service_rhel_sysvinit.rb:12:in `block in <class:HttpdServiceRhelSysvinit>'
  (eval):2:in `block in action_start'
  /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:118:in `instance_eval'
  /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:118:in `compile_and_converge_action'
  (eval):2:in `action_start'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider.rb:144:in `run_action'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource.rb:585:in `run_action'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:49:in `run_action'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `block (2 levels) in converge'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `each'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `block in converge'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/resource_list.rb:83:in `block in execute_each_resource'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/resource_list.rb:81:in `execute_each_resource'
...

httpd_service is broken in 0.4.2

Cookbook version

0.4.2

Chef-client version

12.14.89

Platform Details

Seen on bento/ubuntu-14.04 and bento/centos-7.2, both running on Vagrant/VirtualBox.

Scenario:

httpd_service produces an error. For example,

httpd_service 'customers' do
  mpm 'prefork'
  action [:create, :start]
end

produces an error like:

ERROR: httpd_service_rhel_systemd[customers] (awesome_customers_rhel::web line 7) had an error: ArgumentError: directory[/etc/httpd-customers/conf.modules.d] (/tmp/kitchen/cache/cookbooks/httpd/libraries/httpd_service_rhel.rb line 115) had an error: ArgumentError: wrong number of arguments (given 0, expected 1)

Steps to Reproduce:

Add a httpd_service resource to any recipe. Alternatively:

  1. Clone https://github.com/learn-chef/awesome_customers_rhel or

    https://github.com/learn-chef/awesome_customers_ubuntu

  2. Update metadata.rb (depends 'httpd', '~> 0.4.2')

  3. Run kitchen converge

I've been told it's the latest compat_resource cookbook that breaks things, but I don't understand all the details.

allow error_log to be set as httpd_service parameter or node attribute

Cookbook version

0.3.6

Chef-client version

12.8.1

Platform Details

RHEL 7.2

Scenario:

setting the errorlog in httpd.conf to "syslog:local6"

Steps to Reproduce:

There is no support for setting the errorlog in either the httpd_service resource or in a node attribute

In httpd/libraries/httpd_service_rhel.rb change line 200 sets the error_log statically. Allow the use of a resource parameter or a node attribute if possible.

module file content

Hi,
Unless I've missed something, I don't see a way to specify the content of a module .conf file through httpd_module. Would a 'source' parameter (similar to httpd_config) make sense ?
Something like:

httpd_module 'wsgi' do
action :create
source 'wsgi.conf.erb'
end

Thanks !

Unable to create default service on Amazon Linux

Hi,

I'm getting the following error when trying to create a default instance on Amazon linux using 0.1.5:

================================================================================
Error executing action `create` on resource 'httpd_service[default]'
================================================================================

NoMethodError
-------------
undefined method `each' for nil:NilClass

Cookbook Trace:
---------------
/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb:341:in `create_common'
/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb:19:in `block in <class:Rhel>'

Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/XX_Chef/recipes/xxxx_httpd.rb

  5: httpd_service 'default' do
  6:   action :create
  7: end

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/XX_Chef/recipes/xxxx_httpd.rb:5:in `from_file'

httpd_service("default") do
  action [:create]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  cookbook_name "XX_Chef"
  recipe_name "xxxx_httpd"
  instance "default"
end

[2014-12-14T23:43:42+00:00] INFO: Running queued delayed notifications before re-raising exception
[2014-12-14T23:43:42+00:00] DEBUG: Re-raising exception: NoMethodError - httpd_service[default](XX_Chef::xxxx_httpd line 5) had an error: NoMethodError: undefined method each' for nil:NilClass /var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb:341:increate_common'
/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb:19:in block in <class:Rhel>' /opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:ininstance_eval'
/opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in recipe_eval_with_update_check' /opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:45:inblock in action'
/opt/chef/embedded/apps/chef/lib/chef/provider.rb:145:in run_action' /opt/chef/embedded/apps/chef/lib/chef/resource.rb:654:inrun_action'
/opt/chef/embedded/apps/chef/lib/chef/runner.rb:49:in run_action' /opt/chef/embedded/apps/chef/lib/chef/runner.rb:81:inblock (2 levels) in converge'
/opt/chef/embedded/apps/chef/lib/chef/runner.rb:81:in each' /opt/chef/embedded/apps/chef/lib/chef/runner.rb:81:inblock in converge'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:83:in block in execute_each_resource' /opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:incall'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in call_iterator_block' /opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:85:instep'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:104:in iterate' /opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:55:ineach_with_index'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:81:in execute_each_resource' /opt/chef/embedded/apps/chef/lib/chef/runner.rb:80:inconverge'
/opt/chef/embedded/apps/chef/lib/chef/client.rb:315:in converge' /opt/chef/embedded/apps/chef/lib/chef/client.rb:400:inblock in run'
/opt/chef/embedded/apps/chef/lib/chef/client.rb:399:in catch' /opt/chef/embedded/apps/chef/lib/chef/client.rb:399:inrun'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:261:in block in fork_chef_client' /opt/chef/embedded/apps/chef/lib/chef/application.rb:249:infork'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:249:in fork_chef_client' /opt/chef/embedded/apps/chef/lib/chef/application.rb:215:inblock in run_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/local_mode.rb:38:in with_server_connectivity' /opt/chef/embedded/apps/chef/lib/chef/application.rb:201:inrun_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application/client.rb:355:in block in interval_run_chef_client' /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:345:inloop'
/opt/chef/embedded/apps/chef/lib/chef/application/client.rb:345:in interval_run_chef_client' /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:335:inrun_application'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:58:in run' /opt/chef/embedded/apps/chef/bin/chef-client:26:in<top (required)>'
/usr/bin/chef-client:40:in load' /usr/bin/chef-client:40:in

'

Cannot create/start httpd_service on 2015.03 Amazon AMI Linux Node

I am trying to install onto an Amazon EC2 node running the 2015.03 version of the Amazon Linux AMI. I'm running into an issue where my webserver recipe fails because it cannot create the http_service[customers] resource:

================================================================================
Error executing action `create` on resource 'httpd_service[customers]'
================================================================================

NoMethodError
-------------
undefined method `each' for nil:NilClass 

Cookbook Trace:
---------------
/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel.rb:247:in `block in <class:HttpdServiceRhel>'

Resource Declaration: 
---------------------

# In /var/chef/cache/cookbooks/awesome_customers/recipes/webserver.rb
  2: httpd_service 'customers' do
  3:   mpm 'prefork'
  4:   action [:create, :start]
  5: end
6: 

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/awesome_customers/recipes/webserver.rb:2:in `from_file'

httpd_service("customers") do
  action [:create, :start]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  declared_type :httpd_service
  cookbook_name "awesome_customers"
  recipe_name "webserver"
  mpm "prefork"
  instance "customers"
end

I can manually set the version to either 2.2 or 2.4 in the webserver.rb file, but then it appears to have an issue with my node's platform_version attribute, which doesn't appear to have a default configuration in this community cookbook:

================================================================================
Error executing action `start` on resource 'httpd_service[customers]'
================================================================================

Chef::Exceptions::FileNotFound
------------------------------
template[customers :create /etc/init.d/httpd-customers] (/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_service_rhel_sysvinit.rb line 14) had an error: Chef::Exceptions::FileNotFound: Cookbook 'httpd' (0.2.18) does not contain a file at any of these locations:
  templates/amazon-2015.03/2.4/sysvinit/el-2015/httpd.erb
  templates/amazon/2.4/sysvinit/el-2015/httpd.erb
  templates/default/2.4/sysvinit/el-2015/httpd.erb
  templates/2.4/sysvinit/el-2015/httpd.erb

This cookbook _does_ contain: ['/var/chef/cache/cookbooks/httpd/templates/default/2.2/mods/mpm.conf.erb','/var/chef/cache/cookbooks/httpd/templates/default/2.2/scripts/a2enmod.erb','/var/chef/cache/cookbooks/httpd/templates/default/2.2/sysvinit/debian-7/apache2.erb','/var/chef/cache/cookbooks/httpd/templates/default/2.2/sysvinit/el-6/httpd.erb','/var/chef/cache/cookbooks/httpd/templates/default/2.2/sysvinit/ubuntu-10.04/apache2.erb','/var/chef/cache/cookbooks/httpd/templates/default/2.2/sysvinit/ubuntu-12.04/apache2.erb','/var/chef/cache/cookbooks/httpd/templates/default/2.4/mods/rhel/mpm.conf.erb','/var/chef/cache/cookbooks/httpd/templates/default/2.4/scripts/a2enmod.erb','/var/chef/cache/cookbooks/httpd/templates/default/2.4/sysvinit/el-6/httpd.erb','/var/chef/cache/cookbooks/httpd/templates/default/2.4/sysvinit/ubuntu-14.04/apache2.erb','/var/chef/cache/cookbooks/httpd/templates/default/envvars.erb','/var/chef/cache/cookbooks/httpd/templates/default/httpd.conf.erb','/var/chef/cache/cookbooks/httpd/templates/default/module_load.erb','/var/chef/cache/cookbooks/httpd/templates/default/mpm.conf.erb','/var/chef/cache/cookbooks/httpd/templates/default/rhel/sysconfig/httpd-2.2.erb','/var/chef/cache/cookbooks/httpd/templates/default/rhel/sysconfig/httpd-2.4.erb','/var/chef/cache/cookbooks/httpd/templates/default/systemd/httpd.service.erb','/var/chef/cache/cookbooks/httpd/templates/default/magic.erb','/var/chef/cache/cookbooks/httpd/templates/default/2.2/sysvinit/el-5/httpd.erb']

Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/awesome_customers/recipes/webserver.rb

  2: httpd_service 'customers' do
  3:   version '2.4'
  4:   mpm 'prefork'
  5:   action [:create, :start]
  6: end
  7: 

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/awesome_customers/recipes/webserver.rb:2:in `from_file'

httpd_service("customers") do
  action [:create, :start]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  declared_type :httpd_service
  cookbook_name "awesome_customers"
  recipe_name "webserver"
  version "2.4"
  mpm "prefork"
  instance "customers"
  timeout "400"
  log_level "warn"
  keepalive true
  maxkeepaliverequests "100"
  keepalivetimeout "5"
  hostname_lookups "off"
  listen_addresses ["0.0.0.0"]
  listen_ports ["80"]
end

I'm running chef-client 12.4.1 on both my workstation and the node:

Workstation:

Chef Development Kit Version: 0.7.0
chef-client version: 12.4.1
berks version: 3.2.4
kitchen version: 1.4.2

Node:

chef-client --version
Chef: 12.4.1

Does anyone have any suggestions for how i might resolve this issue?

Please add support to httpd_service for adding LogFormat entries.

I honestly have no need to modify any other config in the default httpd.conf except to add LogFormats used by different setups (behind a load balancer, not behind a load balancer, detailed info, etc).

I don't see any way to add this via the existing resource.

Changing the mpm module results in a fatal configuration error

Changing the mpm module to be used for a httpd_service instance (at least on Ubuntu 14.04) results in 2 enabled mpm module load files and this fatal error while running sudo chef-client:

      STDOUT: * Starting web server apache2
       * 
       * The apache2-example configtest failed.
      STDERR: Output of config test was:
      AH00534: apache2: Configuration error: More than one MPM loaded.
      Action 'configtest' failed.

Deleting one of the mpm module load files in /etc/apache2-example/mods-enabled/ and executing sudo chef-client again solves the problem.

I guess Chef should delete the obsolete mpm module load file if you change the mpm module in your Chef cookbook/recipe, right?

More detailed output:

  * httpd_service_debian_sysvinit[example] action start
    * template[/etc/init.d/apache2-example] action create (up to date)
    * service[apache2-example] action start

      ================================================================================
      Error executing action `start` on resource 'service[apache2-example]'
      ================================================================================

      Mixlib::ShellOut::ShellCommandFailed
      ------------------------------------
      Expected process to exit with [0], but received '1'
      ---- Begin output of /etc/init.d/apache2-example start ----
      STDOUT: * Starting web server apache2
       * 
       * The apache2-example configtest failed.
      STDERR: Output of config test was:
      AH00534: apache2: Configuration error: More than one MPM loaded.
      Action 'configtest' failed.
      The Apache error log may have more information.
      ---- End output of /etc/init.d/apache2-example start ----
      Ran /etc/init.d/apache2-example start returned 1

      Cookbook Trace:
      ---------------
      /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:119:in `compile_and_converge_action'

      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/httpd/libraries/httpd_service_debian_sysvinit.rb

       19:       service "#{apache_name}" do
       20:         supports restart: true, reload: true, status: true
       21:         provider Chef::Provider::Service::Init::Debian
       22:         action [:start, :enable]
       23:       end
       24:     end

      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/httpd/libraries/httpd_service_debian_sysvinit.rb:19:in `block in <class:HttpdServiceDebianSysvinit>'

      service("apache2-example") do
        provider Chef::Provider::Service::Debian
        action [:start, :enable]
        supports {:restart=>true, :reload=>true, :status=>true}
        retries 0
        retry_delay 2
        default_guard_interpreter :default
        service_name "apache2-example"
        pattern "apache2-example"
        declared_type :service
        cookbook_name "solid_webserver"
      end


    ================================================================================
    Error executing action `start` on resource 'httpd_service_debian_sysvinit[example]'
    ================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    service[apache2-example] (/var/chef/cache/cookbooks/httpd/libraries/httpd_service_debian_sysvinit.rb line 19) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
    ---- Begin output of /etc/init.d/apache2-example start ----
    STDOUT: * Starting web server apache2
     * 
     * The apache2-example configtest failed.
    STDERR: Output of config test was:
    AH00534: apache2: Configuration error: More than one MPM loaded.
    Action 'configtest' failed.
    The Apache error log may have more information.
    ---- End output of /etc/init.d/apache2-example start ----
    Ran /etc/init.d/apache2-example start returned 1

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:119:in `compile_and_converge_action'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/solid_webserver/recipes/httpd.rb

      2: httpd_service 'example' do
      3:   mpm 'prefork'
      4:   action [:create, :start]
      5: end
      6: 

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/solid_webserver/recipes/httpd.rb:2:in `from_file'

    httpd_service_debian_sysvinit("example") do
      action [:create, :start]
      updated true
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :httpd_service
      cookbook_name "solid_webserver"
      recipe_name "httpd"
      mpm "prefork"
      version "2.4"
      package_name "apache2"
      instance "example"
      run_user "www-data"
      run_group "www-data"
      servername "localhost"
      maxclients "0"
      maxconnectionsperchild "0"
      maxrequestworkers "150"
      maxspareservers "10"
      minspareservers "5"
      startservers "5"
      modules ["authz_core", "authz_host", "authn_core", "auth_basic", "access_compat", "authn_file", "authz_user", "alias", "dir", "autoindex", "env", "mime", "negotiation", "setenvif", "filter", "deflate", "status"]
      timeout "400"
      log_level "warn"
      keepalive true
      maxkeepaliverequests "100"
      keepalivetimeout "5"
      hostname_lookups "off"
      listen_addresses ["0.0.0.0"]
      listen_ports ["80"]
    end

Order of Include/IncludeOptional directives

The order of the Include (<2.4) and IncludeOptional (>= 2.4) directives for debian/ubuntu installations is defined in httpd/libraries/helpers_debian.rb as

mods-enabled/*.load
conf.d/*.conf
mods-enabled/*.conf

and

mods-enabled/*.load
conf-enabled/*.conf
mods-enabled/*.conf
sites-enabled/*.conf

But the default order of an Apache installation on ubuntu 12.04/14.04 is

mods-enabled/*.load
mods-enabled/*.conf
conf.d/
sites-enabled/

for <2.4 Include and

mods-enabled/*.load
mods-enabled/*.conf
conf-enabled/*.conf
sites-enabled/*.conf

for >=2.4 IncludeOptional directives.

Now, I want to use the default mod configs from an Apache 2.4 installation, turn them into templates and add them to mods-enabled/. But with the order defined by the httpd cookbook my site config is loaded first from conf-enabled/ (it should be located in sites-enabled/, but that is mentioned in #58) and after that the mod configs are loaded from mods-enabled/. So I am no longer able to overwrite a mod config directive in a site config which is bad if I want to reuse my cookbook that wraps the httpd cookbook and contains all the mod config templates.

I would suggest to change the order in httpd/libraries/helpers_debian.rb to the ubuntu default, add sites-enabled/as <2.4 Include and also to fix #58. Then reusing the mod confs and also the confs in conf.d/ or conf-available/ (see also #14) of the Apache installation would be easier.

It does not handle small differences of platform version

Ubuntu 14.10 is seems to be unsupported, because templates/default/2.4/sysvinit/ubuntu-14.10/apache2.erb does not exist.

The error message is appeared by test-kitchen: (sorry for very long message)

         * httpd_service[default] action start
           * template[default :create /etc/init.d/apache2-default] action create

             ================================================================================
             Error executing action `create` on resource 'template[default :create /etc/init.d/apache2-default]'
             ================================================================================

             Chef::Exceptions::FileNotFound
             ------------------------------
             Cookbook 'httpd' (0.2.6) does not contain a file at any of these locations:
        templates/ubuntu-14.10/2.4/sysvinit/ubuntu-14.10/apache2.erb
        templates/ubuntu/2.4/sysvinit/ubuntu-14.10/apache2.erb
        templates/default/2.4/sysvinit/ubuntu-14.10/apache2.erb
        templates/2.4/sysvinit/ubuntu-14.10/apache2.erb

             This cookbook _does_ contain: ['/tmp/kitchen/cache/cookbooks/httpd/templates/default/module_load.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/rhel/sysconfig/httpd-2.4.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/httpd.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/envvars.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/mods/rhel/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/rhel/sysconfig/httpd-2.2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/magic.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/scripts/a2enmod.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/sysvinit/ubuntu-14.04/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/el-5/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/systemd/httpd.service.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/sysvinit/el-6/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/mods/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/scripts/a2enmod.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/debian-7/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/el-6/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/ubuntu-12.04/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/ubuntu-10.04/apache2.erb']

             Resource Declaration:
             ---------------------
       # In /tmp/kitchen/cache/cookbooks/httpd/libraries/provider_httpd_service_debian_sysvinit.rb

       20:             template "#{new_resource.name} :create /etc/init.d/#{apache_name}" do
       21:               path "/etc/init.d/#{apache_name}"
       22:               source "#{apache_version}/sysvinit/#{platform_and_version}/apache2.erb"
       23:               owner 'root'
       24:               group 'root'
       25:               mode '0755'
       26:               variables(apache_name: apache_name)
       27:               cookbook 'httpd'
       28:               action :create
       29:             end
       30:

             Compiled Resource:
             ------------------
             # Declared in /tmp/kitchen/cache/cookbooks/httpd/libraries/provider_httpd_service_debian_sysvinit.rb:20:in `block in <class:Sysvinit>'

             template("default :create /etc/init.d/apache2-default") do
        action [:create]
        retries 0
        retry_delay 2
        default_guard_interpreter :default
        path "/etc/init.d/apache2-default"
        backup 5
        atomic_update true

        cookbook "httpd"
        variables {:apache_name=>"apache2-default"}
        declared_type :template
        cookbook_name "webapps"
        owner "root"
        group "root"
        mode "0755"
             end


           ================================================================================
           Error executing action `start` on resource 'httpd_service[default]'
           ================================================================================

           Chef::Exceptions::FileNotFound
           ------------------------------
           template[default :create /etc/init.d/apache2-default] (/tmp/kitchen/cache/cookbooks/httpd/libraries/provider_httpd_service_debian_sysvinit.rb line 20) had an error: Chef::Exceptions::FileNotFound: Cookbook 'httpd' (0.2.6) does not contain a file at any of these locations:
             templates/ubuntu-14.10/2.4/sysvinit/ubuntu-14.10/apache2.erb
             templates/ubuntu/2.4/sysvinit/ubuntu-14.10/apache2.erb
             templates/default/2.4/sysvinit/ubuntu-14.10/apache2.erb
             templates/2.4/sysvinit/ubuntu-14.10/apache2.erb

           This cookbook _does_ contain: ['/tmp/kitchen/cache/cookbooks/httpd/templates/default/module_load.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/rhel/sysconfig/httpd-2.4.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/httpd.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/envvars.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/mods/rhel/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/rhel/sysconfig/httpd-2.2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/magic.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/scripts/a2enmod.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/sysvinit/ubuntu-14.04/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/el-5/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/systemd/httpd.service.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/sysvinit/el-6/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/mods/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/scripts/a2enmod.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/debian-7/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/el-6/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/ubuntu-12.04/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/ubuntu-10.04/apache2.erb']

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/webapps/recipes/default.rb

        10: httpd_service 'default' do
            11:     action [:create, :start]
            12: end

           Compiled Resource:
           ------------------
       # Declared in /tmp/kitchen/cache/cookbooks/webapps/recipes/default.rb:10:in `from_file'

           httpd_service("default") do
             action [:create, :start]
             updated true
             retries 0

             default_guard_interpreter :default
             declared_type :httpd_service
             cookbook_name "webapps"
             recipe_name "default"
             instance "default"
             timeout "400"
             log_level "warn"
             keepalive true
             maxkeepaliverequests "100"
             keepalivetimeout "5"
             hostname_lookups "off"
             listen_addresses ["0.0.0.0"]

           end


         templates/ubuntu-14.10/2.4/sysvinit/ubuntu-14.10/apache2.erb
         templates/ubuntu/2.4/sysvinit/ubuntu-14.10/apache2.erb
         templates/default/2.4/sysvinit/ubuntu-14.10/apache2.erb
         templates/2.4/sysvinit/ubuntu-14.10/apache2.erb

       This cookbook _does_ contain: ['/tmp/kitchen/cache/cookbooks/httpd/templates/default/module_load.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/rhel/sysconfig/httpd-2.4.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/httpd.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/envvars.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/mods/rhel/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/rhel/sysconfig/httpd-2.2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/magic.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/scripts/a2enmod.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/sysvinit/ubuntu-14.04/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/el-5/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/systemd/httpd.service.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.4/sysvinit/el-6/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/mods/mpm.conf.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/scripts/a2enmod.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/debian-7/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/el-6/httpd.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/ubuntu-12.04/apache2.erb','/tmp/kitchen/cache/cookbooks/httpd/templates/default/2.2/sysvinit/ubuntu-10.04/apache2.erb']

       Running handlers:
       [2015-03-16T02:35:37+00:00] ERROR: Running exception handlers
       Running handlers complete

       [2015-03-16T02:35:37+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       Chef Client failed. 81 resources updated in 42.035333268 seconds
       [2015-03-16T02:35:37+00:00] ERROR: Found 1 errors, they are stored in the backtrace
       [2015-03-16T02:35:38+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> Converge failed on instance <default-ubuntu-1410>.
>>>>>> Please see .kitchen/logs/default-ubuntu-1410.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sh -c '
sudo -E /opt/chef/bin/chef-client --local-mode --config /tmp/kitchen/client.rb --log_level auto --force-formatter --no-color --chef-zero-port 8889 --json-attributes /tmp/kitchen/dna.json
']
>>>>>> ----------------------

I can imagine it properly works after copying templates/default/2.4/sysvinit/ubuntu-14.04/apache2.erb to templates/default/2.4/sysvinit/ubuntu-14.10/apache2.erb.
Is there any major changes in init script in Ubuntu 14.10?
Is this cookbook is only for ubuntu 14.04?

I think the main problem is this cookbook does not handle small differences of platform version like this.

default instance on centos7 - creates empty config file

I tried switching up from version 0.1.5 to 0.2.6, and encountered a problem, with config file creation.

The resource in the recipe is as follows (which works with 0.1.5):

httpd_config 'drupal' do
config_name 'drupal'
instance 'default'
source "drupal-web-env.conf.erb"
action :create
notifies :restart, 'httpd_service[default]'
end

When this runs an /etc/http-default/conf.d directory is created, but the drupal.conf file is empty.

* directory[drupal :create /etc/httpd-default/conf.d] action create[2015-02-12T14:28:52+00:00] INFO: Processing directory[drupal :create /etc/httpd-default/conf.d] action create (/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_config_rhel.rb line 19)

(up to date)
* template[drupal :create /etc/httpd-default/conf.d/drupal.conf] action create[2015-02-12T14:28:52+00:00] INFO: Processing template[drupal :create /etc/httpd-default/conf.d/drupal.conf] action create (/var/chef/cache/cookbooks/httpd/libraries/provider_httpd_config_rhel.rb line 28)
[2015-02-12T14:28:52+00:00] INFO: template[drupal :create /etc/httpd-default/conf.d/drupal.conf] created file /etc/httpd-default/conf.d/drupal.conf

  - create new file /etc/httpd-default/conf.d/drupal.conf
  ================================================================================
  Error executing action `create` on resource 'template[drupal :create /etc/httpd-default/conf.d/drupal.conf]'
  ================================================================================

  Chef::Mixin::Template::TemplateError
  ------------------------------------
  undefined method `[]' for nil:NilClass

  Resource Declaration:
  ---------------------
  # In /var/chef/cache/cookbooks/httpd/libraries/provider_httpd_config_rhel.rb

   28:           template "#{new_resource.name} :create /etc/#{apache_name}/conf.d/#{new_resource.config_name}.conf" do
   29:             path "/etc/#{apache_name}/conf.d/#{new_resource.config_name}.conf"
   30:             owner 'root'
   31:             group 'root'
   32:             mode '0644'
   33:             variables(new_resource.variables)
   34:             source new_resource.source
   35:             cookbook new_resource.cookbook
   36:             action :create
   37:           end
   38:         end

  Compiled Resource:
  ------------------
  # Declared in /var/chef/cache/cookbooks/httpd/libraries/provider_httpd_config_rhel.rb:28:in `block in <class:Rhel>'

I am not in a position to debug right now, as I had to switch back.

httpd pid directory always deleted on vagrant halt on Centos 7.2

Hello,

i install and start the httpd service with following cookbook recipe:

# Install Apache and start the service.
httpd_service 'default' do
  mpm 'prefork'
  action [:create, :start]
end

# Install the mod_php Apache module.
httpd_module 'php' do
  instance 'default'
end

# Install gd.
package 'gd' do
  action :install
end

# Install gd-devel.
package 'gd-devel' do
  action :install
end

# Install php-gd.
package 'php-gd' do
  action :install
end

# Install php-mysql.
package 'php-mysql' do
  action :install
  notifies :restart, 'httpd_service[default]'
end

# Create vhost directories
if node["streaming_evo"]["sites"]

  node["streaming_evo"]["sites"].each do |index, site|

    htdocs = defined?(site["vhost"]["document_root"]) ? site["vhost"]["document_root"] : index

    # Avoid potential duplicate slash in docroot path from config.json input.
    if htdocs.start_with?("/")
      htdocs = htdocs[1..-1]
    end

    # Create subidrectores, allow for multiple layers deep.
    htdocs = "var/www/" + htdocs + "/public_html"
    htdocs = htdocs.split(%r{\/\s*})
    folder = "/"
    for i in (0..htdocs.length - 1)
      folder = folder + htdocs[i] + "/"
      directory folder do
        owner node['streaming_evo']['user']
        group node['streaming_evo']['group']
        mode "0755"
        action :create
      end
    end
  end
end

# Write the home page.
template "#{node['streaming_evo']['document_root']}/index.php" do
  source 'index.php.erb'
  mode '0644'
  owner node['streaming_evo']['user']
  group node['streaming_evo']['group']
  variables(
    :database_password => node['streaming_evo']['mysql_admin_password']
  )
end

# Add the site configuration.
httpd_config 'default' do
  instance 'default'
  source 'vhost.conf.erb'
  notifies :restart, 'httpd_service[default]'
end

After a first vagrant.up and provisioning all works as intended, the local box is reachable via IP or domain names. That's great.

But after a vagrant.halt and vagrant.up the /var/run/httpd-default directory is missing and the httpd-default.pid file cannot be written so starting httpd-default.service quits with an error.

When i do a vagrant.provision on the box again, the directory is created and the httpd-default.pi file can be written.

This gives a systemctl status httpd-default.service

[vagrant@default-centos-72 ~]$ systemctl status httpd-default.service
â— httpd-default.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd-default.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2016-02-25 13:12:22 UTC; 47s ago
  Process: 1020 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 801 ExecStart=/usr/sbin/httpd-default -f /etc/httpd-default/conf/httpd.conf -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 801 (code=exited, status=1/FAILURE)

And the content of /var/log/httpd-default/error_log

[Thu Feb 25 12:26:41.747041 2016] [mpm_prefork:notice] [pid 5250] AH00163: Apache/2.4.6 (CentOS) configured -- resuming normal operations
[Thu Feb 25 12:26:41.747095 2016] [core:notice] [pid 5250] AH00094: Command line: '/usr/sbin/httpd-default -f /etc/httpd-default/conf/httpd.conf -D FOREGROUND'
[Thu Feb 25 12:26:41.881516 2016] [mpm_prefork:notice] [pid 5250] AH00171: Graceful restart requested, doing restart
[Thu Feb 25 12:26:41.884327 2016] [mpm_prefork:notice] [pid 5250] AH00163: Apache/2.4.6 (CentOS) configured -- resuming normal operations
[Thu Feb 25 12:26:41.884339 2016] [core:notice] [pid 5250] AH00094: Command line: '/usr/sbin/httpd-default -f /etc/httpd-default/conf/httpd.conf -D FOREGROUND'
[Thu Feb 25 12:28:04.732534 2016] [mpm_prefork:notice] [pid 5250] AH00170: caught SIGWINCH, shutting down gracefully
[Thu Feb 25 12:28:05.777240 2016] [mpm_prefork:notice] [pid 6742] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
[Thu Feb 25 12:28:05.777269 2016] [core:notice] [pid 6742] AH00094: Command line: '/usr/sbin/httpd-default -f /etc/httpd-default/conf/httpd.conf -D FOREGROUND'
[Thu Feb 25 12:29:32.092324 2016] [mpm_prefork:notice] [pid 6742] AH00170: caught SIGWINCH, shutting down gracefully
[Thu Feb 25 12:30:17.221041 2016] [core:error] [pid 799] (2)No such file or directory: AH00099: could not create /var/run/httpd-default/httpd.pid
[Thu Feb 25 12:30:17.238833 2016] [core:error] [pid 799] AH00100: httpd-default: could not log pid to file /var/run/httpd-default/httpd.pid
[Thu Feb 25 12:35:39.383811 2016] [mpm_prefork:notice] [pid 4982] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
[Thu Feb 25 12:35:39.383845 2016] [core:notice] [pid 4982] AH00094: Command line: '/usr/sbin/httpd-default -f /etc/httpd-default/conf/httpd.conf -D FOREGROUND'
[Thu Feb 25 12:44:43.161934 2016] [mpm_prefork:notice] [pid 4982] AH00170: caught SIGWINCH, shutting down gracefully
[Thu Feb 25 12:45:22.251513 2016] [core:error] [pid 804] (2)No such file or directory: AH00099: could not create /var/run/httpd-default/httpd.pid
[Thu Feb 25 12:45:22.252146 2016] [core:error] [pid 804] AH00100: httpd-default: could not log pid to file /var/run/httpd-default/httpd.pid
[Thu Feb 25 12:54:12.238621 2016] [core:error] [pid 798] (2)No such file or directory: AH00099: could not create /var/run/httpd-default/httpd.pid
[Thu Feb 25 12:54:12.239090 2016] [core:error] [pid 798] AH00100: httpd-default: could not log pid to file /var/run/httpd-default/httpd.pid
[Thu Feb 25 12:56:34.223280 2016] [mpm_prefork:notice] [pid 4971] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
[Thu Feb 25 12:56:34.223313 2016] [core:notice] [pid 4971] AH00094: Command line: '/usr/sbin/httpd-default -f /etc/httpd-default/conf/httpd.conf -D FOREGROUND'
[Thu Feb 25 13:09:47.714565 2016] [mpm_prefork:notice] [pid 4971] AH00170: caught SIGWINCH, shutting down gracefully
[Thu Feb 25 13:12:22.223056 2016] [core:error] [pid 801] (2)No such file or directory: AH00099: could not create /var/run/httpd-default/httpd.pid
[Thu Feb 25 13:12:22.248043 2016] [core:error] [pid 801] AH00100: httpd-default: could not log pid to file /var/run/httpd-default/httpd.pid

Is this an issue of the httpd cookbook?

recent change caused httpd to fail with "cannot load such file -- chef_compat/resource"

As of this morning (few hours ago) I can't seem to converge anything that uses the httpd cookbook. I thought it was my dev machine, reinstalled chefdk, etc and still happening. Error message can be found at the end.

Cookbook version

0.4.0 and 0.3.6

Chef-client version

Host machine running 12.11.18, guest VM running 12.14.60

Platform Details

OSX, Vagrant, Virtualbox

Scenario:

Simply including httpd into metadata.rb and Berksfile causes the above error. Wasn't happening till a few hours ago. Suspecting either a new verison of httpd or chefcompat cookbook has started appearing on my guest VM

Steps to Reproduce:

  1. chef generate cookbook httpduser
  2. edit metadata.rb, add "depends 'httpd'" at the end
  3. edit Berksfile, add "cookbook 'httpd', '> 0.4.0'" at the end. Also tried with "cookbook 'httpd', '> 0.3.6'"
  4. edit .kitchen.yml to use a platform/box you intend, I used:
platforms:
- name: bento/centos-7.2

Run kitchen converge, the above error happens.

Expected Result:

Expecting the converge to finish (httpduser cookbook constructed in reproduction steps doesn't actually do anything, default.rb is blank!).

Actual Result:

Synchronizing Cookbooks:
         - httpduser (0.1.0)
         - httpd (0.4.0)
         - compat_resource (12.14.3)
       Installing Cookbook Gems:
       Compiling Cookbooks...

       ================================================================================
       Recipe Compile Error in /tmp/kitchen/cache/cookbooks/httpd/libraries/helpers.rb
       ================================================================================

       LoadError
       ---------
       cannot load such file -- chef_compat/resource

       Cookbook Trace:
       ---------------
         /tmp/kitchen/cache/cookbooks/httpd/libraries/helpers.rb:1:in `<top (required)>'

       Relevant File Content:
       ----------------------
       /tmp/kitchen/cache/cookbooks/httpd/libraries/helpers.rb:

         1>> require 'chef_compat/resource'
         2:  
         3:  module HttpdCookbook
         4:    module Helpers
         5:      def default_apache_version
         6:        return '2.2' if node['platform_family'] == 'debian' && node['platform_version'].to_i == 7
         7:        return '2.2' if node['platform_family'] == 'debian' && node['platform_version'] == '12.04'
         8:        return '2.2' if node['platform_family'] == 'debian' && node['platform_version'].to_i == 6
         9:        return '2.2' if node['platform_family'] == 'debian' && node['platform_version'].to_i == 7
        10:        return '2.2' if node['platform_family'] == 'omnios'

       Platform:
       ---------
       x86_64-linux


       Running handlers:
       [2016-09-15T04:48:48+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2016-09-15T04:48:48+00:00] ERROR: Exception handlers complete
       Chef Client failed. 0 resources updated in 05 seconds
       [2016-09-15T04:48:48+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2016-09-15T04:48:48+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2016-09-15T04:48:48+00:00] ERROR: cannot load such file -- chef_compat/resource
       [2016-09-15T04:48:48+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

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.