Skip to content

Commit

Permalink
Refactored code and implemented updated Travis testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlesmithjr committed Jan 11, 2019
1 parent 7256df3 commit 941bd85
Show file tree
Hide file tree
Showing 27 changed files with 552 additions and 325 deletions.
75 changes: 58 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,68 @@ language: python
python: "2.7"

# Use the new container infrastructure
sudo: false
sudo: required

# Install ansible
addons:
apt:
packages:
- python-pip
services:
- docker

install:
# Install ansible
- pip install ansible
env:
- distribution: centos
init: /usr/lib/systemd/systemd
version: 7
# - distribution: fedora
# init: /usr/lib/systemd/systemd
# version: 29
# - distribution: fedora
# init: /usr/lib/systemd/systemd
# version: 28
# - distribution: fedora
# init: /usr/lib/systemd/systemd
# version: 27
# - distribution: fedora
# init: /usr/lib/systemd/systemd
# version: 26
# - distribution: fedora
# init: /usr/lib/systemd/systemd
# version: 25
# - distribution: fedora
# init: /usr/lib/systemd/systemd
# version: 24
- distribution: ubuntu
init: /lib/systemd/systemd
version: bionic
- distribution: ubuntu
init: /lib/systemd/systemd
version: xenial
# - distribution: ubuntu
# init: /sbin/init
# version: trusty
# - distribution: debian
# init: /lib/systemd/systemd
# version: stretch
# - distribution: debian
# init: /lib/systemd/systemd
# version: jessie

# Check ansible version
- ansible --version

# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg
before_install:
- "sudo pip install yamllint"
- yamllint -c .yamllint.yml .
- "sudo docker pull ${distribution}:${version}"
- "sudo docker build --no-cache --rm --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests"

script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
- container_id=$(mktemp)
- role_name="ansible-kea-dhcp"
- 'sudo docker run --detach --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --volume="${PWD}":/etc/ansible/roles/${role_name}:ro ${distribution}-${version}:ansible ${init} > "${container_id}"'
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-lint -c /.ansible-lint /etc/ansible/roles/${role_name}/tests/test.yml'
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/${role_name}/tests/test.yml --syntax-check'
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/${role_name}/tests/test.yml'
- >
sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/${role_name}/tests/test.yml
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
- 'sudo docker rm -f "$(cat ${container_id})"'

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
webhooks: https://galaxy.ansible.com/api/v1/notifications/
58 changes: 58 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
extends: default

rules:
braces:
# Defaults
# min-spaces-inside: 0
# max-spaces-inside: 0

# Keeping 0 min-spaces to not error on empty collection definitions
min-spaces-inside: 0
# Allowing one space inside braces to improve code readability
max-spaces-inside: 1

brackets:
# Defaults
# min-spaces-inside: 0
# max-spaces-inside: 0

# Keeping 0 min-spaces to not error on empty collection definitions
min-spaces-inside: 0
# Allowing one space inside braces to improve code readability
max-spaces-inside: 1

colons:
# Defaults
# max-spaces-before: 0
# max-spaces-after: 1

max-spaces-before: 0
# Allowing more than one space for code readability
max-spaces-after: -1

comments:
# Defaults
# level: warning
# require-starting-space: true
# min-spaces-from-content: 2

# Disabling to allow for code comment blocks and #!/usr/bin/ansible-playbook
require-starting-space: false

indentation:
# Defaults
# spaces: consistent
# indent-sequences: true
# check-multi-line-strings: false

# Requiring 2 space indentation
spaces: 2
# Requiring consistent indentation within a file, either indented or not
indent-sequences: consistent

# Disabling due to copious amounts of long lines in the code which would
# require a code style change to resolve
line-length: disable

truthy: disable
52 changes: 28 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
Role Name
=========
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

An [Ansible] role to install/configure [Kea DHCP]
**Table of Contents** _generated with [DocToc](https://github.com/thlorenz/doctoc)_

Requirements
------------
- [ansible-kea-dhcp](#ansible-kea-dhcp)
- [Requirements](#requirements)
- [Role Variables](#role-variables)
- [Dependencies](#dependencies)
- [Example Playbook](#example-playbook)
- [License](#license)
- [Author Information](#author-information)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# ansible-kea-dhcp

An [Ansible](https://www.ansible.com) role to install/configure [Kea DHCP](http://kea.isc.org/)

## Requirements

None

Role Variables
--------------
## Role Variables

[Role Defaults](defaults/main.yml)
[Defaults](defaults/main.yml)

Dependencies
------------
## Dependencies

None

Example Playbook
----------------
## Example Playbook

[Example Playbook](./playbook.yml)

License
-------
## License

BSD
MIT

Author Information
------------------
## Author Information

Larry Smith Jr.
- [@mrlesmithjr]
- http://everythingshouldbevirtual.com
- mrlesmithjr [at] gmail.com

[@mrlesmithjr]: <https://www.twitter.com/mrlesmithjr>

[Ansible]: <https://www.ansible.com>
[Kea DHCP]: <http://kea.isc.org/>
- [@mrlesmithjr](https://www.twitter.com/mrlesmithjr)
- [EverythingShouldBeVirtual](http://everythingshouldbevirtual.com)
- [mrlesmithjr@gmail.com](mailto:mrlesmithjr@gmail.com)
90 changes: 45 additions & 45 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ kea_dhcp_config: false

# Defines Kea DHCP packages to install for Debian/Ubuntu
kea_dhcp_debian_packages:
- 'kea-dhcp-ddns-server'
- 'kea-dhcp4-server'
# - 'kea-dhcp6-server'
- 'socat'
- kea-dhcp-ddns-server
- kea-dhcp4-server
# - kea-dhcp6-server
- socat

# Defines Kea DHCP Debian/Ubuntu services should be enabled
kea_dhcp_debian_services:
- name: 'kea-dhcp-ddns-server'
- name: kea-dhcp-ddns-server
enabled: true
- name: 'kea-dhcp4-server'
- name: kea-dhcp4-server
enabled: true
- name: 'kea-dhcp6-server'
- name: kea-dhcp6-server
enabled: false

# The DHCP DDNS configuration below is formatted appropriately to be converted
# directly to JSON using the kea-dhcp-ddns.conf.j2 Jinja2 template.
kea_dhcp_ddns_config:
DhcpDdns:
ip-address: '127.0.0.1'
ip-address: 127.0.0.1
port: 53001
tsig-keys: []
forward-ddns: {}
reverse-ddns: {}
Logging:
loggers:
- name: 'kea-dhcp-ddns'
- name: kea-dhcp-ddns
output_options:
- output: '/var/log/kea-ddns.log'
severity: 'INFO'
- output: /var/log/kea-ddns.log
severity: INFO
debuglevel: 0

# The DHCP configuration below is formatted appropriately to be converted
Expand All @@ -50,13 +50,13 @@ kea_dhcp_dhcp4_config:
# Add names of interfaces to listen on
interfaces-config:
interfaces:
- '*'
# - 'eth0'
# - 'eth1'
dhcp-socket-type: 'raw'
- "*"
# - eth0
# - eth1
dhcp-socket-type: raw
# Use Memfile lease database backend to store leases in a CSV file.
lease-database:
type: 'memfile'
type: memfile
persist: true
lfc-interval: 0
# Setup reclamation of the expired leases and leases affinity.
Expand All @@ -71,56 +71,56 @@ kea_dhcp_dhcp4_config:
valid-lifetime: 4000
# Below an example of the simple subnet declarations
subnet4: []
# - subnet: '192.0.2.0/24'
# next-server: '192.0.2.234'
# - subnet: 192.0.2.0/24
# next-server: 192.0.2.234
# pools:
# - pool: '192.0.2.1 - 192.0.2.200'
# - pool: "192.0.2.1 - 192.0.2.200"
# reservations:
# - hw-address: '1a:1b:1c:1d:1e:1f'
# ip-address: '192.0.2.202'
# - subnet: '192.0.3.0/24'
# - hw-address: "1a:1b:1c:1d:1e:1f"
# ip-address: 192.0.2.202
# - subnet: 192.0.3.0/24
# pools:
# - pool: '192.0.3.1 - 192.0.3.200'
# - pool: "192.0.3.1 - 192.0.3.200"
# relay:
# ip-address: '10.0.0.1'
# - subnet: '192.0.4.0/24'
# ip-address: 10.0.0.1
# - subnet: 192.0.4.0/24
# pools:
# - pool: '192.0.4.1 - 192.0.4.200'
# - pool: "192.0.4.1 - 192.0.4.200"
# option-data:
# - name: 'domain-name-servers'
# data: '8.8.8.8, 8.8.4.4'
# - name: 'domain-name'
# data: '{{ kea_dhcp_pri_domain_name }}'
# - name: 'tftp-server-name'
# data: 'tftp.{{ kea_dhcp_pri_domain_name }}'
# - name: 'boot-file-name'
# data: 'pxelinux.0'
# - name: domain-name-servers
# data: "8.8.8.8, 8.8.4.4"
# - name: domain-name
# data: "{{ kea_dhcp_pri_domain_name }}"
# - name: tftp-server-name
# data: "tftp.{{ kea_dhcp_pri_domain_name }}"
# - name: boot-file-name
# data: pxelinux.0
dhcp-ddns: []
# enable-updates: false
# qualifying-suffix: '{{ kea_dhcp_pri_domain_name }}'
# next-server: '0.0.0.0'
# qualifying-suffix: "{{ kea_dhcp_pri_domain_name }}"
# next-server: 0.0.0.0
# control-socket:
# socket-type: 'unix'
# socket-name: '/var/run/kea.socket'
# socket-type: unix
# socket-name: /var/run/kea.socket
# Logging configuration starts here. It tells Kea servers to store
# all log messages (on severity INFO or more) in a file.
# debuglevel variable is used on DEBUG level only.
Logging:
loggers:
- name: 'kea-dhcp4'
- name: kea-dhcp4
output_options:
- output: '/var/log/kea-dhcp4.log'
severity: 'INFO'
- output: /var/log/kea-dhcp4.log
severity: INFO
debuglevel: 0

# Defines Kea DHCP RedHat services should be enabled
kea_dhcp_redhat_services:
- name: 'kea-dhcp-ddns'
- name: kea-dhcp-ddns
enabled: true
- name: 'kea-dhcp4'
- name: kea-dhcp4
enabled: true
- name: 'kea-dhcp6'
- name: kea-dhcp6
enabled: false

# Defines primary domain name of environment
kea_dhcp_pri_domain_name: 'vagrant.local'
kea_dhcp_pri_domain_name: vagrant.local
Loading

0 comments on commit 941bd85

Please sign in to comment.