Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playbooks/generic/chrony-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
tasks:
- name: Configure Chrony client
include_role:
name: DeepOps.chrony
name: deepops_chrony
2 changes: 1 addition & 1 deletion playbooks/generic/hosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

- name: set /etc/hosts
include_role:
name: DeepOps.hosts
name: deepops_hosts
vars:
hosts_add_ansible_managed_hosts: true
2 changes: 1 addition & 1 deletion playbooks/generic/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@

- name: Set user password
include_role:
name: DeepOps.users
name: deepops_users
2 changes: 1 addition & 1 deletion playbooks/utilities/user-password.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
ssh_max_auth_retries: 10
- name: Set user password
include_role:
name: DeepOps.users
name: deepops_users
vars:
# User Configuration
users:
Expand Down
5 changes: 5 additions & 0 deletions roles/deepops_chrony/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.idea
*.DS_Store
*.retry
*/__pycache__
*.pyc
26 changes: 26 additions & 0 deletions roles/deepops_chrony/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
language: python
services: docker

env:
global:
- ROLE_NAME: chrony

install:
# Install test dependencies.
- pip install molecule docker testinfra

before_script:
# Use actual Ansible Galaxy role name for the project directory.
- cd ../
- mv ansible-role-$ROLE_NAME unxnn.$ROLE_NAME
- cd unxnn.$ROLE_NAME

script:
# Run tests.
- ansible --version
- molecule --version
- molecule test

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
20 changes: 20 additions & 0 deletions roles/deepops_chrony/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MIT License

Copyright (c) unxnn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
51 changes: 51 additions & 0 deletions roles/deepops_chrony/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!-- Vendored into DeepOps from https://github.com/DeepOps/ansible-role-chrony at commit c9022153036dfdde4e2b313aecde4a46cd6f6687. -->
# Ansible Role: Chrony

This role enables users to install and configure chrony on their hosts.

## Build Status

[![Build Status](https://travis-ci.org/unxnn/ansible-role-chrony.svg?branch=master)](https://travis-ci.org/unxnn/ansible-role-chrony)

## Requirements

None

## Role Variables

| Variable | Required | Default | Comments |
|----------|----------|---------|----------|
| `chrony_pkg_state` | No | `present` | Set pkg `enabled`, `disabled`, `latest` |
| `chrony_service_state` | No | `started` | Set service state, started, enabled or disabled |
| `chrony_service_enabled` | No | `yes` | A list of NTP servers to use. |
| `chrony_config_server` | No | `["0.pool.ntp.org","1.pool.ntp.org","2.pool.ntp.org", "3.pool.ntp.org"]` | A list of NTP servers to use. |
| `chrony_config_logdir` | No | `/var/log/chrony` | A list of NTP servers to use. |
| `chrony_timezone` | No | `Etc/UTC` | Set the timezone for your server. |

## Examples

1) Install chrony and use the default settings.

```

- hosts: all
roles:
- role: unxnn.chrony
```

2) Install chrony and use custom servers.

```

- hosts: all
roles:
- role: unxnn.chrony
vars:
chrony_config_server:
- 0.pool.ntp.org
- 2.pool.ntp.org
```

## License

MIT
11 changes: 11 additions & 0 deletions roles/deepops_chrony/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
chrony_pkg_state: present
chrony_service_state: started
chrony_service_enabled: yes
chrony_config_server:
- 0.pool.ntp.org
- 1.pool.ntp.org
- 2.pool.ntp.org
- 3.pool.ntp.org
chrony_config_logdir: /var/log/chrony
chrony_timezone: Etc/UTC
3 changes: 3 additions & 0 deletions roles/deepops_chrony/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: restart chrony
service: name={{ chrony_service_name }} state=restarted
1 change: 1 addition & 0 deletions roles/deepops_chrony/meta/.galaxy_install_info
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{install_date: 'Thu Apr 2 19:22:01 2020', version: c95f84431c8c3ed693e88b35c87edf792fcf152f}
29 changes: 29 additions & 0 deletions roles/deepops_chrony/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
galaxy_info:
author: unxnn
role_name: chrony
description: This role enables users to install and configure chrony on their hosts.
license: MIT
min_ansible_version: 2.4
platforms:
- name: EL
versions:
- 7
- 8
- name: Debian
versions:
- jessie
- stretch
- buster
- name: Ubuntu
versions:
- bionic
- cosmic
- disco
- eoan
galaxy_tags:
- system
- chrony
- ntp
- time
dependencies: []
3 changes: 3 additions & 0 deletions roles/deepops_chrony/tasks/debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Install the require packages in Debian derivatives
apt: name=chrony state={{ chrony_pkg_state }}
30 changes: 30 additions & 0 deletions roles/deepops_chrony/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
- name: Add the OS specific variables
include_vars: "{{ ansible_os_family|lower }}.yml"

- name: Installation
include_tasks: "{{ ansible_os_family|lower }}.yml"

- name: Copy the chrony.conf template file
template:
src: chrony.conf.j2
dest: "{{ chrony_config_location }}"
mode: "0644"
owner: root
group: root
notify:
- restart chrony

- name: Start and enable chrony service
service:
name: "{{ chrony_service_name }}"
state: "{{ chrony_service_state }}"
enabled: "{{ chrony_service_enabled }}"

- name: Ensure tzdata package is installed
package:
name: "{{ chrony_tzdata_package }}"
state: present

- name: Set timezone
timezone: name="{{ chrony_timezone }}"
11 changes: 11 additions & 0 deletions roles/deepops_chrony/tasks/redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: Install the required packages in Redhat derivatives
yum: name=chrony state={{ chrony_pkg_state }}

- name: Check if ntpd service exists
stat: path="/usr/lib/systemd/system/ntpd.service"
register: ntpd_service_status

- name: Stop and mask ntpd service
systemd: name=ntpd state=stopped masked=yes
when: ntpd_service_status.stat.exists
46 changes: 46 additions & 0 deletions roles/deepops_chrony/templates/chrony.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# {{ ansible_managed }}

# List of NTP servers to use.
{% for server in chrony_config_server %}
server {{ server }} iburst
{% endfor %}

# Ignore stratum in source selection.
stratumweight 0

# Record the rate at which the system clock gains/losses time.
driftfile {{ chrony_config_driftfile }}

# Enable kernel RTC synchronization.
rtcsync

# In first three updates step the system clock instead of slew
# if the adjustment is larger than 10 seconds.
makestep 10 3

# Allow NTP client access from local network.
#allow 192.168/16

# Listen for commands only on localhost.
bindcmdaddress 127.0.0.1
bindcmdaddress ::1

# Serve time even if not synchronized to any NTP server.
#local stratum 10

keyfile {{ chrony_config_keyfile }}

# Specify the key used as password for chronyc.
commandkey 1

# Generate command key if missing.
generatecommandkey

# Disable logging of client accesses.
noclientlog

# Send a message to syslog if a clock adjustment is larger than 0.5 seconds.
logchange 0.5

logdir {{ chrony_config_logdir }}
#log measurements statistics tracking
6 changes: 6 additions & 0 deletions roles/deepops_chrony/vars/debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
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
chrony_tzdata_package: tzdata
6 changes: 6 additions & 0 deletions roles/deepops_chrony/vars/redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
chrony_service_name: chronyd
chrony_config_location: /etc/chrony.conf
chrony_config_driftfile: /var/lib/chrony/drift
chrony_config_keyfile: /etc/chrony.keys
chrony_tzdata_package: tzdata
16 changes: 16 additions & 0 deletions roles/deepops_hosts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# .gitignore

# Hidden Vagrant-directory
.vagrant

# Backup files (e.g. Vim, Gedit, etc.)
*~

# Vagrant base boxes (you never know when someone puts one in the repository)
*.box

# Compiled Python
*.pyc

# Test directory (sits in a separate branch)
tests/
13 changes: 13 additions & 0 deletions roles/deepops_hosts/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# BSD License

Copyright (c) 2014, Bert Van Vreckem, (bert.vanvreckem@gmail.com)

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading
Loading