diff options
author | Christian Pointner <equinox@spreadspace.org> | 2020-11-28 00:57:39 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2020-11-28 00:57:39 +0100 |
commit | 638189b7050d25fce30bf3f7d7c9ac6bafa8a760 (patch) | |
tree | 7dc42fc9049823a468e8f0163c419ace7041b201 /roles/core/ntp/tasks | |
parent | kubernetes/standalone: fix config hash annotation if role is included multipl... (diff) | |
parent | core/ntp: add support for openbsd (diff) |
Merge branch 'topic/core-ntp'
Diffstat (limited to 'roles/core/ntp/tasks')
-rw-r--r-- | roles/core/ntp/tasks/Debian_chrony.yml | 11 | ||||
-rw-r--r-- | roles/core/ntp/tasks/Debian_openntpd.yml | 11 | ||||
-rw-r--r-- | roles/core/ntp/tasks/Debian_systemd-timesyncd.yml | 18 | ||||
-rw-r--r-- | roles/core/ntp/tasks/OpenBSD_openntpd.yml | 6 | ||||
-rw-r--r-- | roles/core/ntp/tasks/error.yml | 3 | ||||
-rw-r--r-- | roles/core/ntp/tasks/main.yml | 14 |
6 files changed, 63 insertions, 0 deletions
diff --git a/roles/core/ntp/tasks/Debian_chrony.yml b/roles/core/ntp/tasks/Debian_chrony.yml new file mode 100644 index 00000000..d220af30 --- /dev/null +++ b/roles/core/ntp/tasks/Debian_chrony.yml @@ -0,0 +1,11 @@ +--- +- name: install chrony + apt: + name: chrony + state: present + +- name: install chrony configuration + template: + src: chrony.conf.j2 + dest: /etc/chrony/chrony.conf + notify: restart chrony diff --git a/roles/core/ntp/tasks/Debian_openntpd.yml b/roles/core/ntp/tasks/Debian_openntpd.yml new file mode 100644 index 00000000..76f62646 --- /dev/null +++ b/roles/core/ntp/tasks/Debian_openntpd.yml @@ -0,0 +1,11 @@ +--- +- name: install openntpd + apt: + name: openntpd + state: present + +- name: install openntpd configuration + template: + src: openntpd.conf.j2 + dest: /etc/openntpd/ntpd.conf + notify: restart openntpd diff --git a/roles/core/ntp/tasks/Debian_systemd-timesyncd.yml b/roles/core/ntp/tasks/Debian_systemd-timesyncd.yml new file mode 100644 index 00000000..20a5f379 --- /dev/null +++ b/roles/core/ntp/tasks/Debian_systemd-timesyncd.yml @@ -0,0 +1,18 @@ +--- +- name: set ntp servers + when: + - ntp_client is defined + - "'servers' in ntp_client" + lineinfile: + path: /etc/systemd/timesyncd.conf + regexp: '^#?NTP=' + line: "NTP={{ ntp_client.servers | map(attribute='name') | join(' ') }}" + notify: restart systemd-timesyncd + +- name: un-set ntp servers + when: "ntp_client is not defined or 'servers' not in ntp_client" + lineinfile: + path: /etc/systemd/timesyncd.conf + regexp: '^#?NTP=' + line: "#NTP=" + notify: restart systemd-timesyncd diff --git a/roles/core/ntp/tasks/OpenBSD_openntpd.yml b/roles/core/ntp/tasks/OpenBSD_openntpd.yml new file mode 100644 index 00000000..947b23c4 --- /dev/null +++ b/roles/core/ntp/tasks/OpenBSD_openntpd.yml @@ -0,0 +1,6 @@ +--- +- name: install openntpd configuration + template: + src: openntpd.conf.j2 + dest: /etc/ntpd.conf + notify: restart ntpd diff --git a/roles/core/ntp/tasks/error.yml b/roles/core/ntp/tasks/error.yml new file mode 100644 index 00000000..84a1a198 --- /dev/null +++ b/roles/core/ntp/tasks/error.yml @@ -0,0 +1,3 @@ +--- +- fail: + msg: "ntp variant '{{ ntp_variant }}' is not supported on this platform" diff --git a/roles/core/ntp/tasks/main.yml b/roles/core/ntp/tasks/main.yml new file mode 100644 index 00000000..d8c619a9 --- /dev/null +++ b/roles/core/ntp/tasks/main.yml @@ -0,0 +1,14 @@ +--- +- name: load os/distrubtion/version specific tasks + when: ntp_variant is defined + vars: + params: + files: + - "{{ ansible_distribution_release }}_{{ ntp_variant }}.yml" + - "{{ ansible_distribution }}_{{ ntp_variant }}.yml" + - "{{ ansible_os_family }}_{{ ntp_variant }}.yml" + - "error.yml" + loop: "{{ q('first_found', params) }}" + loop_control: + loop_var: tasks_file + include_tasks: "{{ tasks_file }}" |