Skip to content
This repository was archived by the owner on Jul 25, 2018. It is now read-only.

Apache not started after reboot #116

@e21347

Description

@e21347

Cookbook version

0.4.5

Chef-client version

12.21.1

Platform Details

Ubuntu 16.04

Scenario:

Getting apache to start after reboot without having to run chef-client again.

Steps to Reproduce:

# metadata.rb
...
depends 'apt', '~> 6.1.0'
depends 'httpd', '~> 0.4.5'
# recipes/default.rb

include_recipe 'apt::default'

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

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

<VirtualHost *:80>
  DocumentRoot /var/www/html

  ErrorLog /var/log/apache2-default/error.log
  LogFormat "%v:%p %a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
  CustomLog /var/log/apache2-default/access.log vhost_combined
</VirtualHost>

kitchen converge
kitchen login

(all is good at this point)

vagrant@default-ubuntu-1604:~$ sudo reboot

Expected Result:

Apache started after reboot.

Actual Result:

Apache cannot be started after reboot. /var/lock/apache2-default is missing.

vagrant@default-ubuntu-1604:~$ systemctl status apache2-default.service
● apache2-default.service - The Apache HTTP Server
   Loaded: loaded (/etc/systemd/system/apache2-default.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2017-06-22 05:51:04 UTC; 10min ago
  Process: 1208 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 1144 ExecStart=/usr/sbin/apache2 -f /etc/apache2-default/apache2.conf -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 1144 (code=exited, status=1/FAILURE)

Jun 22 05:51:04 default-ubuntu-1604 systemd[1]: Started The Apache HTTP Server.
Jun 22 05:51:04 default-ubuntu-1604 apache2[1144]: AH00526: Syntax error on line 6 of /etc/apache2-default/apache2.conf:
Jun 22 05:51:04 default-ubuntu-1604 apache2[1144]: Invalid Mutex directory in argument file:/var/lock/apache2-default
Jun 22 05:51:04 default-ubuntu-1604 systemd[1]: apache2-default.service: Main process exited, code=exited, status=1/FAILURE
Jun 22 05:51:04 default-ubuntu-1604 kill[1208]: kill: failed to parse argument: '': No such file or directory
Jun 22 05:51:04 default-ubuntu-1604 systemd[1]: apache2-default.service: Control process exited, code=exited status=1
Jun 22 05:51:04 default-ubuntu-1604 systemd[1]: apache2-default.service: Unit entered failed state.
Jun 22 05:51:04 default-ubuntu-1604 systemd[1]: apache2-default.service: Failed with result 'exit-code'.
# /etc/apache2-default/apache2.conf
ServerName default-ubuntu-1604
ServerRoot /etc/apache2-default
PidFile /var/run/apache2/apache2-default.pid
User www-data
Group www-data
Mutex file:/var/lock/apache2-default default
Timeout 400
ErrorLog /var/log/apache2-default/error_log
LogLevel warn
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
DefaultType None
HostnameLookups off

Listen 0.0.0.0:80

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions