Cookbook:: lab2
Recipe:: default
Copyright:: 2022, The Authors, All Rights Reserved.
node.default['from']['recipe'] = "from recipe"
utilpackages=['vim', 'git', 'curl']
Task 1
template 'testfile' do
source 'sample.erb'
only_if { node.default['apache']['dir'] == '/etc/apache2' }
end
Task 2
log 'message' do
message "#{node['hostname']} and #{node.default['apache']['dir']} and #{node.default['from']['recipe']}"
end
Task 3
file 'writehere.txt' do
content "write a content only when /etc/password not there"
not_if { ::File.exists?('/etc/password') }
end
Task 4
utilpackages.each do |packss|
apt_package packss do
action :install
end
Task 5
file '/tmp/if_only' do
content "write a content only when php installed there"
only_if 'php --version'
end
Task 6
apt_package 'httpd' do
action :install
not_if {node['Platform'] == 'centos'}
end
Top comments (0)