Giter VIP home page Giter VIP logo

ansible-role-chrony's Introduction

Ansible Role: chrony

GitHub Super-Linter Molecule Ansible Role

This Ansible role allows you to install chrony and manage its configuration.

An hardened systemd unit file is setup when deploying under Debian >= 11 and Arch Linux.

For more information about chrony, please check the official project page.

Requirements

None

Dependencies

None

Role variables

Variable name Description Default value
chrony_service_name Service name. chronyd
chrony_ntp_pools A list of NTP pools to use, with their options. [ 'pool.ntp.org iburst maxpoll 10' ]
chrony_ntp_servers A list of NTP servers to use, with their options. []
chrony_ntp_peers A list of NTP peers to use, with their options. []
chrony_config_file Path to chrony configuration file. /etc/chrony.conf
chrony_config_logdir Path to chrony logs directory. /var/log/chrony
chrony_config_driftfile Path to chrony drift file. /var/lib/chrony/drift
chrony_makestep_threshold Limit (in sec) above which chrony will step the clock instead of slewing it. 1
chrony_makestep_limit Limit (in nb) above which chrony won't step the clock anymore, even if needed. 10
chrony_allow List of subnets allowed to access this computer as an NTP server. []
chrony_deny List of subnets NOT allowed to access this computer as an NTP server. []

๐Ÿ“— Documentation:

Example

Here is a small example playbook.

IMPORTANT: DO NOT use this example as it is.

---
- hosts: all
  become: true
  roles:
    - role: frzk.chrony
      chrony_service_name: chronyd
      chrony_ntp_pools: []
      chrony_ntp_servers:
        - 0.rhel.pool.ntp.org iburst maxpoll 10
        - 1.rhel.pool.ntp.org iburst maxpoll 10
        - 2.rhel.pool.ntp.org iburst maxpoll 10
        - 3.rhel.pool.ntp.org iburst maxpoll 10
      chrony_ntp_peers:
        - ntp00.example.com maxpoll 10
        - ntp01.example.com maxpoll 10
        - ntp02.example.com maxpoll 10
      chrony_config_file: /etc/chrony.conf
      chrony_config_driftfile: /var/lib/chrony/drift
      chrony_makestep_threshold: 5
      chrony_makestep_limit: 3
      chrony_allow:
        - 192.0.2.0/24
        - 192.0.2.200
      chrony_deny:
        - 192.0.2.0/25
...

Testing

Testing is done by leveraging Molecule and Ansible (see verify.yml), through GitHub Actions and Docker containers.

Tests successfully pass under the following distributions:

  • Arch Linux
  • Debian 11
  • Debian 10
  • Debian 9
  • Ubuntu 20.04
  • Ubuntu 18.04

Contributing

Code reviews, patches, comments, bug reports and feature requests are welcome. Please read the Contributing Guide for further details.

ansible-role-chrony's People

Contributors

frzk avatar juddtracy-das avatar mur-me avatar pescobar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ansible-role-chrony's Issues

Allow users to specify options to apply to server / pools / peers

I would like to add the ability to separate the server list from the options applied to each server in the list similarly to the way the openstack chrony role works. For my use and hopefully others the separation makes the configuration more expandable.

The way it is done in the openstack version is they have a global options variable like the following with an empty default set:

chrony_ntp_server_options: "iburst maxpoll 10"

Then in the template that value can be applied to each server like:

{% if chrony_ntp_servers|length > 0 %}
# List of NTP servers to use
{% for server in chrony_ntp_servers %}
server {{ server }} {{ chrony_ntp_server_options }}
{% endfor %}
{% endif %}

This allows me to use inventory groups to specify the servers like:

[STRATUM1_TIME_SERVERS]
time0s1.example.com
time1s1.example.com
time2s1.example.com

[PROD_TIME_SERVERS]
prod-time0.example.com
prod-time1.example.com
prod-time2.example.com

So when I want to setup the PROD_TIME_SERVERS with STRATUM1_TIME_SERVERS as their servers I can do the following

chrony_ntp_server_options: "iburst maxpoll 10"
chrony_ntp_servers: "{{ groups.STRATUM1_TIME_SERVERS }}"

Without defining chrony_ntp_server_options the role should work as before.

Installation problem

Hi, Today I noticed that there is no archive to download from github. We have been using the role for several months and before we had no problem installing it.

$ ansible-galaxy install frzk.chrony -f
Starting galaxy role install process
- downloading role 'chrony', owned by frzk
- downloading role from https://github.com/Frzk/ansible-role-chrony/archive/master.tar.gz
 [ERROR]: failed to download the file: HTTP Error 404: Not Found
[WARNING]: - frzk.chrony was NOT installed successfully.
ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.

Please do a release of your ansible-role-chrony

Hi,

Nice ansible role, please do a release tag on it so the user can do a version in requirements.yml. It will help when you make changes and the user can decide to upgrade their code to your new patch or changes on a schedule, not just a thing that happens.

Thank You, GearBoxScott

Why does the role update the system timezone?

Since this is a chrony role I'm confused as to why the role is setting the system time zone.

- name: Set up timezone

For example, on RHEL8 the system time zone is set to "America/New_York". That value is incompatible with crony's leapsectz setting. The leapsectz setting accepts only EST, EDT, UTC, etc. It does not support the America/New_York style value.

I recommend that setting of the system time zone be remove entirely as this isn't something that chrony should be doing.

Debian 12 AppArmor

I had to disable AppArmor for chrony to get this working on Debian 12. Can you please verify and fix if you agree? I may be out of my depth.

Here's what I had to run:
aa-complain /etc/apparmor.d/usr.sbin.chronyd

(Molecule) Fails to create Ansible's temporary directory

The molecule converge calls Ansible, which fails to gather facts because it couldn't create temporary directory.
The root cause seems more to be that the instance is unreachable.

The error message is:

PLAY [Converge] ****************************************************************
  
  TASK [Gathering Facts] *********************************************************
  fatal: [instance]: UNREACHABLE! => changed=false 
    msg: 'Failed to create temporary directory. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in "/tmp", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p "` echo /tmp `"&& mkdir "` echo /tmp/ansible-tmp-1685568278.5878556-2111-47362399749280 `" && echo ansible-tmp-1685568278.5878556-2111-47362399749280="` echo /tmp/ansible-tmp-1685568278.5878556-2111-47362399749280 `" ), exited with result 1'
    unreachable: true

The provisioner is configured like this:

provisioner:
  name: ansible
  env:
    ANSIBLE_LOCAL_TEMP: "${WORKSPACE:-$HOME}/.ansible/tmp"
    ANSIBLE_REMOTE_TMP: /tmp

Seems related to ansible/molecule#3818

(Molecule) Find a way to run tests in an unprivileged Docker container

All my attempts to run tests in an unprivileged container were unsuccessful.
I tried to run with:

capabilities:
  - SYS_ADMIN
  - SYS_TIME
privileged: false

which should be sufficient (?)
But we get this result:

TASK [frzk.chrony : Set up timezone] *******************************************
[WARNING]: timedatectl command was found but not usable: Failed to query
server: Connection timed out . using other method.
fatal: [instance]: FAILED! => changed=false 
  msg: |-
    Error message:
    tried to configure name using a file "/etc/sysconfig/clock", but could not write to it

PLAY RECAP *********************************************************************
instance                   : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

CRITICAL Ansible return code was 2, command was: ansible-playbook --diff --inventory /home/runner/.cache/molecule/frzk.chrony/default/inventory --skip-tags molecule-notest,notest /home/runner/work/ansible-role-chrony/ansible-role-chrony/frzk.chrony/molecule/default/converge.yml
WARNING  An error occurred during the test sequence action: 'converge'. Cleaning up.

I sadly don't have time to dive into Docker internals and whatever. So we'll run in privileged mode for now.
Any help appreciated :-)

Inconsistent tag format may be causing failing galaxy installs

We've found our ansible-galaxy installs are failing recently and it appears to be related to frzk.chrony's change in tag format.

[WARNING]: - frzk.chrony was NOT installed successfully: Unable to compare role
versions (1.0.0, v2.0.0) to determine the most recent version due to
incompatible version formats. Please contact the role author to resolve
versioning conflicts, or specify an explicit role version to install.
ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.

I have a requirements file like such:

- src: frzk.chrony
  version: 1.0.0

Our builds are unable to execute now and I cannot figure out how to get Ansible to just use the given version. Please advise

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.