Puppet Class: psick::time::windows

Defined in:
manifests/time/windows.pp

Overview

This psick manages ntp client on Windows Derived from github.com/ncorrare/windowstime

Parameters:

  • ntp_servers (Array) (defaults to: $psick::time::servers)
  • fallback_servers (Array) (defaults to: [])
  • manage (Boolean) (defaults to: $psick::manage)
  • noop_manage (Boolean) (defaults to: $psick::noop_manage)
  • noop_value (Boolean) (defaults to: $psick::noop_value)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'manifests/time/windows.pp', line 3

class psick::time::windows (
  Array $ntp_servers      = $psick::time::servers,
  Array $fallback_servers = [],

  Boolean $manage      = $psick::manage,
  Boolean $noop_manage = $psick::noop_manage,
  Boolean $noop_value  = $psick::noop_value,
) {
  if $manage {
    if $noop_manage {
      noop($noop_value)
    }

    $servers_ntp = inline_template('<% @ntp_servers.each do |s| -%><%= s %>,0x01 <% end -%>')
    $servers_fallback = inline_template('<% @fallback_servers.each do |s| -%><%= s %>,0x02 <% end -%>')
    $servers_registry = "${servers_ntp} ${servers_fallback}"
    $system32dir = $facts['os']['windows']['system32']

    registry_value { 'HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\Type':
      ensure => present,
      type   => string,
      data   => 'NTP',
    }
    registry_value { 'HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\NtpServer':
      ensure => present,
      type   => string,
      data   => $servers_registry,
      notify => Service['w32time'],
    }

    exec { 'c:/Windows/System32/w32tm.exe /resync':
      refreshonly => true,
    }

    service { 'w32time':
      ensure => running,
      enable => true,
      notify => Exec['c:/Windows/System32/w32tm.exe /resync'],
    }
  }
}