caseraw.ansible_role_chrony
Ansible Role Chrony
Using Ansible to manage network time with chrony.
License
MIT / BSD
Author Info
- Created and managed by: Kasra Amirsarvari
- Ansible Galaxy community author: Link
- Dockerhub user: Link
Requirements
- Make sure you have a package manager ready and configured correctly.
- The user running this role needs the right permissions to:
- Install and remove packages.
- Edit files from the installed package.
- Control
systemd
services forntpd
andchronyd
.
- Allow network traffic over UDP port 123 for NTP.
- Outbound for any servers providing NTP.
- Inbound for any clients using NTP.
Dependencies
None
Compatibility
Works with these operating systems:
- CentOS 7
- CentOS 8
- RHEL 7.x
- RHEL 8.x
Role Variables
Variable Name | Description |
---|---|
role_chrony_chrony_dot_conf_parameters | Holds the chrony configuration settings. |
role_chrony_required_packages | List of packages needed for chrony to run properly. |
role_chrony_time_zone | The timezone to set for the system. |
Example Playbook
---
- name: Setup and configure chrony for NTP
become: True
gather_facts: False
roles:
- role: ansible_role_chrony
...
Useful Shell Commands
chronyc tracking
chronyc sources
chronyc sourcestats
Additional Documentation
For more information about chrony and how to use it, visit:
- 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 tested locally using Molecule. The configuration is found at: molecule/default.
Molecule tests are performed using the docker driver on Dockerhub images made for this purpose:
Some setups might need a full operating system instead of a lightweight container image. In those cases, you can use the molecule driver for Vagrant with the libvirt provider. Here's an example of the configuration:
driver:
name: vagrant
provider:
name: libvirt
platforms:
- name: ansible_role_chrony-ansible-molecule-centos-7
box: centos/7
memory: 1024
cpus: 1
CI/CD with Travis CI
This role uses Travis CI to run automated tests using Molecule and sends notifications to add the role to Ansible Galaxy once tests pass. The Travis CI config file is located at the root of this 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