apachecentospuppetpuppetlabs-apache

Apache won't start after installing with Puppet


I have installed Apache via puppetlabs/apache and it will not start. I throws the error Address already in use: AH00072: make_sock: could not bind to address regardless of what port is used. netstat -lntp doesn't show anything using the port. My system is CentOS 7 and I am using packages from the centos-sclo-rh repo. Here are the packages I have installed related to this:

$ rpm -qa |grep 'http\|php' |sort
httpd24-1.1-9.el7.x86_64
httpd24-httpd-2.4.12-6.el7.1.x86_64
httpd24-httpd-devel-2.4.12-6.el7.1.x86_64
httpd24-httpd-tools-2.4.12-6.el7.1.x86_64
httpd24-mod_ssl-2.4.12-6.el7.1.x86_64
httpd24-runtime-1.1-9.el7.x86_64
rh-php56-2.0-6.el7.x86_64
rh-php56-php-cli-5.6.5-7.el7.x86_64
rh-php56-php-common-5.6.5-7.el7.x86_64
rh-php56-php-pear-1.9.5-3.el7.noarch
rh-php56-php-pecl-jsonc-1.3.6-3.el7.x86_64
rh-php56-php-process-5.6.5-7.el7.x86_64
rh-php56-php-xml-5.6.5-7.el7.x86_64
rh-php56-runtime-2.0-6.el7.x86_64

And here is my Puppet manifest. Any help would be greatly appreciated.

exec { 'create localhost cert':
  # lint:ignore:80chars
  command   => "/bin/openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -sha256 -subj '/CN=domain.com/O=My Company Name LTD./C=US' -keyout /etc/pki/tls/private/localhost.key -out /etc/pki/tls/certs/localhost.crt",
  # lint:endignore
  creates   => '/etc/pki/tls/certs/localhost.crt',
  logoutput => true,
  before    => Class['apache'],
}

package { 'centos-release-scl-rh':
  ensure => installed,
}

$packages = [
  'httpd24',
  'rh-php56',
  'scl-utils',
]

package { $packages:
  ensure  => installed,
  before  => Class['apache'],
  require => Package['centos-release-scl-rh'],
}

user { 'webmaster':
  ensure => present,
  before => Class['apache'],
}

$scl_httpd = '/opt/rh/httpd24/root'

class { 'apache':
  apache_name           => 'httpd24-httpd',
  apache_version        => '2.4',
  conf_dir              => "${scl_httpd}/etc/httpd/conf",
  confd_dir             => "${scl_httpd}/etc/httpd/conf.d",
  default_mods          => false,
  default_ssl_vhost     => false,
  default_vhost         => false,
  dev_packages          => 'httpd24-httpd-devel',
  docroot               => "${scl_httpd}/var/www/html",
  httpd_dir             => "${scl_httpd}/etc/httpd",
  logroot               => '/var/log/httpd24',
  mod_dir               => "${scl_httpd}/etc/httpd/conf.modules.d",
  mpm_module            => 'worker',
  pidfile               => '/opt/rh/httpd24/root/var/run/httpd/httpd.pid',
  ports_file            => "${scl_httpd}/etc/httpd/conf.d/ports.conf",
  purge_configs         => true,
  serveradmin           => 'root@localhost',
  servername            => 'demobox.example.com',
  server_root           => "${scl_httpd}/etc/httpd",
  service_name          => 'httpd24-httpd',
  trace_enable          => false,
  vhost_dir             => "${scl_httpd}/etc/httpd/conf.d",
  vhost_include_pattern => '*.conf',
}

class { 'apache::dev': }

class { 'apache::mod::ssl':
  package_name => 'httpd24-mod_ssl',
}

apache::vhost { 'main-site-nonssl':
  ip            => '*',
  ip_based      => true,
  port          => '80',
  docroot       => "${scl_httpd}/var/www/main-site",
#  docroot_owner => 'webmaster',
#  docroot_group => 'webmaster',
}

apache::vhost { 'main-site-ssl':
  ip            => '*',
  ip_based      => true,
  port          => '443',
  docroot       => "${scl_httpd}/var/www/main-site",
#  docroot_owner => 'webmaster',
#  docroot_group => 'webmaster',
  ssl           => true,
  ssl_cert      => '/etc/pki/tls/certs/localhost.crt',
  ssl_key       => '/etc/pki/tls/private/localhost.key',
}

Solution

  • It turned out that I had placed ports.conf in conf.d instead of conf which meant it was being included twice. Changing ports_file => "${scl_httpd}/etc/httpd/conf.d/ports.conf", to ports_file => "${scl_httpd}/etc/httpd/conf/ports.conf", resolved the issue.