1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_ntp.git synced 2024-08-16 12:59:49 +02:00

use modern ansible name scheme and remove travis

This commit is contained in:
L3D 2021-03-12 13:20:58 +01:00
parent fcd83491f8
commit 3974bd6500
Signed by: l3d
GPG key ID: CD08445BFF4313D1
16 changed files with 76 additions and 231 deletions

View file

@ -1,2 +0,0 @@
skip_list:
- '305'

View file

@ -1,9 +0,0 @@
---
- name: install and test this ntp role
hosts: localhost
tags:
- default
roles:
- './'
vars:
- submodules_versioncheck: false

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.cache

View file

@ -1,81 +0,0 @@
---
version: "~> 1.0"
os: linux
language: python
python:
- '3.8'
- '3.7'
- '3.6'
services: docker
cache:
pip: true
directories:
- ".tox"
install:
- pip install tox-travis
env:
jobs:
- TOX_DISTRO=archlinuxlatest TOX_ANSIBLE=latest
- TOX_DISTRO=alpinelatest TOX_ANSIBLE=latest
- TOX_DISTRO=alpine310 TOX_ANSIBLE=latest
- TOX_DISTRO=alpine39 TOX_ANSIBLE=latest
- TOX_DISTRO=centoslatest TOX_ANSIBLE=latest
- TOX_DISTRO=centos8 TOX_ANSIBLE=latest
- TOX_DISTRO=centos7 TOX_ANSIBLE=latest
- TOX_DISTRO=clearlinuxlatest TOX_ANSIBLE=latest
- TOX_DISTRO=debianlatest TOX_ANSIBLE=latest
- TOX_DISTRO=debianstable TOX_ANSIBLE=latest
- TOX_DISTRO=debian10 TOX_ANSIBLE=latest
- TOX_DISTRO=debian9 TOX_ANSIBLE=latest
- TOX_DISTRO=debian8 TOX_ANSIBLE=latest
- TOX_DISTRO=fedoralatest TOX_ANSIBLE=latest
- TOX_DISTRO=fedora31 TOX_ANSIBLE=latest
- TOX_DISTRO=fedora30 TOX_ANSIBLE=latest
- TOX_DISTRO=fedora29 TOX_ANSIBLE=latest
- TOX_DISTRO=fedora28 TOX_ANSIBLE=latest
- TOX_DISTRO=opensuselatest TOX_ANSIBLE=latest
- TOX_DISTRO=opensuse15 TOX_ANSIBLE=latest
- TOX_DISTRO=ubuntulatest TOX_ANSIBLE=latest
- TOX_DISTRO=ubuntu2004 TOX_ANSIBLE=latest
- TOX_DISTRO=ubuntu1904 TOX_ANSIBLE=latest
- TOX_DISTRO=ubuntu1804 TOX_ANSIBLE=latest
- TOX_DISTRO=ubuntu1604 TOX_ANSIBLE=latest
- TOX_DISTRO=alpinelatest TOX_ANSIBLE={29,28}
- TOX_DISTRO=alpine310 TOX_ANSIBLE={29,28}
- TOX_DISTRO=alpine39 TOX_ANSIBLE={29,28}
- TOX_DISTRO=centoslatest TOX_ANSIBLE={29,28}
- TOX_DISTRO=centos8 TOX_ANSIBLE={29,28}
- TOX_DISTRO=centos7 TOX_ANSIBLE={29,28}
- TOX_DISTRO=clearlinuxlatest TOX_ANSIBLE={29,28}
- TOX_DISTRO=debianlatest TOX_ANSIBLE={29,28}
- TOX_DISTRO=debianstable TOX_ANSIBLE={29,28}
- TOX_DISTRO=debian10 TOX_ANSIBLE={29,28}
- TOX_DISTRO=debian9 TOX_ANSIBLE={29,28}
- TOX_DISTRO=debian8 TOX_ANSIBLE={29,28}
- TOX_DISTRO=fedoralatest TOX_ANSIBLE={29,28}
- TOX_DISTRO=fedora31 TOX_ANSIBLE={29,28}
- TOX_DISTRO=fedora30 TOX_ANSIBLE={29,28}
- TOX_DISTRO=fedora29 TOX_ANSIBLE={29,28}
- TOX_DISTRO=fedora28 TOX_ANSIBLE={29,28}
- TOX_DISTRO=opensuselatest TOX_ANSIBLE={29,28}
- TOX_DISTRO=opensuse15 TOX_ANSIBLE={29,28}
- TOX_DISTRO=ubuntulatest TOX_ANSIBLE={29,28}
- TOX_DISTRO=ubuntu2004 TOX_ANSIBLE={29,28}
- TOX_DISTRO=ubuntu1904 TOX_ANSIBLE={29,28}
- TOX_DISTRO=ubuntu1804 TOX_ANSIBLE={29,28}
- TOX_DISTRO=ubuntu1604 TOX_ANSIBLE={29,28}
script:
- tox -e $(echo py${TRAVIS_PYTHON_VERSION} | tr -d .)-ansible${TOX_ANSIBLE}-${TOX_DISTRO}
- |
rm -r .tox/py*/log/*
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View file

@ -19,8 +19,7 @@ ntp_servers:
- 3.pool.ntp.org iburst - 3.pool.ntp.org iburst
# Enable or disable ntp statistics # Enable or disable ntp statistics
# Default is false
ntp_statistics: false ntp_statistics: false
# version check for this playbook # version check for this playbook (true is recomended)
submodules_versioncheck: true submodules_versioncheck: false

View file

@ -1,20 +1,18 @@
--- ---
# handlers file for ansible-role-ntp
- name: Restart ntp daemons on Linux - name: Restart ntp daemons on Linux
become: yes become: true
service: service:
name: "{{ ntp_service }}" name: "{{ ntp_service }}"
state: restarted state: restarted
- name: Restart ntp daemons on FreeBSD - name: Restart ntp daemons on FreeBSD
become: yes become: true
service: service:
name: "{{ ntp_service }}" name: "{{ ntp_service }}"
state: restarted state: restarted
- name: Restart ntp daemons on OpenBSD - name: Restart ntp daemons on OpenBSD
become: yes become: true
service: service:
name: "{{ ntp_service }}" name: "{{ ntp_service }}"
state: restarted state: restarted

View file

@ -1,46 +1,24 @@
galaxy_info: galaxy_info:
role_name: ntp role_name: ntp
author: L3D author: do1jlr
description: Ansible role for manage ntp daemon description: Ansible role for manage ntp daemon
license: "Apache" license: "Apache"
min_ansible_version: 2.7 min_ansible_version: 2.8
platforms: platforms:
- name: Archlinux - name: Archlinux
versions: all versions: all
- name: Alpine - name: Alpine
version: version: all
- latest
- 3.10
- 3.9
- 3.8
- name: Clearlinux - name: Clearlinux
version: version: all
- latest
- name: Debian - name: Debian
versions: versions: all
- latest
- stable
- 10
- 9
- 8
- name: EL - name: EL
versions: versions: all
- latest
- 8
- 7
- name: Fedora - name: Fedora
versions: versions: all
- latest
- 31
- 30
- 29
- 28
- name: Suse
versions:
- latest
- 15
galaxy_tags: galaxy_tags:
- system - system

View file

@ -2,9 +2,9 @@
# Tasks file for config ntp daemon # Tasks file for config ntp daemon
- name: seting-up ntp config - name: seting-up ntp config
become: yes become: true
template: ansible.builtin.template:
src: ntp.conf.j2 src: templates/ntp.conf.j2
dest: "{{ ntp_configfile }}" dest: "{{ ntp_configfile }}"
owner: "{{ ntp_configfile_user }}" owner: "{{ ntp_configfile_user }}"
group: "{{ ntp_configfile_group }}" group: "{{ ntp_configfile_group }}"

View file

@ -1,12 +1,12 @@
--- ---
- include_tasks: versioncheck.yml - name: run versionscheck if enabled
ansible.builtin.include_tasks: versioncheck.yml
when: submodules_versioncheck|bool when: submodules_versioncheck|bool
- name: Include OS specific variables. - name: Include OS specific variables.
include_vars: "{{ ansible_os_family }}.yml" ansible.builtin.include_vars: "{{ lookup('first_found', ntp__vars) }}"
- name: Install ntp - name: Install ntp
include_tasks: "packages/setup-{{ ansible_system }}.yml" ansible.builtin.include_tasks: "{{ lookup('first_found', ntp__install) }}"
- name: Configure ntp - name: Configure ntp
include_tasks: config.yml ansible.builtin.include_tasks: config.yml

View file

@ -2,8 +2,8 @@
# Tasks file for install ntp daemon on MacOSX system # Tasks file for install ntp daemon on MacOSX system
- name: Service ntp on MacOSX - name: Service ntp on MacOSX
become: yes become: true
service: ansible.builtin.service:
name: "{{ ntp_service }}" name: "{{ ntp_service }}"
enabled: yes enabled: true
state: started state: started

View file

@ -1,21 +1,29 @@
--- ---
# Tasks file for install ntp daemon on Linux system # Tasks file for install ntp daemon on Linux system
- name: Update apt cache
become: true
ansible.builtin.apt:
cache_valid_time: 3600
update_cache: true
when:
- ansible_pkg_mgr == "apt"
- name: Update emerge cache on Gentoo - name: Update emerge cache on Gentoo
become: yes become: true
shell: emerge-webrsync ansible.builtin.shell: emerge-webrsync
changed_when: false changed_when: false
when: ansible_os_family == "Gentoo" when: ansible_os_family == "Gentoo"
- name: Install ntp daemon on Linux - name: Install ntp daemon on Linux
become: yes become: true
package: ansible.builtin.package:
name: "{{ ntp_package }}" name: "{{ ntp_package }}"
state: present state: present
- name: Service ntp on Linux - name: Service ntp on Linux
become: yes become: true
service: ansible.builtin.service:
name: "{{ ntp_service }}" name: "{{ ntp_service }}"
enabled: yes enabled: true
state: started state: started

View file

@ -2,14 +2,14 @@
# Tasks file for install ntp daemon on OpenBSD system # Tasks file for install ntp daemon on OpenBSD system
- name: Install ntp daemon on OpenBSD - name: Install ntp daemon on OpenBSD
become: yes become: true
package: ansible.builtin.package:
name: "{{ ntp_package }}" name: "{{ ntp_package }}"
state: present state: present
- name: Service ntp on OpenBSD - name: Service ntp on OpenBSD
become: yes become: true
service: ansible.builtin.service:
name: "{{ ntp_service }}" name: "{{ ntp_service }}"
enabled: yes enabled: true
state: started state: started

View file

@ -1,7 +1,7 @@
--- ---
- name: Create directory for versionscheck - name: Create directory for versionscheck
become: true become: true
file: ansible.builtin.file:
path: '/etc/.ansible-version' path: '/etc/.ansible-version'
state: directory state: directory
mode: 0755 mode: 0755
@ -9,38 +9,38 @@
- name: check playbook version - name: check playbook version
become: true become: true
slurp: ansible.builtin.slurp:
src: "/etc/.ansible-version/{{ playbook_version_path }}" src: "/etc/.ansible-version/{{ playbook_version_path }}"
register: playbook_version register: playbook_version
when: submodules_versioncheck|bool when: submodules_versioncheck|bool
ignore_errors: yes ignore_errors: true
failed_when: false failed_when: false
- name: Print remote role version - name: Print remote role version
debug: ansible.builtin.debug:
msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}"
when: submodules_versioncheck|bool when: submodules_versioncheck|bool
- name: Print locale role version - name: Print locale role version
debug: ansible.builtin.debug:
msg: "Local role version: '{{ playbook_version_number|string }}'." msg: "Local role version: '{{ playbook_version_number|string }}'."
when: submodules_versioncheck|bool when: submodules_versioncheck|bool
- name: Check if your version is outdated - name: Check if your version is outdated
fail: ansible.builtin.fail:
msg: "Your ansible module has the version '{{ playbook_version_number }}' and is outdated. You need to update it!" msg: "Your ansible module has the version '{{ playbook_version_number }}' and is outdated. You need to update it!"
when: when:
- playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck|bool - playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck|bool
- name: check if '/etc/ansible-version/' is empty - name: check if '/etc/ansible-version/' is empty
find: ansible.builtin.find:
paths: '/etc/ansible-version/' paths: '/etc/ansible-version/'
register: filesFound register: filesFound
- name: write new version to remote disk - name: write new version to remote disk
become: true become: true
copy: ansible.builtin.copy:
content: "{{ playbook_version_number }}" content: "{{ playbook_version_number }}"
dest: "/etc/.ansible-version/{{ playbook_version_path }}" dest: "/etc/.ansible-version/{{ playbook_version_path }}"
mode: 0644 mode: '0644'
when: submodules_versioncheck|bool when: submodules_versioncheck|bool

68
tox.ini
View file

@ -1,68 +0,0 @@
[tox]
minversion = 3.7
envlist = py{3}-ansible{latest,29,28}-{ alpinelatest,alpine310,alpine39,alpine38, centoslatest,centos8,centos7, debianlatest,debian10,debian9,debian8, fedoralatest,fedora30,fedora29,fedora28, ubuntulatest,ubuntu2004,ubuntu1904,ubuntu1804,ubuntu1604 }
# only test currently supported ansible versions
# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#release-status
skipsdist = true
[base]
passenv = *
deps =
-r.requirements.txt
ansible25: ansible==2.5
ansible26: ansible==2.6
ansible27: ansible==2.7
ansible28: ansible==2.8
ansible29: ansible==2.9
ansiblelatest: ansible
commands =
ansible-playbook .ansible-test.yml -i localhost
setenv =
TOX_ENVNAME={envname}
MOLECULE_EPHEMERAL_DIRECTORY=/tmp/{envname}
[testenv]
passenv =
{[base]passenv}
deps =
{[base]deps}
commands =
{[base]commands}
setenv =
archlinuxlatest: MOLECULE_DISTRO="archlinux:latest"
alpinelatest: MOLECULE_DISTRO="alpine:latest"
alpine310: MOLECULE_DISTRO="alpine:3.10"
alpine39: MOLECULE_DISTRO="alpine:3.9"
alpine38: MOLECULE_DISTRO="alpine:3.8"
centoslatest: MOLECULE_DISTRO="centos:latest"
centos8: MOLECULE_DISTRO="centos:8"
centos7: MOLECULE_DISTRO="centos:7"
clearlinuxlatest: MOLECULE_DISTRO="clearlinux:latest"
debianlatest: MOLECULE_DISTRO="debian:latest"
debianstable: MOLECULE_DISTRO="debian:stable"
debian10: MOLECULE_DISTRO="debian:10"
debian9: MOLECULE_DISTRO="debian:9"
debian8: MOLECULE_DISTRO="debian:8"
fedoralatest: MOLECULE_DISTRO="fedora:latest"
fedora31: MOLECULE_DISTRO="fedora:31"
fedora30: MOLECULE_DISTRO="fedora:30"
fedora29: MOLECULE_DISTRO="fedora:29"
fedora28: MOLECULE_DISTRO="fedora:28"
opensuselatest: MOLECULE_DISTRO="opensuse/leap:latest"
opensuse15: MOLECULE_DISTRO="opensuse/leap:15"
ubuntulatest: MOLECULE_DISTRO="ubuntu:latest"
ubuntu2004: MOLECULE_DISTRO="ubuntu:20.04"
ubuntu1904: MOLECULE_DISTRO="ubuntu:19.04"
ubuntu1804: MOLECULE_DISTRO="ubuntu:18.04"
ubuntu1604: MOLECULE_DISTRO="ubuntu:16.04"
{[base]setenv}

7
vars/fallback.yml Normal file
View file

@ -0,0 +1,7 @@
ntp_package: ntp
ntp_service: ntp
ntp_configfile: /etc/ntp.conf
ntp_configfile_user: root
ntp_configfile_group: root
ntp_driftfile: /var/lib/ntp/drift

View file

@ -1,3 +1,17 @@
--- ---
playbook_version_number: 2049 # should be over ninethousand playbook_version_number: 2050 # should be int
playbook_version_path: 'role-ntp_chaos-bodensee_github.com.version' playbook_version_path: 'role-ntp_chaos-bodensee_github.com.version'
ntp__vars:
files:
- "{{ ansible_os_family }}.yml"
- 'fallback.yml'
paths:
- 'vars'
ntp__install:
files:
- "setup-{{ ansible_system }}.yml"
- 'setup-Linux.yml'
paths:
- 'tasks/packages'