Wednesday, October 31, 2012

Puppet DNS lookup

From time to time NetworkManager breaks my /etc/resolv.conf. I normally turn that off using puppet but when /etc/resolv.conf is broken, puppet won't run so I have to fix it manually :-(

Well, not any more. Now I add a static /etc/hosts entry for the puppet server and puppet will run even when /etc/resolv.conf is broken.

The special part about this is that I look up the IP address using a template so I don't have to hard code the value in my manifest. Google said it could not be done without writing a custom function. As always, I did not believe it...

Assuming you have set $puppetserver to contain the fqdn of your puppet server:

host { 'hostsconf-puppet':
        ensure => present,
        ip => inline_template("<% _erbout.concat(Resolv::DNS.open.getaddress('$puppetserver').to_s) %>"),
        name => $puppetserver,
        target => '/etc/hosts',
}



9 comments:

  1. Hooray for no more manual fixes! And what a simple solution it was, too. This is definitely one of those things that you put up with for a long time until one day you're just like "enough!" and actually do something about it. And that something takes like two seconds and you should've done it months ago.

    Better late than never?

    Fred | https://webhostinggeeks.com/tools/

    ReplyDelete
  2. This is also a very good post which I really enjoyed reading. It is not everyday that I have the possibility to see something like this.
    gun mayhem 2

    ReplyDelete
  3. Wonderful goods from you, man. I have understand your stuff previous to and you’re just extremely magnificent. I actually like what you’ve acquired here, certainly like what you are saying and the way in which you say it. You make it entertaining and you still care for to keep it wise.
    I can’t wait to read much more from you. This is really a great web site.

    films altadefinizione

    ReplyDelete
  4. Very interesting content. Thanks.

    Lucy Hennessy, for more info visit my Homepage

    ReplyDelete
  5. This is known as the cbd water entourage effect and is the reason our products are potent and effective.

    ReplyDelete
  6. For example, an essay is completed between 3 and 7 hours. Research papers https://rankmywriter.com/payforessay-net-review only require 24 to 48 hours to write properly, and our professionals require the maximum of a week to research and write dissertations.

    ReplyDelete
  7. Very recommended service navigate to this web-site, their editors write the professional essay, also very patient for revisions. I have used this service for at least 5 papers now, and been happy with the service on all of them. Most of the time it is done before the deadline. Online customer service is also quick to respond to questions. I will continue to use them in the future!

    ReplyDelete