Skip to content
Snippets Groups Projects
Commit 04fbb160 authored by nimrod's avatar nimrod
Browse files

Merge branch 'master' of /home/nimrod/Documents/Shore/Ansible/example

# Conflicts:
#	README.rst
#	defaults/main.yml
#	handlers/main.yml
#	molecule.yml
#	tasks/main.yml
#	tests/playbook.yml
#	vars/main.yml
parents 3a3f00d3 d118eae4
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@
- id: check-merge-conflict
- id: flake8
- id: check-symlinks
- repo: https://www.shore.co.il/git/ansible-pre-commit
- repo: https://github.com/adarnimrod/ansible-pre-commit.git
sha: 0fadd691465b97db8992cfc66650f630e433324b
hooks:
- id: ansible-syntax-check
......
---
language: python
python: "2.7"
dist: trusty
sudo: false
group: beta
services: [docker]
cache:
- pip
- directories:
- $HOME/.pre-commit
install:
- pip install -r tests/requirements.txt | cat
- ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles
- molecule dependency
script:
- pre-commit run --all-files
- molecule test --driver docker
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
email: false
NTP client
##########
An Ansible role for installing and configuring an NTP client.
.. image:: https://travis-ci.org/adarnimrod/ntp-client.svg?branch=master
:target: https://travis-ci.org/adarnimrod/ntp-client
Provision an NTP client.
Requirements
------------
See :code:`meta/main.yml`, :code:`tests/requirements.yml` and assertions at
the top of :code:`tasks/main.yml`.
See :code:`meta/main.yml` and assertions at the top of :code:`tasks/main.yml`.
Role Variables
--------------
......@@ -27,21 +29,22 @@ See :code:`tests/playbook.yml`.
Testing
-------
Testing requires Virtualbox and Vagrant and Python 2.7. Install the Python
dependencies, add pre-commit hooks by running:
Testing requires Python 2.7 and either Docker or Vagrant and Virtualbox.
Install the Python dependencies, dependent roles and roles required for
testing:
.. code:: shell
pip install -r tests/requirements.txt
pre-commit install
ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles
molecule dependency
To run the full test suite:
.. code:: shell
ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles
molecule test --platform all
pre-commit run --all-files
molecule test --platform all
License
-------
......
......@@ -5,6 +5,7 @@ retry_files_enabled = False
roles_path = .molecule/roles:.molecule/../roles:../:../../
command_warnings = True
deprecation_warnings = True
callback_whitelist = profile_tasks
[ssh_connection]
pipelining = True
---
# defaults file for ansible-role-ntp-client
# defaults file for ntp-client
---
# handlers file for ansible-role-ntp-client
# handlers file for ntp-client
- name: Restart ntpd
service:
......
galaxy_info:
author: Nimrod Adar
description: An Ansible role for configuring NTP time syncronization.
description: Provision an NTP client
company: Shore technologies
license: MIT
min_ansible_version: 2.0
......
......@@ -4,6 +4,9 @@ ansible:
playbook: tests/playbook.yml
diff: True
config_file: ../ansible.cfg
dependency:
name: galaxy
requirements_file: tests/requirements.yml
vagrant:
......@@ -13,12 +16,10 @@ vagrant:
platforms:
- name: openbsd
box: kaorimatz/openbsd-6.0-amd64
- name: debian
- name: jessie
box: debian/jessie64
- name: ubuntu
box: ubuntu/xenial64
instances:
- name: ansible-role-ntp-client
- name: ntp-client
options:
append_platform_to_hostname: yes
raw_config_args:
......@@ -26,3 +27,17 @@ vagrant:
- 'vbguest.auto_update = false'
- 'landrush.enabled = false'
- 'landrush_ip.override = false'
docker:
containers:
- name: ntp-client-jessie
image: debian
image_version: jessie
command: /sbin/init
privileged: True
volume_mounts:
- /sys/fs/cgroup:/sys/fs/cgroup
- /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
environment:
DEBIAN_FRONTEND: noninteractive
container: docker
---
# tasks file for ansible-role-ntp-client
# tasks file for ntp-client
- name: Assertions
assert:
that: ansible_os_family in [ 'Debian', 'OpenBSD' ]
......
---
- hosts: ansible-role-ntp-client-openbsd
- hosts: ntp-client-openbsd
gather_facts: false
roles: [openbsd_bootstrap]
roles: [adarnimrod.openbsd-bootstrap]
- hosts: ansible-role-ntp-client-ubuntu
- hosts: ntp-client-xenial
gather_facts: false
roles: [debian_bootstrap]
roles: [adarnimrod.debian-bootstrap]
- hosts: all
roles: [ansible-role-ntp-client]
strategy: free
roles:
- role: ntp-client
ansible==2.2.0.0
testinfra==1.4.3
molecule==1.13.0
ansible-lint==3.4.4
pre-commit==0.9.3
testinfra==1.4.5
molecule==1.16.1
ansible-lint==3.4.8
pre-commit==0.9.4
piprot==0.9.7
python-vagrant==0.5.14
docker-py==1.10.6
---
- src: https://www.shore.co.il/git/ansible-role-openbsd-bootstrap
scm: git
name: openbsd_bootstrap
- src: https://www.shore.co.il/git/ansible-role-debian-bootstrap
scm: git
name: debian_bootstrap
- src: adarnimrod.openbsd-bootstrap
- src: adarnimrod.debian-bootstrap
from testinfra.utils.ansible_runner import AnsibleRunner
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def test_example(Command):
assert Command('uname').rc == 0
def test_root(Command, Sudo):
with Sudo():
assert Command('whoami').stdout == 'root'
assert Command('whoami').stdout.strip() == 'root'
def test_ntp(Service, Ansible):
if Ansible('setup')['ansible_facts']['ansible_service_mgr'] == 'systemd':
service = Service('systemd-timesyncd')
elif Ansible('setup')['ansible_facts']['ansible_os_family'] == 'Debian':
service = Service('openntpd')
elif Ansible('setup')['ansible_facts']['ansible_os_family'] == 'OpenBSD':
service = Service('ntpd')
assert service.is_running
from testinfra.utils.ansible_runner import AnsibleRunner
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def test_ntp(Service):
assert Service('systemd-timesyncd').is_running or Service(
'ntpd').is_running
try:
assert service.is_enabled
Service('systemd-timesyncd').is_enabled or Service('ntpd').is_enabled
except NotImplementedError:
pass
---
# vars file for ansible-role-ntp-client
# vars file for ntp-client
ntpd_conf:
OpenBSD: /etc/ntpd.conf
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment