2
votes

I'm new to Chef and am trying to disable the default site in Apache via a Chef script using Vagrant. I am trying the following:

include_recipe 'apache2'

# disable default site
apache_site '000-default' do
  enable false
end

When I run "Vagrant Up" I get the following error message:

==> default: [2014-10-29T14:16:54+00:00] ERROR: Cookbook apache2 not found. If you're loading apache2 from another cookbook, make sure you configure the dependency in your metadata

==> default: [2014-10-29T14:16:54+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

1

1 Answers

2
votes

I had to add

depends          'apache2','2.0.0'

to the metadata.rb file

or I have found you can just add the following script to your recipe

#disable the default site if it is active
execute "a2dissite default" do
  only_if do
    File.symlink?("/etc/apache2/sites-enabled/000-default")
  end
  notifies :restart, "service[apache2]"
end

service "apache2" do
    action [ :restart ]
end