Difference between revisions of "Chef-apply and receipe syntax"
From Notes_Wiki
(Created page with "<yambe:breadcrumb>Chef|Chef</yambe:breadcrumb> =chef-apply and receipe syntax= ==Using chef to work with a resource== # Download chef development kit from https://downloads....") |
m |
||
Line 1: | Line 1: | ||
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[System administration tools]] > [[Chef|chef]] > [[Chef-apply and receipe syntax]] | |||
==Using chef to work with a resource== | ==Using chef to work with a resource== | ||
Line 61: | Line 60: | ||
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[System administration tools]] > [[Chef|chef]] > [[Chef-apply and receipe syntax]] | |||
Latest revision as of 12:09, 28 July 2022
Home > CentOS > CentOS 6.x > System administration tools > chef > Chef-apply and receipe syntax
Using chef to work with a resource
- Download chef development kit from https://downloads.chef.io/chef-dk/
- Install chef-development kit using rpm
- Create file hello.rb with following contents
- file 'motd' do
- content 'hello world'
- end
- Run 'chef-apply hello.rb'
- Update hello.rb to
- file 'motd' do
- action :delete
- end
- Again run 'chef-apply hello.rb'
Read more about 'file' resource at https://docs.chef.io/resource_file.html or http://docs.chef.io/chef/resources.html#file
Other resources such as service and package can be learned using http://docs.chef.io/chef/resources.html#service and http://docs.chef.io/chef/resources.html#package
Steps learned from https://learn.chef.io/rhel/configure-a-resource/ and subsequent chapters
Chef cookbook basics
- Create folder ~/cookbooks and cd to it.
- Create cookbook using 'chef generate cookbook learn_chef_httpd'
- Create template in new cookbook using:
- chef generate template learn_chef_httpd index.html
- Update learn_chef_httpd/recipes/default.rb with following
- package 'httpd'
- service 'httpd' do
- action [:start, :enable]
- end
- template '/var/www/html/index.html' do
- source 'index.html.erb'
- end
- service 'iptables' do
- action :stop
- end
- chef-client --local-mode --runlist 'recipe[learn_chef_httpd]'
Steps learned from https://learn.chef.io/rhel/make-your-recipe-more-manageable/
Home > CentOS > CentOS 6.x > System administration tools > chef > Chef-apply and receipe syntax