Skip to content

Commit e503b22

Browse files
Add files via upload
1 parent 5b44a73 commit e503b22

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

Chef/Chef.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
--Install Chefdk
2+
curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk -c stable -v 0.18.30
3+
--Check Chefdk version
4+
chef --version
5+
which chef
6+
7+
------------------------First Receipe---------------
8+
Prog1: Create a Chef Reciepe which creates a file /hello.txt and add the content as Hello World
9+
10+
Create a file hello.rb and write the following code
11+
12+
file '/hello.txt' do
13+
content 'Hello World'
14+
end
15+
16+
--Execute above code
17+
sudo chef-client --local-mode hello.rb
18+
19+
--Result :-Check /hello.txt file and that should exist with content Hello World
20+
21+
22+
-----------------Resource Examples
23+
24+
package 'httpd' do
25+
action :install
26+
end
27+
28+
29+
service 'httpd' do
30+
action [ :enable, :start ]
31+
end'
32+
33+
--------Chef Cookbook Examples
34+
35+
chef --help
36+
chef generate --help
37+
chef generate cookbook --help
38+
39+
Let's create a dir called cookbooks
40+
41+
---Create a cookbook called workstation
42+
chef generate cookbook cookbooks/workstation
43+
44+
Create some reciepe in workstataion
45+
46+
chef-client -z --runlist "workstation::setup"
47+
chef-client -z -r "recipe[workstation::setup]"
48+
49+
----How to include a recipe in another recipe
50+
include_recipe 'workstation::setup'
51+
chef-client -z -r "recipe[workstation]"
52+
53+
54+
--------------Template Example
55+
chef generate template cookbooks/workstation/ motd
56+

0 commit comments

Comments
 (0)