From e5a5d1c94c4f9b60c0c8b534e9472d432f978f5a Mon Sep 17 00:00:00 2001 From: Sven Velt Date: Thu, 19 Sep 2024 09:36:03 +0200 Subject: [PATCH] Kapitel 10: Chrony mit Handler --- 10/chrony.conf.j2 | 1 + 10/chrony_mit_handler.yml | 24 ++++++++++++++++++++++++ 10/old.ntp/ntp.conf.j2 | 1 + 10/old.ntp/ntp_mit_handler.yml | 31 +++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 120000 10/chrony.conf.j2 create mode 100644 10/chrony_mit_handler.yml create mode 120000 10/old.ntp/ntp.conf.j2 create mode 100644 10/old.ntp/ntp_mit_handler.yml diff --git a/10/chrony.conf.j2 b/10/chrony.conf.j2 new file mode 120000 index 0000000..ce39bf1 --- /dev/null +++ b/10/chrony.conf.j2 @@ -0,0 +1 @@ +../05/chrony.conf.j2 \ No newline at end of file diff --git a/10/chrony_mit_handler.yml b/10/chrony_mit_handler.yml new file mode 100644 index 0000000..f77b88f --- /dev/null +++ b/10/chrony_mit_handler.yml @@ -0,0 +1,24 @@ +--- +- hosts: all + + tasks: + + - name: Install Chrony + package: name=chrony state=latest + notify: Restart Chrony + + - name: Show pools + debug: var=chrony_pools + + - name: Template config file + template: "src=chrony.conf.j2 dest='{{ chrony_config_path }}' mode=0644 owner=root group=root backup=yes" + notify: Restart Chrony + + - name: Enable Chrony at boot + service: "name={{ chrony_service_name }} enabled=yes" + + handlers: + + - name: Restart Chrony + service: "name='{{ chrony_service_name }}' state=restarted" + diff --git a/10/old.ntp/ntp.conf.j2 b/10/old.ntp/ntp.conf.j2 new file mode 120000 index 0000000..2f73a28 --- /dev/null +++ b/10/old.ntp/ntp.conf.j2 @@ -0,0 +1 @@ +../../05/old.ntp/ntp.conf.j2 \ No newline at end of file diff --git a/10/old.ntp/ntp_mit_handler.yml b/10/old.ntp/ntp_mit_handler.yml new file mode 100644 index 0000000..11fa06b --- /dev/null +++ b/10/old.ntp/ntp_mit_handler.yml @@ -0,0 +1,31 @@ +--- +- hosts: all + + tasks: + + - name: Install NTP + package: + name: ntp + state: latest + + - name: Debug + debug: var=ntp_servers + + - name: Copy ntp.conf + template: + src: ntp.conf.j2 + dest: /etc/ntp.conf + backup: yes + notify: Restart NTP + + - name: Enable NTP + service: + name: "{{ ntp_service_name }}" + enabled: yes + state: started + + + handlers: + - name: Restart NTP + service: "name={{ ntp_service_name }} state=\"restarted\"" +