Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reload not working centOs 6.x and apache 2.4 #423

Closed
tb01923 opened this issue Apr 21, 2016 · 7 comments
Closed

reload not working centOs 6.x and apache 2.4 #423

tb01923 opened this issue Apr 21, 2016 · 7 comments

Comments

@tb01923
Copy link

tb01923 commented Apr 21, 2016

I am trying to install onto centOs 6.4 and apache 2.4 version. I have the following attributes:

{
  "apache": {
    "package": "httpd24",
    "devel_package": "httpd24-devel",
    "service_name": "httpd24-httpd",
    "dir": "/opt/rh/httpd24",
    "conf_dir": "/opt/rh/httpd24"
  }
} 

and it looks like everything is going on ok. service enable fizzles out. running this I see the folowing in the console:

Recipe: apache2::default
  * service[apache2] action enable

    ================================================================================
    Error executing action `enable` on resource 'service[apache2]'
    ================================================================================

    Errno::ENOENT
    -------------
    No such file or directory - /usr/sbin/httpd

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

    206: service 'apache2' do
    207:   service_name apache_service_name
    208:   case node['platform_family']
    209:   when 'rhel'
    210:     if node['platform_version'].to_f < 7.0
    211:       restart_command "/sbin/service #{apache_service_name} restart && sleep 1"
    212:       reload_command "/sbin/service #{apache_service_name} graceful && sleep 1"
    213:     end
    214:   when 'debian'

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

    service("apache2") do
      action [:enable, :start]
      supports {:restart=>true, :reload=>true, :status=>true, :start=>true}
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      service_name "httpd24-httpd"
      pattern "apache2"
      restart_command "/sbin/service httpd24-httpd restart && sleep 1"
      reload_command "/sbin/service httpd24-httpd graceful && sleep 1"
      declared_type :service
      cookbook_name "apache2"
      recipe_name "default"
      only_if "/usr/sbin/httpd -t"
    end

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

Further all the service commands work except graceful:

$ sudo service httpd24-httpd graceful
/opt/rh/httpd24/root/usr/sbin/apachectl: line 116: /usr/bin/systemctl: No such file or directory

I dont know where esle to poke around... Any hints appreciated

@svanzoest
Copy link
Contributor

The apache package generally assumes you are using the standard package provided by the operating system. The attributes such as apache.dir should match the package your are installing. Are you doing your own rpm?

@tb01923
Copy link
Author

tb01923 commented Apr 21, 2016

I don't think so. I do install the repo prior to kicking the coobook off:

http://repos.fedorapeople.org/repos/jkaluza/httpd24/epel-httpd24.repo

without that, the cookbook cannot find httpd24. Then there are various failures of the cookbook driving me to use the package name, and then subsequent failures about locations that make things fail without me overriding those attributes. For example - the install defaults to /etc/httpd for a lot of things, but httpd24 isn't getting installed by the package.

My wrapper cookbook currently is:

bash 'yum install epel-httpd24' do
  cwd '/etc/yum.repos.d/'
  code <<-EOH
     cd /etc/yum.repos.d/
     wget http://repos.fedorapeople.org/repos/jkaluza/httpd24/epel-httpd24.repo
  EOH
   not_if { ::File.exists?('/etc/yum.repos.d/epel-httpd24.repo') }
end

include_recipe 'apache2::default'

So I don't know - let me rerun withbout the folder defaults. For example without specifying the conf_dir i end up with this error:

10.6.20.30   * template[apache2.conf] action create
10.6.20.30     * Parent directory /etc/httpd/conf does not exist.
10.6.20.30     ================================================================================
10.6.20.30     Error executing action `create` on resource 'template[apache2.conf]'
10.6.20.30     ================================================================================
10.6.20.30     
10.6.20.30     Chef::Exceptions::EnclosingDirectoryDoesNotExist
10.6.20.30     ------------------------------------------------
10.6.20.30     Parent directory /etc/httpd/conf does not exist.
10.6.20.30     
10.6.20.30     Resource Declaration:
10.6.20.30     ---------------------
10.6.20.30     # In /var/chef/cache/cookbooks/apache2/recipes/default.rb
10.6.20.30     
10.6.20.30     157: template 'apache2.conf' do
10.6.20.30     158:   if platform_family?('rhel', 'fedora', 'arch', 'freebsd')
10.6.20.30     159:     path "#{node['apache']['conf_dir']}/httpd.conf"
10.6.20.30     160:   elsif platform_family?('debian')
10.6.20.30     161:     path "#{node['apache']['conf_dir']}/apache2.conf"
10.6.20.30     162:   elsif platform_family?('suse')
10.6.20.30     163:     path "#{node['apache']['conf_dir']}/httpd.conf"
10.6.20.30     164:   end
10.6.20.30     165:   action :create
10.6.20.30     
10.6.20.30     Compiled Resource:
10.6.20.30     ------------------
10.6.20.30     # Declared in /var/chef/cache/cookbooks/apache2/recipes/default.rb:157:in `from_file'
10.6.20.30     
10.6.20.30     template("apache2.conf") do
10.6.20.30       action [:create]
10.6.20.30       retries 0
10.6.20.30       retry_delay 2
10.6.20.30       default_guard_interpreter :default
10.6.20.30       source "apache2.conf.erb"
10.6.20.30       declared_type :template
10.6.20.30       cookbook_name "apache2"
10.6.20.30       recipe_name "default"
10.6.20.30       mode "0644"
10.6.20.30       owner "root"
10.6.20.30       group "root"
10.6.20.30       path "/etc/httpd/conf/httpd.conf"
10.6.20.30       atomic_update true
10.6.20.30     end
10.6.20.30     
10.6.20.30     Platform:
10.6.20.30     ---------
10.6.20.30     x86_64-linux

@tb01923
Copy link
Author

tb01923 commented Apr 21, 2016

Well I tried to install httpd24 by hand on a fresh VM (centOS 6):

 cd /yum/repos.d
 wget http://repos.fedorapeople.org/repos/jkaluza/httpd24/epel-httpd24.repo
sudo yum install httpd24

And it worked to the same degree as the cookbok. Then running:

sudo service httpd24-httpd graceful
/opt/rh/httpd24/root/usr/sbin/apachectl: line 116: /usr/bin/systemctl: No such file or directory

It doesn't look to be associated with the cookbook at all. It looks tobe completely associated with the httpd24 install. I wonder if a solution is to remove the graceful section of the cookbook and defer to a restart for now?

@tb01923
Copy link
Author

tb01923 commented Apr 21, 2016

I posted on serverfault.com trying to chase this down from a non-cookbook basis (linux/apache) here. Unfortunately this is their reply:

I reproduced it. Don't use "graceful" command for it. Try to use sudo service httpd24-httpd start or sudo service httpd24-httpd restart – Anton ...

The offending lines of code come from: https://github.com/svanzoest-cookbooks/apache2/blob/master/recipes/default.rb

service 'apache2' do
  service_name apache_service_name
  case node['platform_family']
  when 'rhel'
    if node['platform_version'].to_f < 7.0
      restart_command "/sbin/service #{apache_service_name} restart && sleep 1"
      reload_command "/sbin/service #{apache_service_name} graceful && sleep 1"
    end
  when 'debian'
    provider Chef::Provider::Service::Debian
  when 'arch'
    service_name apache_service_name
  end
  supports [:start, :restart, :reload, :status]
  action [:enable, :start]
  only_if "#{node['apache']['binary']} -t", :environment => { 'APACHE_LOG_DIR' => node['apache']['log_dir'] }, :timeout => 10
end

I think the recommendation is to change this line - since garceful and http24 on centos6 doesn't work:

      reload_command "/sbin/service #{apache_service_name} graceful && sleep 1"

or maybe just remove it (i am not a chef expert)? Any thoughts on how to proceed here - I am happy to do what is recommended (including fork -> fix -> pull). The code looks like it was intended for RHEL 6 derivatives - but not properly matched to the http24 code base (or at least no longer properly matched).

@tb01923
Copy link
Author

tb01923 commented Apr 21, 2016

I created a fork/pull to address this: #424 seems to be working for me...

@svanzoest
Copy link
Contributor

svanzoest commented Apr 21, 2016

So it looks like you are using a custom backport package that we currently do not support. The cookbook is developed to support the native httpd, which currently is apache 2.2 on centos 6.

However, via https://www.softwarecollections.org/en/scls/rhscl/httpd24/ you can install the httpd24 package, which looks to be a backport of the centos 7 version.

The changes you are making in #424 seem to mostly revolve around using systemd and httpd24. To enable apache 2.4 behavior you would set apache.version to 2.4. That should be alll that is needed assuming everything else stays the same.

The only thing is that there are still guards that are specific to what version of the rhel platform family your are using that may cause issues. We could adjust that to allow for version 6 of rhel with apache.version set to 2.4. I addressed the guard issue with 1e11c89, so I do not think #424 is needed.

It seems to me that would get you the behavior you are looking for based on the PR you provided.

@lock
Copy link

lock bot commented Jul 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants