Last active
          May 31, 2016 16:41 
        
      - 
      
- 
        Save nathenharvey/9134977 to your computer and use it in GitHub Desktop. 
    vhosts recipe for one-day Introduction to Chef workshop
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | data_bag("vhosts").each do |site| | |
| site_data = data_bag_item("vhosts", site) | |
| site_name = site_data["id"] | |
| document_root = "/srv/apache/#{site_name}" | |
| template "/etc/httpd/conf.d/#{site_name}.conf" do | |
| source "custom-vhosts.erb" | |
| mode "0644" | |
| variables( | |
| :document_root => document_root, | |
| :port => site_data["port"] | |
| ) | |
| notifies :restart, "service[httpd]" | |
| end | |
| directory document_root do | |
| mode "0755" | |
| recursive true | |
| end | |
| template "#{document_root}/index.html" do | |
| source "index.html.erb" | |
| mode "0644" | |
| variables( | |
| :site_name => site_name, | |
| :port => site_data["port"] | |
| ) | |
| end | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Hi,
I have been following tutorial for chef and could see this code into the tutorial by Nathen, Can anyone explain this code please?