mullholland.timezone

Ansible role timezone

Configure timezine settings

GitHub Downloads Version
github downloads Version

Example Playbook

This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.

---
- name: Converge
  hosts: all
  become: true
  gather_facts: true
  roles:
    - role: "mullholland.timezone"

The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml:

---
- name: Prepare
  hosts: all
  become: true
  gather_facts: true

  tasks:
    # dependend packages can be configured via `timezone_dependent_services`
    - name: Install dependencies
      ansible.builtin.package:
        name:
          - "cronie"  # default timezone dependent services
          - "rsyslog"  # default timezone dependent services
        state: present
      when:
        - ansible_distribution in [ "RedHat", "CentOS", "Amazon", "Rocky", "AlmaLinux", "Fedora" ]

    - name: Install dependencies
      ansible.builtin.apt:
        name:
          - "cron"  # default timezone dependent services
          - "rsyslog"  # default timezone dependent services
        state: present
        update_cache: true
      when:
        - ansible_os_family == "Debian"

Role Variables

The default values for the variables are set in defaults/main.yml:

---
# Default timezone
timezone: "Etc/UTC"

timezone_dependent_services_map:
  RedHat:
    - "crond"
    - "rsyslog"
  Rocky:
    - "crond"
    - "rsyslog"
  Debian:
    - "cron"
    - "rsyslog"

timezone_dependent_services: "{{ timezone_dependent_services_map[ansible_distribution] | default(timezone_dependent_services_map[ansible_os_family] | default(timezone_dependent_services_map['default'])) }}"

Requirements

State of used roles

The following roles are used to prepare a system. You can prepare your system in another way.

Requirement GitHub GitLab

Context

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles: dependencies

Compatibility

This role has been tested on these container images:

container tags
EL all
Amazon Candidate
Fedora all
Ubuntu all
Debian all

The minimum version of Ansible required is 2.10, tests have been done to:

  • The previous version.
  • The current version.
  • The development version.

If you find issues, please register them in GitHub.

License

MIT.

Author Information

Mullholland

Install
ansible-galaxy install mullholland.timezone
GitHub repository
License
apache-2.0
Downloads
193