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

Update travis checks

This commit is contained in:
Lilian Roller 2020-01-16 17:01:25 +01:00
parent e613663215
commit 46f1d8fdfd
No known key found for this signature in database
GPG key ID: 5215C3441797AB2B
16 changed files with 154 additions and 429 deletions

9
.ansible-test.yml Normal file
View file

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

4
.gitignore vendored
View file

@ -1,4 +0,0 @@
Gemfile.lock
.kitchen
tests/inspec/inspec.lock
Dockerfile-kitchen*

View file

@ -1,107 +0,0 @@
---
# we use docker as plateform
driver:
name: vagrant
# Ansible will be our provisioner
provisioner:
name: ansible_playbook
hosts: localhost
require_chef_for_busser: false
require_ruby_for_busser: false
require_ansible_omnibus: false
idempotency_test: true
# We use Inspec as testing framework
verifier:
name: inspec
inspec_tests:
- path: tests/inspec
# Build platforms
platforms:
# Standard Linux
- name: centos-7
- name: centos-6
- name: fedora-28
- name: fedora-27
- name: fedora-26
- name: ubuntu-18.04
- name: ubuntu-17.10
- name: ubuntu-16.04
- name: ubuntu-14.04
- name: debian-9
- name: debian-8
- name: debian-7
- name: oraclelinux-7
driver:
box: bento/oracle-7
- name: oraclelinux-6
driver:
box: bento/oracle-6
# Archlinux
- name: archlinux-rolling
driver:
box: archlinux/archlinux
provision: true
vagrantfiles:
- tests/vagrant/vagrant_archlinux_target.rb
# Gentoo
- name: gentoo
driver:
box: generic/gentoo
provision: true
vagrantfiles:
- tests/vagrant/vagrant_gentoo_target.rb
# FreeBSD
- name: freebsd-11.2
driver:
box: bento/freebsd-11.2
provision: true
vagrantfiles:
- tests/vagrant/vagrant_freebsd_target.rb
- name: freebsd-10.4
driver:
box: bento/freebsd-10.4
provision: true
vagrantfiles:
- tests/vagrant/vagrant_freebsd_target.rb
- name: freebsd-10.3
driver:
box: bento/freebsd-10.3
provision: true
vagrantfiles:
- tests/vagrant/vagrant_freebsd_target.rb
# OpenBSD
- name: openbsd-6
driver:
box: generic/openbsd6
provision: true
vagrantfiles:
- tests/vagrant/vagrant_openbsd_target.rb
# Mac osx
- name: macosx-10.11
driver:
box: jhcook/osx-elcapitan-10.11
provision: true
provisioner:
name: ansible_playbook
ansible_binary_path: /usr/local/bin/
- name: macosx-10.10
driver:
box: jhcook/osx-yosemite-10.10
provision: true
provisioner:
name: ansible_playbook
ansible_binary_path: /usr/local/bin/
suites:
- name: default
provisioner:
name: ansible_playbook
playbook: tests/test.yml

View file

@ -1,137 +0,0 @@
---
# we use docker as plateform
driver:
name: docker
privileged: true
volume: /sys/fs/cgroup:/sys/fs/cgroup
# Ansible will be our provisioner
provisioner:
name: ansible_playbook
hosts: localhost
require_chef_for_busser: false
require_ruby_for_busser: false
require_ansible_omnibus: false
idempotency_test: true
verifier:
name: inspec
inspec_tests:
- path: tests/inspec
platforms:
# Centos
- name: centos-7
driver:
image: diodonfrost/centos-7-ansible
run_command: /sbin/init
platform: centos
provision_command:
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
- name: centos-6
driver:
image: diodonfrost/centos-6-ansible
platform: centos
run_command: /sbin/init
provision_command:
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
# Fedora
- name: fedora-27
driver:
image: diodonfrost/fedora-27-ansible
run_command: /usr/sbin/init
platform: centos
provision_command:
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
- name: fedora-26
driver:
image: diodonfrost/fedora-26-ansible
run_command: /usr/sbin/init
platform: centos
provision_command:
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
# Ubuntu
- name: ubuntu-18.04
driver:
image: diodonfrost/ubuntu-18.04-ansible
provision_command: apt-get install -y init
run_command: /sbin/init
platform: ubuntu
- name: ubuntu-16.04
driver:
image: diodonfrost/ubuntu-16.04-ansible
provision_command: apt-get install -y init
run_command: /sbin/init
platform: ubuntu
- name: ubuntu-14.04
driver:
image: diodonfrost/ubuntu-14.04-ansible
platform: ubuntu
run_command: /sbin/init
provision_command:
- apt-get install -y init
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
# Debian
- name: debian-9
driver:
image: diodonfrost/debian-9-ansible
provision_command: apt-get install -y systemd
run_command: /bin/systemd
platform: debian
- name: debian-8
driver:
image: diodonfrost/debian-8-ansible
run_command: /sbin/init
platform: debian
- name: debian-7
driver:
image: diodonfrost/debian-7-ansible
platform: debian
# Oraclelinux
- name: oraclelinux-7
driver:
image: diodonfrost/oraclelinux-7-ansible
run_command: /usr/sbin/init
platform: centos
provision_command:
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
- systemctl enable sshd
- name: oraclelinux-6
driver:
image: diodonfrost/oraclelinux-6-ansible
run_command: /sbin/init
platform: centos
# Amazonlinux
- name: amazonlinux-2
driver:
image: diodonfrost/amazonlinux-2-ansible
run_command: /usr/sbin/init
platform: centos
provision_command:
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
- name: amazonlinux-1
driver:
image: diodonfrost/amazonlinux-1-ansible
run_command: /sbin/init
platform: centos
# Archlinux
- name: archlinux-rolling
driver:
image: diodonfrost/archlinux-rolling-ansible
run_command: /usr/lib/systemd/systemd
provision_command:
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
- systemctl enable sshd
suites:
# Test openjdk-latest
- name: default
provisioner:
name: ansible_playbook
playbook: tests/test.yml

2
.requirements.txt Normal file
View file

@ -0,0 +1,2 @@
docker
molecule

View file

@ -1,107 +1,81 @@
---
services:
- docker
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:
#-----------------------------------------------
#
# CentOS
#
#-----------------------------------------------
- distribution: centos
version: "7"
- distribution: centos
version: "6"
#--------------------------------
#
# Fedora
#
#--------------------------------
- distribution: fedora
version: "28"
- distribution: fedora
version: "27"
- distribution: fedora
version: "26"
#--------------------------------
#
# Ubuntu
#
#--------------------------------
- distribution: ubuntu
version: "18.04"
- distribution: ubuntu
version: "16.04"
- distribution: ubuntu
version: "14.04"
- distribution: ubuntu
version: "12.04"
#--------------------------------
#
# Debian
#
#--------------------------------
- distribution: debian
version: "9"
- distribution: debian
version: "8"
#--------------------------------
#
# Oraclelinux
#
#--------------------------------
- distribution: oraclelinux
version: "7"
- distribution: oraclelinux
version: "6"
#--------------------------------
#
# Amazonlinux
#
#--------------------------------
- distribution: amazonlinux
version: "2"
- distribution: amazonlinux
version: "1"
#--------------------------------
#
# Archlinux
#
#--------------------------------
- distribution: archlinux
version: "rolling"
before_install:
# Build docker container
- 'sudo docker pull diodonfrost/${distribution}-${version}-ansible:latest'
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:
- container_id=$(mktemp)
# Run container and mount ansible role with it
- 'sudo docker run --detach --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --volume="${PWD}":/etc/ansible/roles/ansible-role-ntp:ro diodonfrost/${distribution}-${version}-ansible:latest > "${container_id}"'
# Check syntax
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/ansible-role-ntp/tests/test.yml --syntax-check'
# Run ansible playbook
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/ansible-role-ntp/tests/test.yml'
# Test indempotence
- >
sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/ansible-role-ntp/tests/test.yml
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Delete container
- 'sudo docker rm -f "$(cat ${container_id})"'
- 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

@ -1,17 +0,0 @@
# Test ntp config
ntp_configfile = '/etc/ntp.conf'
control 'config-01' do
impact 1.0
title 'Ntp server'
desc 'Ntp worldwide servers should be present'
describe file(ntp_configfile) do
its('owner') { should eq 'root' }
its('mode') { should cmp '0644' }
its('content') { should match /server 0.pool.ntp.org iburst/ }
its('content') { should match /server 1.pool.ntp.org iburst/ }
its('content') { should match /server 2.pool.ntp.org iburst/ }
its('content') { should match /server 3.pool.ntp.org iburst/ }
end
end

View file

@ -1,24 +0,0 @@
# Test ntp daemon install
ntp_package = "ntp"
ntp_service = "ntpd"
ntp_service = "ntp" if os.family == "debian"
control 'install-01' do
impact 1.0
title 'Ntp package'
desc 'Ntp daemon package should be install'
describe package(ntp_package) do
it { should be_installed }
end
end
control 'install-02' do
impact 1.0
title 'Ntp service'
desc 'Ntp service should be enabled and started'
describe service(ntp_service) do
it { should be_enabled }
it { should be_running }
end
end

View file

@ -1,2 +0,0 @@
localhost

View file

@ -1,5 +0,0 @@
---
- hosts: localhost
remote_user: root
roles:
- ansible-role-ntp

View file

@ -1,5 +0,0 @@
Vagrant.configure(2) do |config|
config.vm.provision "shell", inline: <<-SHELL
pacman --noconfirm -Syu ansible
SHELL
end

View file

@ -1,7 +0,0 @@
Vagrant.configure(2) do |config|
config.vm.provision "shell", inline: <<-SHELL
pkg install -y ncurses python
pkg install -y py27-ansible
ln -s /usr/local/bin/python2.7 /usr/bin/python
SHELL
end

View file

@ -1,11 +0,0 @@
Vagrant.configure(2) do |config|
config.vm.provision "shell", inline: <<-SHELL
emerge --sync
echo 'USE=-bindist' >> /etc/portage/make.conf
echo 'dev-lang/python sqlite' >> /etc/portage/package.use/python
emerge net-misc/openssh app-admin/sudo app-admin/ansible app-portage/gentoolkit
# Enable features on specific package for java install
echo 'x11-libs/cairo X' > /etc/portage/package.use/cairo
echo 'app-text/ghostscript-gpl cups' > /etc/portage/package.use/ghostscript-gpl
SHELL
end

View file

@ -1,9 +0,0 @@
Vagrant.configure(2) do |config|
config.vm.provision "shell", inline: <<-SHELL
OPENBSD_VERSION=`uname -a | awk -F " " '{print $3}'`
wget -P /tmp https://ftp.openbsd.org/pub/OpenBSD/${OPENBSD_VERSION}/amd64/xbase64.tgz
cd / && tar xzvphf /tmp/xbase64.tgz
pkg_add -z ansible
ln -s /usr/local/bin/python2.7 /usr/bin/python
SHELL
end

68
tox.ini Normal file
View file

@ -0,0 +1,68 @@
[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}

View file

@ -1,3 +1,3 @@
---
playbook_version_number: 1024 # should be over ninethousand
playbook_version_number: 2048 # should be over ninethousand
playbook_version_path: 'role-ntp_chaos-bodensee_github.com.version'