community.windows icon indicating copy to clipboard operation
community.windows copied to clipboard

win_ntp module required to configure NTP

Open Udayendu opened this issue 4 years ago • 5 comments

SUMMARY

Currently there is no ntp module to configure NTP client. Its good to have a win_ntp module that can take multiple NTP server IP/FQDN and configure in the windows system.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

win_ntp

ADDITIONAL INFORMATION

Currently only win_timezone module is available related to timezone change. But its having no option to configure the NTP as well. Hence either enhance this module with ntp configuration or make a new module win_ntp for ntp configuration.

Udayendu avatar Jul 16 '20 07:07 Udayendu

  • I am using the following option to use the win_shell module to push the powershell commands which is working fine:
- name: NTP Client Configuration
  win_shell: |
        w32tm /config /manualpeerlist:"{{ ntp_server_01 }}" /syncfromflags:MANUAL
        w32tm /config /manualpeerlist:"{{ ntp_server_02 }}" /syncfromflags:MANUAL
        Stop-Service w32time
        Start-Service w32time
  • The new module allow atleast 2 NTP servers to add to the windows guest.

Udayendu avatar Jul 28 '20 14:07 Udayendu

Since there are so many additional settings besides just the name or address of an NTP server, I would imagine that if there were to be such a module, it would allow configuration of all pertinent NTP settings: https://docs.microsoft.com/en-us/windows-server/networking/windows-time-service/windows-time-service-tools-and-settings#reference-windows-time-service-registry-entries.

I currently achieve this will a role containing a dozen or so plays using win_regedit; this allows it to be idempotent and only restarts the service if there is a change to this (or any of the other) keys.

  - name: "[W32Time Parameters] Configure NTP Server Name"
    win_regedit:
      path: HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
      name: 'NtpServer'
      data: 'ntp.domain.com,0x8'
      type: string
    notify: restart w32time service

mwtrigg avatar Jul 28 '20 15:07 mwtrigg

Since there are so many additional settings besides just the name or address of an NTP server, I would imagine that if there were to be such a module, it would allow configuration of all pertinent NTP settings: https://docs.microsoft.com/en-us/windows-server/networking/windows-time-service/windows-time-service-tools-and-settings#reference-windows-time-service-registry-entries.

I currently achieve this will a role containing a dozen or so plays using win_regedit; this allows it to be idempotent and only restarts the service if there is a change to this (or any of the other) keys.

  - name: "[W32Time Parameters] Configure NTP Server Name"
    win_regedit:
      path: HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
      name: 'NtpServer'
      data: 'ntp.domain.com,0x8'
      type: string
    notify: restart w32time service

If no specific NTP module then I will prefer to use the win_shell module where its simple to implement and can add multiple entries easily. Using minimal use of win_regedit is good.

Udayendu avatar Jul 29 '20 12:07 Udayendu

Hello @Udayendu @mwtrigg,

@sakar97 and I have forked the branch and started working on it and posting this for your solicit feedback and comments and to make sure no one else is already working on it.

suyeb786 avatar Sep 09 '20 10:09 suyeb786

Hello @Udayendu @mwtrigg,

@sakar97 and I have forked the branch and started working on it and posting this for your solicit feedback and comments and to make sure no one else is already working on it.

I think that would ne nice. Once done, let me know.

Udayendu avatar Sep 10 '20 13:09 Udayendu