ansible_role_chrony
Ansible role chrony
Managing network time with Ansible using chrony.
License
MIT / BSD
Author Information
- Made and maintained by: Kasra Amirsarvari
- Ansible Galaxy community author: https://galaxy.ansible.com/caseraw
- Dockerhub community user: https://hub.docker.com/u/caseraw
Requirements
- Ensure a package manager is available and configured with the correct package sources and repositories.
- Ensure privileged permissions are set for the user executing this role to:
- Install and uninstall.
- Edit files provided by the package itself.
- Manage
systemd
services forntpd
andchronyd
.
- Ensure network traffic over 123/udp (port/protocol) is allowed.
- Outbound for any servers providing NTP.
- Inbound for any clients retrieving NTP.
Dependencies
N/A
Compatibility
Compatible with the following list of operating systems:
- CentOS 7
- CentOS 8
- RHEL 7.x
- RHEL 8.x
Role Variables
Variable name | Description |
---|---|
role_chrony_chrony_dot_conf_parameters | A dictionary containing the chrony configuration. |
role_chrony_required_packages | A list of packages that need to be installed for chrony to work properly. |
role_chrony_time_zone | The timezone to set. |
Example Playbook
---
- name: Manage the installation and configuration of chrony for NTP
become: True
gather_facts: False
roles:
- role: ansible_role_chrony
...
Useful shell commands
chronyc tracking
chronyc sources
chronyc sourcestats
Additional documentation resources
The following links provide more information about chrony and it's usage.
- https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-configuring_ntp_using_the_chrony_suite
- https://chrony.tuxfamily.org/faq.html
Testing with Molecule
This role is locally tested with the use of Molecule, the configuration is located at: molecule/default.
The Molecule tests are run (using the docker driver) on Dockerhub images built for this purpose:
Some specific configurations might require a full OS instead of a minimal container image. In these use-cases make use of molecule driver for vagrant with the libvirt provider. The Molecule driver and platform configuration part could look something like this:
driver:
name: vagrant
provider:
name: libvirt
platforms:
- name: ansible_role_chrony-ansible-molecule-centos-7
box: centos/7
imemory: 1024
cpus: 1
CI/CD with Travis CI
This role uses Travis CI to run online tests with the use of Molecule and pushes notifications to import the role into Ansible Galaxy once the tests are successful. The Travis CI configuration is located at the root of the Ansible role .travis.yml
Useful links
- GitHub repository: https://github.com/Caseraw/ansible_role_chrony
- Travis CI build status: https://travis-ci.org/Caseraw/ansible_role_chrony
- Ansible Galaxy role: https://galaxy.ansible.com/caseraw/ansible_role_chrony
Manage the installation and configuration of chrony for NTP
ansible-galaxy install Caseraw/ansible_role_chrony