pull/1/head
Davous3k 3 years ago
commit b8022a6047
  1. 12
      chrony.yml
  2. 11
      chrony/defaults/main.yml
  3. 3
      chrony/handlers/main.yml
  4. 42
      chrony/meta/main.yml
  5. 19
      chrony/tasks/main.yml
  6. 3
      chrony/tasks/ubuntu.yml
  7. 39
      chrony/templates/chrony.conf.j2
  8. 5
      chrony/vars/ubuntu.yml

@ -0,0 +1,12 @@
- name: Setup chrony
hosts: test
become: true
gather_facts: False
pre_tasks:
- name: 1. Check Python and install if not present
raw: test -e /usr/bin/python || ( apt -y update && apt install -y python)
changed_when: False
- name: 2. Gather facts
setup: # aka gather_facts
roles:
- chrony

@ -0,0 +1,11 @@
---
chrony_pkg_state: present
chrony_service_state: started
chrony_service_enabled: yes
chrony_config_server:
- 0.cz.pool.ntp.org
- 1.cz.pool.ntp.org
- 2.cz.pool.ntp.org
- 3.cz.pool.ntp.org
chrony_config_logdir: /var/log/chrony
chrony_config_extra_options: {}

@ -0,0 +1,3 @@
---
- name: restart chrony
service: name={{ chrony_service_name }} state=restarted

@ -0,0 +1,42 @@
---
galaxy_info:
author: davo
role_name: chrony
company: davo
description: Enables users to install and configure chrony on their hosts.
license: MIT
min_ansible_version: 2.4
platforms:
- name: Ubuntu
versions:
- artful
- bionic
- cosmic
- cuttlefish
- disco
- eoan
- focal
- groovy
- hirsute
- impish
- jammy
- lucid
- maverick
- natty
- precise
- quantal
- raring
- saucy
- trusty
- utopic
- vivid
- wily
- xenial
- yakkety
- zesty
galaxy_tags:
- system
- chrony
- ntp
- time
dependencies: []

@ -0,0 +1,19 @@
---
- name: chrony | Add the OS specific variables
include_vars: "ubuntu.yml"
- name: chrony | Installation
include_tasks: "ubuntu.yml"
- name: chrony | Copy the chrony.conf template file
template:
src: chrony.conf.j2
dest: "{{ chrony_config_location }}"
notify:
- restart chrony
- name: chrony | start and enable chrony service
service:
name: "{{ chrony_service_name }}"
state: "{{ chrony_service_state }}"
enabled: "{{ chrony_service_enabled }}"

@ -0,0 +1,3 @@
---
- name: Install the require packages in Ubuntu derivatives
apt: name=chrony state={{ chrony_pkg_state }}

@ -0,0 +1,39 @@
# {{ ansible_managed }}
# List of NTP servers to use.
{% for server in chrony_config_server %}
server {{ server }} iburst
{% endfor %}
# This directive specify the location of the file containing ID/key pairs for
# NTP authentication.
keyfile {{ chrony_config_keyfile }}
# This directive specify the file into which chronyd will store the rate
# information.
driftfile {{ chrony_config_driftfile }}
# Uncomment the following line to turn logging on.
#log tracking measurements statistics
# Log files location.
logdir {{chrony_config_logdir }}
# Stop bad estimates upsetting machine clock.
maxupdateskew 100.0
# Bind local adress
bindaddress 127.0.0.1
# This directive enables kernel synchronisation (every 11 minutes) of the
# real-time clock. Note that it can't be used along with the 'rtcfile' directive.
rtcsync
# Step the system clock instead of slewing it if the adjustment is larger than
# one second, but only in the first three clock updates.
makestep 1 3
# Extra options
{% for k, v in chrony_config_extra_options.items() %}
{{ k }} {{ v }}
{% endfor %}

@ -0,0 +1,5 @@
---
chrony_service_name: chrony
chrony_config_location: /etc/chrony/chrony.conf
chrony_config_driftfile: /var/lib/chrony/chrony.drift
chrony_config_keyfile: /etc/chrony/chrony.keys
Loading…
Cancel
Save