#
# Cookbook:: .
# Recipe:: lamp
#
# Copyright:: 2020, The Authors, All Rights Reserved.
apache_package = node['lampstack']['apache']['package']
php_packages = node['lampstack']['apache']['php_package']
apt_update 'ubuntu package update' do
ignore_failure true
action :update
only_if { platform?('ubuntu') }
end
package apache_package do
action :install
end
service apache_package do
action :enable
end
package php_packages do
action :install
end
service 'restart apache' do
service_name apache_package
action :restart
end
Now make changes to recipes\default.rb
if platform?('ubuntu') || platform?('redhat')
include_recipe 'lampstack::lamp'
else
Chef::Application.fatal!('This cookbook supports redhat and ubuntu platforms')
end
Now lets converge our resources using kitchen
kitchen converge
Now execute kitchen list
Now the problem in the current recipe is we are writing the same resource service twice
Chef has a concept of Notifications.
Chef Notifications
Notification is a property on resource that listens to other resources in resource collection & takes action based on notification type.