Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the following Puppet module:

class resolvconf {
    $packages = ['resolvconf', 'dnsmasq']
    package { $packages: ensure => installed, }

    file { '/etc/resolvconf/resolv.conf.d/base':
        ensure  => file,
        owner   => root,
        group   => root,
        content => '
nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4',
    }

    service { 'dnsmasq':
        require   => Package[resolvconf],
        ensure    => running,
        subscribe => File['/etc/resolvconf/resolv.conf.d/base']
    }
}

However, when I run the provisioning, I get the following error:

err: /Stage[main]/Resolvconf/File[/etc/resolvconf/resolv.conf.d/base]/ensure: change from absent to file failed: Could not set 'file on ensure: No such file or directory - /etc/resolvconf/resolv.conf.d/base.puppettmp_4012 at /tmp/vagrant-puppet/modules-0/resolvconf/manifests/init.pp:13

I understand this to mean that /etc/resolvconf/resolv.conf.d/base does not exist yet, or can't be created. This problem seems to eventually go away after a number of re-provisionings or a reboot, so it would seem to be some sort of a dependency problem that I could resolve with the appropriate dependency or exec statement.

In addition, because of this failed dependency, the following will hang indefinitely:

notice: /Stage[main]/Resolvconf/Service[dnsmasq]: Dependency File[/etc/resolvconf/resolv.conf.d/base] has failures: true
warning: /Stage[main]/Resolvconf/Service[dnsmasq]: Skipping because of failed dependencies

or at least until I hit CTRL-C.

What do I need to change in the module or manifest to allow the script to run correctly the first time through?

share|improve this question

migrated from stackoverflow.com Aug 10 '12 at 23:28

This question came from our site for professional and enthusiast programmers.

1 Answer 1

Add a line to require the package in your file resource like this:

file { '/etc/resolvconf/resolv.conf.d/base':
    ensure  => file,
    owner   => root,
    group   => root,
    content => '...
    require => Package['resolvconf'],
}

Using a require basically forced puppet to perform the package install first.

This of course assumes that the installation of the resolvconf package creates the required directories, which I believe it does happen.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.