# ============================================== | |
# Program Example - 1 | |
# ============================================== | |
['vim', 'ntp', 'git'].each do |package| | |
package package do | |
action :install | |
end | |
end | |
# ============================================== | |
# Program Example -2 | |
# ============================================== | |
packages = ['vim', 'ntp', 'git'] | |
packages.each do |package| | |
package package do | |
action :install | |
end | |
end | |
# ============================================== | |
# Program Example -3 | |
# ============================================== | |
default['createdir']['shared_dir'] = 'shared-lib' | |
default['createdir']['config_dir'] = 'shared-config' | |
default['createdir']['mode'] = 755 | |
default['createdir']['owner'] = "ec2-user" | |
default['createdir']['group'] = "root" | |
[ "/opt/#{node['createdir']['shared_dir']}", "/opt/#{node['createdir']['config_dir']}" ].each do |path| | |
directory path do | |
mode node['createdir']['mode'] | |
owner node['createdir']['owner'] | |
group node['createdir']['group'] | |
recursive true | |
action :create | |
end | |
end | |
# ============================================== | |
# Program Example -4 | |
# ============================================== | |
django.each do |params| | |
node.default["my_app"]["virtual_host"] = params | |
include_recipe "gunicorn::addsite" | |
include_recipe "nginx::addsite" | |
include_recipe "supervisor::addsite" | |
end | |
# ============================================== | |
# Program Example -5 | |
# ============================================== | |
file_array = ['fileX.xml', 'fileY.xml', 'fileZ.xml'] | |
file_array.each do |this_file| | |
cookbook_file "#{utilities_directory}\\" + this_file do | |
source "#{files_directory}/#{this_file}" | |
end | |
end | |
# ============================================== | |
# Program Example -6 | |
# ============================================== | |
%w(fileX.xml fileY.xml fileZ.xml).each do |this_file| | |
cookbook_file "#{utilities_directory}\\" + this_file do | |
source "#{files_directory}/#{this_file}" | |
end | |
end | |
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND