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

Question: How can a wrapper cookbook specify additional systemd options #314

Closed
kamaradclimber opened this issue May 12, 2016 · 6 comments
Closed

Comments

@kamaradclimber
Copy link
Contributor

kamaradclimber commented May 12, 2016

On some setups, the LimitNOFILE option is required in the consul service definition.

Is it possible to add this option using the wrapper cookbook pattern?

So far, I've tried to specify attributes such as
default['consul']['service']['options']['template'] = 'consul-wrapper:mytemplate.erb'
(and similar variation) without any luck.

@johnbellone
Copy link
Contributor

johnbellone commented May 16, 2016

Unfortunately I am not sure this is something that can currently be set right now using a node attribute. I'm going to have to think a little more about it, but you should be able to use the poise_service_options resource in a wrapper cookbook. The block below should do what you're looking for the systemd provider:

poise_service_options node['consul']['service_name'] do
  options :systemd, template: 'consul-wrapper:mytemplate.erb'
end

@kamaradclimber
Copy link
Contributor Author

thanks I'll try that

@johnbellone
Copy link
Contributor

This is probably something that we could expose using inversion options (similar to what we do with the download URL). This allows us to override in a policy or wrapper cookbook. You can see an example in our Redis cookbook README. Unfortunately the inversion attribute name is the name of the resource which in this cookbook's case is the service name (consul) and tends to make the node attributes confusing.

@kamaradclimber
Copy link
Contributor Author

Unfortunately, adding the code you suggested does not change anything.

@kamaradclimber
Copy link
Contributor Author

I've succeeded by monkey patching your provider in my wrapper cookbook

module ConsulCookbook
  module Provider
    class ConsulService < Chef::Provider

      alias_method :old_service_options, :service_options unless method_defined?(:old_service_options)

      def service_options(service)
        old_service_options(service)
        service.options(:systemd, template: 'consul-criteo:systemd.service.erb')
      end
    end
  end
end

but I've submitted a cleaner patch in #316 to make this available to everybody

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants