Skip to content

Commit 62288cd

Browse files
Add files via upload
1 parent 2e433ba commit 62288cd

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

Chef/chef.txt

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
wget https://packages.chef.io/files/stable/chef-workstation/21.2.278/ubuntu/20.04/chef-workstation_21.2.278-1_amd64.deb
2+
dpkg -i chef-workstation_21.2.278-1_amd64.deb
3+
-----Verify the Installation
4+
chef -v
5+
--------Uninstall
6+
sudo dpkg -P chef-workstation
7+
8+
9+
10+
-------------------------------------------------------------------
11+
Create first reciepe
12+
-------------------------------------------------------------------
13+
- Create file hello.rb
14+
15+
file '/tmp/hello.txt' do
16+
content 'testing'
17+
end
18+
19+
---Execute the script
20+
chef-client -z hello.rb
21+
-------------------------------------------------------------------------
22+
23+
- Install apache (package.rb)
24+
package 'apache2' do
25+
action :install
26+
end
27+
----Execute Script
28+
chef-client -z package.rb
29+
--------------------------------------------------------------------------
30+
- UnInstall apache (package.rb)
31+
package 'apache2' do
32+
action :purge
33+
end
34+
----Execute Script
35+
chef-client -z package.rb
36+
--------------------------------------------------------------------------
37+
- setup.rb
38+
39+
package 'tree' do
40+
action :install
41+
end
42+
43+
package 'ntp'
44+
45+
file '/etc/motd' do
46+
content 'This server is the property of ...'
47+
end
48+
49+
service 'ntp' do
50+
action [:enable, :start]
51+
end
52+
53+
----Execute Script
54+
chef-client -z setup.rb
55+
---------------------------------------------------------------------------
56+
57+
--------Chef Cookbook Examples
58+
59+
chef --help
60+
chef generate --help
61+
chef generate cookbook --help
62+
mkdir cookbooks
63+
chef generate cookbook cookbooks/workstation
64+
cp setup.rb cookbooks/workstation/recipes/
65+
chef-client -z --runlist "workstation::setup"
66+
chef-client -z -r "recipe[workstation::setup]"
67+
68+
----How to include a recipe in another recipe
69+
open default.rb file and add following code
70+
71+
include_recipe 'workstation::setup'
72+
73+
To Execute it run the following command
74+
chef-client -z -r "recipe[workstation]"
75+
76+

0 commit comments

Comments
 (0)