Separate config template to partial template
Source: https:/
Should mark this blueprint as duplicated.
There are some common section/options in the configuration file of all the OpenStack projects, we can put the same section/options in one Chef partial templates and reference it in all cookbooks.
We should use attribute direct access in templates, no variables, this will also allow users easy to update the configuration file through attributes in Chef environment file.
I will take database section as an example, the changes are:
1. In openstack-common cookbooks:
* Add a partial template file `templates/
[database]
backend=<%= node['openstack
connection=<%= node['openstack
* Update database attribute file like:
%w(identity compute ...).each do |project|
default[
db_user = ...
db_pass = get_password('db', project)
default[
end
2. In openstack-project cookbooks:
* In recipes, add a template resource like:
template '/etc/project/
source 'project.conf.erb'
variables(
project: 'project_name',
partials: {
'
}
)
end
* In templates, add something like:
<% @partials.each do |partial, cookbook| %>
<%= render partial, :cookbook => cookbook %>
<% end %>