chef generate cookbook apache2
Once the cookbook is created,we have to go for `test` directory,Inside the test directory we have the recipes and the smoke directories.
We have to go through recipes directory
apache2 > test > recipes > we have to create the file (default_test.rb)
Inside this default_test.rb,we have the
# # encoding: utf-8
# Inspec test for recipe apache2::default
# The Inspec reference, with examples and extensive documentation, can be
# found at https://docs.chef.io/inspec_reference.html
# test regular file
#describe file('/etc/httpd/httpd.conf') do
#it { should exist }
#it { should be_file }
#end
describe package 'httpd' do
it { should be_installed }
end
describe service 'httpd' do
it { should be_disabled }
it { should be_running }
end
describe port 80 do
it { should be_listening }
end
These are the test conditions,we have to write before writing the recipes(main) in the cookbook.
-----------------------------------------------------------------------------------------------------------------------
#
# Cookbook Name:: apache2
# Recipe:: default
#
# Copyright 2017, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
package 'httpd'
service 'httpd' do
action %i[enable start]
end
template '/var/www/html/index.html' do
source 'index.html.erb'
end
-------------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment