ntpd: Initial version of role

This commit is contained in:
Timo Makinen 2025-06-24 14:29:05 +00:00
parent e1edd338aa
commit 554e3f9701
4 changed files with 35 additions and 0 deletions

View file

@ -0,0 +1,3 @@
---
ntpd_servers:
- time.foo.sh

View file

@ -0,0 +1,5 @@
---
- name: Restart ntpd
ansible.builtin.service:
name: ntpd
state: restarted

16
roles/ntpd/tasks/main.yml Normal file
View file

@ -0,0 +1,16 @@
---
- name: Create config
ansible.builtin.template:
dest: /etc/ntpd.conf
src: ntpd.conf.j2
mode: "0644"
owner: root
group: "{{ ansible_wheel }}"
validate: "/usr/sbin/ntpd -f %s -n"
notify: Restart ntpd
- name: Enable service
ansible.builtin.service:
name: ntpd
state: started
enabled: true

View file

@ -0,0 +1,11 @@
{% if ntpd_listen is defined %}
# listen to network
{% for listen in ntpd_listen %}
listen on {{ listen }}
{% endfor %}
{% endif %}
# remote servers
{% for server in ntpd_servers %}
server {{ server }}
{% endfor %}