Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dovecot settings #9

Closed
llonchj opened this issue Apr 7, 2014 · 5 comments
Closed

dovecot settings #9

llonchj opened this issue Apr 7, 2014 · 5 comments

Comments

@llonchj
Copy link
Contributor

llonchj commented Apr 7, 2014

FIrst of all, thanks for the cookbook.

I am trying to get my head around the conf_files.rb and I do not understand the reason why templates are set for action :nothing.

I thought the standard way was to be change a template and reload the service if a setting changes.

Do you have a plan to standardize the cookbook with the way templates operate?

Thanks,
Jordi

@zuazo
Copy link
Owner

zuazo commented Apr 7, 2014

Yeah. I know that maybe this code can be improved. But there is a reason for this non-standard behavior.

The configuration files are created depending on the packages installed. In each distribution, each package installs its configuration files. So if, for example, the sieve package is installed, this cookbook will generate the sieve configuration files, but not the other. This facilitates homogenizing the different behavior between distributions, packages and its configuration files, avoiding the creation of unnecessary configuration files.

To understand the conf_file.rb recipe correctly, you should read the ruby_blocks inside the from_package.rb recipe. There, the required plugins are calculated searching inside node["conf"] and node["protocols"] attributes. Then, the required packages are installed, and the correct templates notified using the node["conf_files"] attribute.

The templates are notified every chef-run from there, so the config files are updated correctly on configuration changes. Or at least that's what I meant when I did.

Maybe adding a comment about this in the code would not be a bad idea. If this quick and poor explanation has not been clear enough, please feel free to ask me again.

@llonchj
Copy link
Contributor Author

llonchj commented Apr 7, 2014

Thanks for your explanation.

I am only implementing build from source based on ubuntu 13.10 at the
moment.

It is a bit challenging trying to implement the from_source.rb with this
template behavior because, at this stage, the recipe is not able to notify
templates if dovecot or pigeonhole is already compiled.

Do you have an idea on how to proceed?

Regards,

2014-04-08 2:45 GMT+10:00 Xabier de Zuazo notifications@github.com:

Yeah. I know that maybe this code can be improved. But there is a reason
for this non-standard behavior.

The configuration files are created depending on the packages installed.
In each distribution, each package installs its configuration files. So if,
for example, the sieve package is installed, this cookbook will generate
the sieve configuration files, but not the other. This facilitates
homogenizing the different behavior between distributions, packages and its
configuration files, avoiding the creation of unnecessary configuration
files.

To understand the conf_file.rb recipe correctly, you should read the
ruby_blocks inside the from_package.rb recipe. There, the required
plugins are calculated searching inside node["conf"] and node["protocols"]attributes. Then, the required packages are installed, and the correct
templates notified using the node["conf_files"] attribute.

The templates are notified every chef-run from there, so the config files
are updated correctly on configuration changes. Or at least that's what I
meant when I did.

Maybe adding a comment about this in the code would not be a bad idea. If
this quick and poor explanation has not been clear enough, please feel free
to ask me again.

Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-39754082
.

@zuazo
Copy link
Owner

zuazo commented Apr 10, 2014

Sorry, I have not had time to look at this in detail.

I would try to find out a way to report the templates depending on how you have compiled dovecot. Perhaps using ruby_blocks similar to the from_package recipe in the from_source recipe.

But if it turns out to be too complicated or tricky, I would try to move the ruby_blocks logic to a library. Then, use this library to both install the packages and generate the templates. Something like the following (simplified pseudo-ruby):

# from_packages.rb
if Dovecot.requires?('imap', node['dovecot'])
  node['dovecot']['packages']['imap'].each do |pkg|
    package pkg # [...]
  end
end
# conf_files.rb
node['dovecot']['conf_files'].each do |type, conf_files|
  if Dovecot.requires?(type, node['dovecot'])
    conf_files.each do |conf_file|
      template conf_files # [...]
    end
  end
end

This #requires? will have the ruby_blocks conditional logic, which only uses node attribute information to make decisions.

I think this would solve your problem, right? What do you think of this solution?

I will try to think about this in the coming days and let you know if I get something.

@llonchj
Copy link
Contributor Author

llonchj commented Apr 11, 2014

Xabier,

The requires? looks like an interesting approach.

Cheers

2014-04-11 8:57 GMT+10:00 Xabier de Zuazo notifications@github.com:

Sorry, I have not had time to look at this in detail.

I would try to find out a way to report the templates depending on how you
have compiled dovecot. Perhaps using ruby_blocks similar to the
from_package recipe in the from_source recipe.

But if it turns out to be too complicated or tricky, I would try to move
the ruby_blocks logic to a library. Then, use this library to both
install the packages and generate the templates. Something like the
following (simplified pseudo-ruby):

from_packages.rbif Dovecot.requires?('imap', node['dovecot'])

node['dovecot']['packages']['imap'].each do |pkg|
package pkg # [...]
endend

conf_files.rbnode['dovecot']['conf_files'].each do |type, conf_files|

if Dovecot.requires?(type, node['dovecot'])
conf_files.each do |conf_file|
template conf_files # [...]
end
endend

This #requires? will have the ruby_blocks conditional logic, which only
uses node attribute information to make decisions.

I think this would solve your problem, right? What do you think of this
solution?

I will try to think about this in the coming days and let you know if I
get something.

Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-40152739
.

@zuazo zuazo closed this as completed in 7885c4b Apr 12, 2014
@zuazo
Copy link
Owner

zuazo commented Apr 23, 2014

Released in version 1.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants