Skip to content
Snippets Groups Projects
Commit 19a99f70 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 bf50f707 41ad1da6
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
- id: check-merge-conflict - id: check-merge-conflict
- id: flake8 - id: flake8
- id: check-symlinks - id: check-symlinks
- repo: https://www.shore.co.il/git/ansible-pre-commit - repo: https://github.com/adarnimrod/ansible-pre-commit.git
sha: 0fadd691465b97db8992cfc66650f630e433324b sha: 0fadd691465b97db8992cfc66650f630e433324b
hooks: hooks:
- id: ansible-syntax-check - 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
NSD NSD
### ###
Provision NSD authorative DNS server. By default the role has minimal .. image:: https://travis-ci.org/adarnimrod/nsd.svg?branch=master
:target: https://travis-ci.org/adarnimrod/nsd
Provision an NSD authorative DNS server. By default the role has minimal
configuration. You can add your own by overriding the default configuration. You can add your own by overriding the default
:code:`nsd_config` dictionary with your own for configuration under the :code:`nsd_config` dictionary with your own for configuration under the
:code:`server` block in :code:`nsd.conf`. For other blocks that can declared :code:`server` block in :code:`nsd.conf`. For other blocks that can declared
...@@ -14,8 +17,7 @@ playbook). ...@@ -14,8 +17,7 @@ playbook).
Requirements Requirements
------------ ------------
See :code:`meta/main.yml`, :code:`tests/requirements.yml` and assertions at See :code:`meta/main.yml` and assertions at the top of :code:`tasks/main.yml`.
the top of :code:`tasks/main.yml`.
Role Variables Role Variables
-------------- --------------
...@@ -35,21 +37,22 @@ See :code:`tests/playbook.yml`. ...@@ -35,21 +37,22 @@ See :code:`tests/playbook.yml`.
Testing Testing
------- -------
Testing requires Virtualbox and Vagrant and Python 2.7. Install the Python Testing requires Python 2.7 and either Docker or Vagrant and Virtualbox.
dependencies, add pre-commit hooks by running: Install the Python dependencies, dependent roles and roles required for
testing:
.. code:: shell .. code:: shell
pip install -r tests/requirements.txt 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: To run the full test suite:
.. code:: shell .. 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 pre-commit run --all-files
molecule test --platform all
License License
------- -------
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
library = library library = library
host_key_checking = False host_key_checking = False
retry_files_enabled = False retry_files_enabled = False
roles_path = .molecule/roles:.molecule/../roles:../:../../ roles_path = ../:.molecule/roles:.molecule/../roles:../../
command_warnings = True command_warnings = True
deprecation_warnings = True deprecation_warnings = True
callback_whitelist = profile_tasks
[ssh_connection] [ssh_connection]
pipelining = True pipelining = True
--- ---
# defaults file for ansible-role-nsd # defaults file for nsd
nsd_mail_alias: root # Where to send mail for the NSD user. nsd_mail_alias: root # Where to send mail for the NSD user.
nsd_config: # key/value configuration under the server block, for more nsd_config: # key/value configuration under the server block, for more
......
--- ---
# handlers file for ansible-role-nsd # handlers file for nsd
- name: Restart NSD - name: Restart NSD
service: service:
......
galaxy_info: galaxy_info:
author: Nimrod Adar author: Nimrod Adar
description: Install and configure NSD description: Provision an NSD authorative DNS server
company: Shore technologies company: Shore technologies
license: MIT license: MIT
min_ansible_version: 2.0 min_ansible_version: 2.0
...@@ -12,5 +12,8 @@ galaxy_info: ...@@ -12,5 +12,8 @@ galaxy_info:
- name: Debian - name: Debian
versions: versions:
- jessie - jessie
- name: Ubuntu
versions:
- xenial
galaxy_tags: [ networking, web ] galaxy_tags: [ networking, web ]
dependencies: [] dependencies: []
...@@ -4,6 +4,9 @@ ansible: ...@@ -4,6 +4,9 @@ ansible:
playbook: tests/playbook.yml playbook: tests/playbook.yml
diff: True diff: True
config_file: ../ansible.cfg config_file: ../ansible.cfg
dependency:
name: galaxy
requirements_file: tests/requirements.yml requirements_file: tests/requirements.yml
vagrant: vagrant:
...@@ -13,10 +16,10 @@ vagrant: ...@@ -13,10 +16,10 @@ vagrant:
platforms: platforms:
- name: openbsd - name: openbsd
box: kaorimatz/openbsd-6.0-amd64 box: kaorimatz/openbsd-6.0-amd64
- name: debian - name: jessie
box: debian/jessie64 box: debian/jessie64
instances: instances:
- name: ansible-role-nsd - name: nsd
options: options:
append_platform_to_hostname: yes append_platform_to_hostname: yes
raw_config_args: raw_config_args:
...@@ -24,3 +27,17 @@ vagrant: ...@@ -24,3 +27,17 @@ vagrant:
- 'vbguest.auto_update = false' - 'vbguest.auto_update = false'
- 'landrush.enabled = false' - 'landrush.enabled = false'
- 'landrush_ip.override = false' - 'landrush_ip.override = false'
docker:
containers:
- name: nsd-xenial
image: ubuntu
image_version: xenial
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-nsd # tasks file for nsd
- name: Assertions - name: Assertions
assert: assert:
that: that:
- ansible_os_family in [ 'Debian', 'OpenBSD' ] - ansible_os_family in nsd_user
- ansible_os_family in aliases_file
- nsd_config is iterable
- name: APT install NSD - name: APT install NSD
when: ansible_pkg_mgr == 'apt' when: ansible_pkg_mgr == 'apt'
......
--- ---
- hosts: ansible-role-nsd-openbsd - hosts: nsd-openbsd
gather_facts: false gather_facts: false
roles: [openbsd_bootstrap] roles: [openbsd-bootstrap]
- hosts: nsd-xenial
gather_facts: false
roles: [debian-bootstrap]
- hosts: all - hosts: all
roles: [ ansible-role-nsd ] strategy: free
roles:
- role: nsd
post_tasks: post_tasks:
- name: Copy test zone - name: Copy test zone
with_items: with_items:
......
ansible==2.2.0.0 ansible==2.2.0.0
testinfra==1.4.3 testinfra==1.4.5
molecule==1.13.0 molecule==1.17.0
ansible-lint==3.4.4 ansible-lint==3.4.8
pre-commit==0.9.3 pre-commit==0.9.4
piprot==0.9.7 piprot==0.9.7
python-vagrant==0.5.14
docker-py==1.10.6
netaddr==0.7.18
passlib==1.7.0
bcrypt==3.1.2
--- ---
- src: https://www.shore.co.il/git/ansible-role-openbsd-bootstrap - src: adarnimrod.openbsd-bootstrap
scm: git name: openbsd-bootstrap
name: openbsd_bootstrap - src: adarnimrod.debian-bootstrap
- src: https://www.shore.co.il/git/ansible-role-debian-bootstrap name: debian-bootstrap
scm: git
name: debian_bootstrap
from testinfra.utils.ansible_runner import AnsibleRunner
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def test_example(Command): def test_example(Command):
assert Command('uname').rc == 0 assert Command('uname').rc == 0
def test_root(Command, Sudo): def test_root(Command, Sudo):
with Sudo(): with Sudo():
assert Command('whoami').stdout == 'root' assert Command('whoami').stdout.strip() == 'root'
from testinfra.utils.ansible_runner import AnsibleRunner
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def test_nsd(Command, Sudo): def test_nsd(Command, Sudo):
with Sudo(): with Sudo():
assert Command('nsd -v').rc == 0 assert Command('nsd -v').rc == 0
......
--- ---
# vars file for ansible-role-nsd # vars file for nsd
nsd_conf: '{{ "/var/nsd/etc/nsd.conf" if ansible_os_family == "OpenBSD" else "/etc/nsd/nsd.conf" }}' nsd_conf: '{{ "/var/nsd/etc/nsd.conf" if ansible_os_family == "OpenBSD" else "/etc/nsd/nsd.conf" }}'
nsd_conf_d: '{{ nsd_conf }}.d' nsd_conf_d: '{{ nsd_conf }}.d'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment