I am learning chef at the moment using OpsWorks , currently I am trying to create a recipe that will install 2 package in one instance. I stored my cookbook on github.. there I have a recipe that is like this - webserver.rb
# Install apache and start the service
httpd_service 'site' do
mpm 'prefork'
action [:create, :start]
end
# Add the site configuration
httpd_config 'site' do
instance 'site'
source 'site.conf.erb'
notifies :restart, 'httpd_service[site]'
end
#create the document root directory
#directory '/var/www/public_html' do
# recursive true
#end
#write the homepage
file '/var/www/index.html' do
content '<html>This is a web</html>'
mode '0644'
owner 'web_admin'
group 'web_admin'
end
# Install apache , config and etc END
# Install the mod_php5 apache module
httpd_module 'php' do
instance 'site'
end
#install php5-mysql
package 'php-mysql' do
action :install
notifies :restart, 'httpd_service[site]'
end
#write the homepage
file '/var/www/index2.php' do
content '<html><?php echo phpinfo(); ?></html>'
mode '0644'
owner 'web_admin'
group 'web_admin'
end
I am following the tutorial in AWS creating a LAMP environment. Unfortunately when I run this to my Instance , opsworks_cookbook_demo::default (it will run some include , including webserver.) am getting error that precondition httpd cookbook not found
, I already added on my metadaba.rb depends 'httpd' '~> ..' ,Can someone guide me what the wrong doing here. Coz I assume whenever you put depends 'httpd' it will extend my cookbook to use that cookbook.
Do I need berkshelf for this case? (Currently I am using AWS OpsWorks and have my recipe in github)
You have to download all the dependencies ahead of time to feed to OpsWorks. See https://docs.aws.amazon.com/opsworks/latest/userguide/best-practices-packaging-cookbooks-locally.html for more info. The older Chef 11 stacks used to somewhat automate this for you by running berks vendor
on the target, but now you need to do that yourself on your workstation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With