alecunsolo.time
Ansible Role: time
DISCLAIMER
After this announcement I will not test on RHEL anymore.
A simple role to set timezone and enable NTP (Chrony). Nothing sophisticated and not very configurable, but it's all I need :)
Requirements
The package tzdata must be installed. I think only containers don't have it already installed by default.
Role Variables
Default values defined in defaults/main.yml
config_timezone: Etc/UTC
The wanted timezone.
custom_ntp_server: ~
If present, configure a preferred ntp server.
The chrony config file path is different for RedHat and Debian, so it is configured in a distro specific variable file:
# Debian
chrony_conf_path: /etc/chrony/chrony.conf
# RedHat
chrony_conf_path: /etc/chrony.conf
Dependencies
The role use the community.general.timezone module, so the community.general collection must be available.
Example Playbook
- hosts: all
vars:
config_timezone: Europe/Rome
custom_ntp_server: ntp.example.com
pre_tasks:
- name: Ensure tzdata package is installed.
ansible.builtin.package:
name: tzdata
state: present
roles:
- alecunsolo.time
License
MIT
Notes
Testing with molecule (including the docker images used) is stolen from heavily inspired by Jeff Geerling. Watch his video (and the other ones as well).
ansible-galaxy install alecunsolo.time