centos7puppetnetplan

Replicate netplan nameserver configuration for centos


First of a warning: I'm a junior level with little experience using centos.

I'm running a puppet environment with a few different machines some example modules I'm running is consul and puppet-dns for the ubuntu machines I have used netplan to configure up my dns clients.

Dns Server machine

  include dns::server

  # Forwarders
  dns::server::options { '/etc/bind/named.conf.options':
    dnssec_enable     => false,
    dnssec_validation => no,
    forwarders        => [ 'IP1' ],
  }

  dns::zone { 'consul':
    zone_type       => forward,
    forward_policy  => only,
    allow_forwarder => [ '127.0.0.1 port 8600' ],
  }

DNS Client setup

  /^(Debian|Ubuntu)$/: { 
  class { 'netplan':
    config_file   => '/etc/netplan/50-cloud-init.yaml',
    ethernets     => {
      'ens3' => {
        'dhcp4'       => true,
        'nameservers' => {
          'search'    => ['node.consul'],
          'addresses' => [ "$dir_ip" ],
        }
      }
    },
    netplan_apply => true,
  }

In order to replicate this on Centos7, I came accross ifcfg files (/etc/sysconfig/network-scripts/ifcfg-ens3) however, I am not sure how to replicate the result from above within one of this files. Does anyone have experience with this ?


Solution

  • After some reading, I decided to edit /etc/resolv.conf with the help of puppetmod: saz-resolv_conf

     class { 'resolv_conf':
          nameservers => ["$dir_ip"],
          searchpath  => ['node.consul'],
      }
    

    I was a bit skeptical about this at first since the file had automated items from OpenStack, however, everything is working as expected.