master
Davo 3 years ago
parent e992308cf6
commit 216c6e4b8f
  1. 2
      ansible-chrony.yml
  2. 0
      ansible-chrony/defaults/main.yml
  3. 6
      ansible-chrony/handlers/main.yml
  4. 27
      ansible-chrony/tasks/main.yml
  5. 6
      ansible-chrony/templates/chrony.conf.j2
  6. 5
      ansible-chrony/vars/main.yml
  7. 5
      chrony/handlers/main.yml
  8. 42
      chrony/meta/main.yml
  9. 31
      chrony/tasks/main.yml
  10. 5
      chrony/tasks/ubuntu.yml
  11. 8
      chrony/vars/ubuntu.yml

@ -9,5 +9,5 @@
- name: 2. Gather facts
setup: # aka gather_facts
roles:
- chrony #naming scheme - in large repo, use sw prefix when desgning a role for software "sw-chrony" or in standalone
- ansible-chrony #naming scheme - in large repo, use sw prefix when desgning a role for software "sw-chrony" or in standalone
# role like this one, use "ansible-chrony" to let the user know that this is in a fact an Ansible role

@ -0,0 +1,6 @@
---
- name: restart chrony
ansible.builtin.systemd:
state: restarted
daemon_reload: yes
name: chrony

@ -0,0 +1,27 @@
---
- name: chrony | 1. Install chrony
ansible.builtin.apt:
name: chrony
state: "{{ chrony_pkg_state }}"
- name: chrony | 2. Create custom chrony directory
ansible.builtin.file:
path: "{{ chrony_config_location }}"
state: directory
- name: chrony | 3. Copy the chrony.conf template file
ansible.builtin.template:
src: chrony.conf.j2
dest: "{{ chrony_config_location }}"
notify:
- restart chrony
- name: chrony | 4. Just force systemd to reread configs
ansible.builtin.systemd:
daemon_reload: yes
- name: chrony | 5. start and enable chrony service
ansible.builtin.service:
name: "{{ chrony_service_name }}"
state: "{{ chrony_service_state }}"
enabled: "{{ chrony_service_enabled }}"

@ -37,9 +37,3 @@ makestep 1 3
{% for k, v in chrony_config_extra_options.items() %}
{{ k }} {{ v }}
{% endfor %}
# popis mi plz, co tenhle cyklus udela v sablone pro nasledujici promenne (nad obsahem tech options se nezamyslej, ty jsem si vymyslel):
# chrony_config_extra_options:
# - time_server: ntp.davo.cz
# - follow_drift: yes

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

@ -1,5 +0,0 @@
---
- name: restart chrony
service: name={{ chrony_service_name }} state=restarted
#use newer style of ansible syntax - https://docs.ansible.com/ansible/latest/collections/ansible/builtin/systemd_module.html#examples

@ -1,42 +0,0 @@
---
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: []

@ -1,31 +0,0 @@
---
- name: chrony | Add the OS specific variables
include_vars: "ubuntu.yml"
# designujes roli pro jeden OS (nemas tam specificke vars pro rhel nebo centos)
# zjednodus to, misto include vars ubuntu.yml z vars slozky toto vypust a dej do vars slozky jen "main.yml", kde to vydefinujes
# ansible si to tak natahne by default a nemusis resit
- name: chrony | Installation
include_tasks: "ubuntu.yml"
# fajn ze to je oddelene pres include tasks, ale dalsi veci si neoddelil why?
# ten template a ta service by mohla byt v chrony-setup.yml a misto ubuntu.yml by si to mohl pojmenovat jako install.yml (protoze opet nemas OS-specific
# instalacni postupy, delame jen na ubuntu
- name: chrony | Copy the chrony.conf template file
template:
src: chrony.conf.j2
dest: "{{ chrony_config_location }}"
notify:
- restart chrony
# je dobry kvuli debugu a prehlednosti pojmenovat tasky i cislem od 1. a dale
# hodi se to kdyz poustis ansible, ze hnedka vidis roli + cislo, kde to dela problem
- name: chrony | start and enable chrony service
service:
name: "{{ chrony_service_name }}"
state: "{{ chrony_service_state }}"
enabled: "{{ chrony_service_enabled }}"
# daemon reload neni treba? nebo jo? rekni proc

@ -1,5 +0,0 @@
---
- name: Install the require packages in Ubuntu derivatives
apt: name=chrony state={{ chrony_pkg_state }}
# again old syntax, look up ansible apt module a opis to z toho

@ -1,8 +0,0 @@
---
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
# proc myslis, ze je dobry/neni dobry to mit pojmenovane vse s prefixem "chrony"?
Loading…
Cancel
Save