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

Stopping default recursor on debian based distros for sysvinit #78

Merged
merged 7 commits into from
Jun 29, 2017

Conversation

therobot
Copy link
Contributor

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.

# 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
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted, thanks.

Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Member

@onlyhavecans onlyhavecans Jun 28, 2017

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

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor

@martinisoft martinisoft left a 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.

@therobot therobot merged commit 0b57a58 into master Jun 29, 2017
@therobot therobot deleted the bugfix/stopping_default_recursor branch June 29, 2017 13:02
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

Successfully merging this pull request may close these issues.

pdns_recursor_service_sysvinit behaves different when using Vagrant or Docker as providers
3 participants