ntp.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Deploy ntp servers
  16. block:
  17. - name: Deploy ntpd
  18. package:
  19. name: ntp
  20. state: present
  21. - name: Deploy ntpdate
  22. package:
  23. name: ntpdate
  24. state: present
  25. - name: Update ntp servers
  26. template:
  27. src: ntp.conf.j2
  28. dest: "{{ ntp_path }}"
  29. owner: root
  30. group: root
  31. mode: "{{ ntp_mode }}"
  32. backup: yes
  33. notify:
  34. - Restart ntpd
  35. - Sync tp clocks
  36. when: ( ansible_distribution == "CentOS" or ansible_distribution == "RedHat" ) and ansible_distribution_major_version < os_higher_version
  37. - name: Deploy chrony server
  38. block:
  39. - name: Deploy chrony
  40. package:
  41. name: chrony
  42. state: present
  43. - name: Update ntp servers
  44. template:
  45. src: chrony.conf.j2
  46. dest: "{{ chrony_path }}"
  47. owner: root
  48. group: root
  49. mode: "{{ ntp_mode }}"
  50. backup: yes
  51. notify:
  52. - Restart chrony
  53. - Sync chrony sources
  54. when: (( ansible_distribution == "CentOS" or ansible_distribution == "RedHat" ) and ansible_distribution_major_version > os_version) or
  55. ( os_supported_leap in compute_os ) and ( ansible_distribution_version >= os_supported_leap_version )