ansible-infra/ansible_collections/debops/debops/roles/ntp/tasks/install.yml

50 lines
1.9 KiB
YAML

---
# Copyright (C) 2014-2017 Maciej Delmanowski <drybjed@gmail.com>
# Copyright (C) 2015-2017 Robin Schneider <ypid@riseup.net>
# Copyright (C) 2014-2017 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only
- name: Install required packages
ansible.builtin.package:
name: '{{ (ntp__base_packages + ntp__packages) | flatten }}'
state: 'present'
register: ntp__register_apt_install
until: ntp__register_apt_install is succeeded
- name: Query available systemd services
ansible.builtin.service_facts:
when: ansible_service_mgr == "systemd"
- name: Manage systemd-timesyncd state
ansible.builtin.service:
name: 'systemd-timesyncd'
state: '{{ "started" if (ntp__daemon in ["systemd-timesyncd"]) else "stopped" }}'
enabled: '{{ True if (ntp__daemon in ["systemd-timesyncd"]) else False }}'
when:
- ansible_service_mgr == "systemd"
- ("systemd-timesyncd.service" in ansible_facts.services and
ansible_facts.services['systemd-timesyncd.service'].status != 'not-found')
# NTPdate does not need to be configured separately as the script `/usr/sbin/ntpdate-debian`
# will pick up the configuration from `/etc/ntp.conf` when it exists.
# Install chrony on all hosts except inside containers
- name: Install chrony
ansible.builtin.include_tasks: chrony.yml
when: ntp__daemon == 'chrony'
# Install NTPd on all hosts except inside containers
- name: Install ntpd
ansible.builtin.include_tasks: ntpd.yml
when: ntp__daemon in [ 'ntpd', 'ntpdate' ]
# Install OpenNTPd on all hosts except inside containers
- name: Install OpenNTPd
ansible.builtin.include_tasks: openntpd.yml
when: ntp__daemon == 'openntpd'
# Configure systemd-timesyncd
- name: Include systemd-timesyncd configuration
ansible.builtin.include_tasks: systemd-timesyncd.yml
when: (ansible_service_mgr == "systemd" and
ntp__daemon == 'systemd-timesyncd')