From 3b8eec998152ad008639adbb768d22aba321df36 Mon Sep 17 00:00:00 2001 From: Paolo Asperti Date: Sun, 5 Apr 2020 18:50:00 +0200 Subject: [PATCH] playbook split + added ntp --- .../ansible/roles/common/handlers/main.yml | 4 +++ .../roles/common/tasks/libreschool_repo.yml | 16 ++++++++++++ root/etc/ansible/roles/common/tasks/main.yml | 20 +++----------- root/etc/ansible/roles/common/tasks/ntp.yml | 26 +++++++++++++++++++ .../roles/common/tasks/required_packages.yml | 7 +++++ 5 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 root/etc/ansible/roles/common/handlers/main.yml create mode 100644 root/etc/ansible/roles/common/tasks/libreschool_repo.yml create mode 100644 root/etc/ansible/roles/common/tasks/ntp.yml create mode 100644 root/etc/ansible/roles/common/tasks/required_packages.yml diff --git a/root/etc/ansible/roles/common/handlers/main.yml b/root/etc/ansible/roles/common/handlers/main.yml new file mode 100644 index 0000000..a544b03 --- /dev/null +++ b/root/etc/ansible/roles/common/handlers/main.yml @@ -0,0 +1,4 @@ +--- + - name: restart systemd-timesyncd + service: name=systemd-timesyncd state=restarted + \ No newline at end of file diff --git a/root/etc/ansible/roles/common/tasks/libreschool_repo.yml b/root/etc/ansible/roles/common/tasks/libreschool_repo.yml new file mode 100644 index 0000000..4e895d0 --- /dev/null +++ b/root/etc/ansible/roles/common/tasks/libreschool_repo.yml @@ -0,0 +1,16 @@ +--- + + - name: Add LibreSchool signing key + apt_key: + url: http://repo.libreschool.org/libreschool.asc + state: present + + - name: Add LibreSchool repository + apt_repository: + repo: deb http://repo.libreschool.org/ubuntu {{ ansible_distribution_release }} main + state: present + + - name: Update repositories cache and install "libreschool-client" package + apt: + name: libreschool-client + update_cache: yes diff --git a/root/etc/ansible/roles/common/tasks/main.yml b/root/etc/ansible/roles/common/tasks/main.yml index 32ae6e0..48303e9 100644 --- a/root/etc/ansible/roles/common/tasks/main.yml +++ b/root/etc/ansible/roles/common/tasks/main.yml @@ -5,22 +5,8 @@ register: esmith delegate_to: localhost -- name: Add LibreSchool signing key - apt_key: - url: http://repo.libreschool.org/libreschool.asc - state: present +- include: libreschool_repo.yml -- name: Add LibreSchool repository - apt_repository: - repo: deb http://repo.libreschool.org/ubuntu {{ ansible_distribution_release }} main - state: present +- include: required_packages.yml -- name: Update repositories cache and install "libreschool-client" package - apt: - name: libreschool-client - update_cache: yes - -- name: Installing common required packages - apt: - name: [ 'debconf', 'debconf-utils' ] - state: latest +- include: ntp.yml diff --git a/root/etc/ansible/roles/common/tasks/ntp.yml b/root/etc/ansible/roles/common/tasks/ntp.yml new file mode 100644 index 0000000..c763812 --- /dev/null +++ b/root/etc/ansible/roles/common/tasks/ntp.yml @@ -0,0 +1,26 @@ +--- + + # TODO: check for other distro, maybe we should first check if we have systemd, + # and if so, we have to properly configure it. If we don't have systemd, + # we have to install and configure ntpd + + - name: Remove NTP package as we use systemd + apt: + name: [ 'ntp' ] + state: absent + + - name: Setup NTP server + ini_file: + path: /etc/systemd/timesyncd.conf + section: Time + option: NTP + value: "{{ esmith.SystemName }}.{{ esmith.DomainName }}" + notify: restart systemd-timesyncd + + - name: Setup Fallback NTP server + ini_file: + path: /etc/systemd/timesyncd.conf + section: Time + option: FallbackNTP + value: pool.ntp.org + notify: restart systemd-timesyncd diff --git a/root/etc/ansible/roles/common/tasks/required_packages.yml b/root/etc/ansible/roles/common/tasks/required_packages.yml new file mode 100644 index 0000000..f88ee06 --- /dev/null +++ b/root/etc/ansible/roles/common/tasks/required_packages.yml @@ -0,0 +1,7 @@ +--- + + - name: Installing common required packages + apt: + name: [ 'debconf', 'debconf-utils' ] + state: latest + \ No newline at end of file