Question

Here is my sample manifest that I use to set up ntp on my machine to connect to my source '10.0.2.15'

class myNtpClass ($ntpSource='10.0.2.15') {

file {'myFile':
        ensure => present,
        path => '/test2',
        content => "servers => ['${ntpSource} iburst']",
}

class { '::ntp':

servers => ['${ntpSource} iburst', 'localhost'],
restrict => ['restrict 127.0.0.1', 'restrict 10.0.2.0/24'],
}

}

include myNtpClass

I am using the ntp in-built class to insert my list of source servers into my ntp configuration.

When I execute this manifest, the $ntpSource variable doesn't get replaced in my ntp.conf config file.

Here is my ntp.conf file after applying the puppet manifest,

# ntp.conf: Managed by puppet.
#
# Keep ntpd from panicking in the event of a large clock skew
# when a VM guest is suspended and resumed.
tinker panic 0

# Permit time synchronization with our time source, but do not'
# permit the source to query or modify the service on this system.'
restrict 127.0.0.1
restrict 10.0.2.0/24


# Servers
server ${ntpSource} iburst
server localhost


# Driftfile.
driftfile /var/lib/ntp/drift

I am not sure where I am going wrong. When I try to print the $ntpSource variable in a file; the file gets created as expected.

Was it helpful?

Solution

Use double quotes instead of single:

servers => ["${ntpSource} iburst", 'localhost'],

Quote from Puppet site:

There are two kinds of quotes in Puppet: single (') and double ("). The main difference is that double quotes let you interpolate $variables.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top