-
Notifications
You must be signed in to change notification settings - Fork 42
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
Stopping default recursor on debian based distros for sysvinit #78
Conversation
Vagrant fails to download the versions when removed.
# Some distros start pdns-recursor after installing it, we want to stop it | ||
# The behavior of the init script on CentOS 6 causes a bug so we skip it there | ||
# (see https://github.com/dnsimple/chef-pdns/issues/77#issuecomment-311644973) | ||
service 'pdns-recursor' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicating the resource below is a chef 13 violation and will not work as desired in all cases. You will probably want to make an pdns_default_actions
var and then set it based on the requirements and pass it to action on a single service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cosigned about that. Resource cloning has been deprecated for some time in Chef, technically since just before Chef 11. While it is technically still supported via Chef 13, the side-affect is that you'll have the same resource being called multiple times in different ways which can make it unpredictable. See https://docs.chef.io/deprecations_resource_cloning.html about this behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A way around this would be something like:
pdns_recursor_actions = [:disable]
pdns_recursor_actions = pdns_recursor_actions.unshift(:stop) if node['platform_family'] == 'debian'
service 'pdns-recursor' do
supports restart: true, status: true
action pdns_recursor_actions
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also use
pdns_recursor_actions += [:stop] if node['platform_family'] == 'debian'
which is less rubyesque but I think looks cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since order of array is a thing in chef then that snippet may be an issue since the += appends. Hence my use of unshift to put stop first, not last.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could simplify it by doing:
pdns_recursor_actions = [:disable] if node['platform_family'] == 'debian'
(pdns_recursor_actions ||= []).push(:stop)
But that might be a little too obscure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to resolve the cloning issue.
This PR fixes #77 by solution proposed in the latest comment, (see issue for complete discussion of the bug).
The solution is stopping the default recursor instance only on debian based distros for sysvinit provider.
This has been proved to pass tests in both Vagrant and Docker.