L24 – Create cookbook versions for use in the environments
To create a second version of the apache cookbook
$cd chef-repo/cookbooks/apache/attributes
$vi defualt.rb AND ADD THE LINE
default[“author”][“name”] = “PaulH”
$cd ../recipes
$vi default.rb ADD the author attribute
Change the index.html creation to:
template “/var/www/#{sitename}/index.html” dosource “index.html.erb”
mode “0644”
variables ({
:site_title=>data[“site_title”],
:tobewritten=>”To Be Written”,
:author_name=>node[“author”][“name”]
})
notifies :restart, “service[httpd]”
end
$ cd ../templates/default
$ vi index.html.erb
add a heading line e.g.H2 H2
$ cd ../../
$ vi metadata.rb
Change
version      ‘0.1.0’
TO
version      ‘0.1.5’
$ knife cookbook upload apache
Using the website we can see that the current apache version is 0.1.5
So lets make DEV use this version and we’ll set live to use 0.1.0
BUT
The author name won’t be changed in DEV because we set up an override_attribute in the DEV environment file which overrides and values set in the particular cookbooks used.
If we remove the override_attribute then the new author_name would be displayed.
SO
Discussion ¬