summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Geerling <geerlingguy@mac.com>2014-05-09 09:44:06 -0500
committerJeff Geerling <geerlingguy@mac.com>2014-05-09 09:44:06 -0500
commit19dfa1942bb7452c4006055b69b5f0ac031f0ae7 (patch)
treee46ead317838444b02a561b8245d7f3a375fb10b
parentfd9f99697d3f06f636d13a34206202eb26c5ca17 (diff)
downloadntp-19dfa1942bb7452c4006055b69b5f0ac031f0ae7.tar.gz
ntp-19dfa1942bb7452c4006055b69b5f0ac031f0ae7.tar.bz2
ntp-19dfa1942bb7452c4006055b69b5f0ac031f0ae7.tar.xz
ntp-19dfa1942bb7452c4006055b69b5f0ac031f0ae7.zip
Add Travis integration for real.
-rw-r--r--.travis.yml30
-rw-r--r--defaults/main.yml3
-rw-r--r--tasks/main.yml9
-rw-r--r--tests/inventory1
-rw-r--r--tests/test.yml5
5 files changed, 47 insertions, 1 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..3eee176
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,30 @@
+---
+language: python
+python: "2.7"
+
+env:
+ - SITE=test.yml
+
+before_install:
+ - sudo apt-get update -qq
+
+install:
+ # Install Ansible.
+ - pip install ansible==1.5.0
+
+ # Add ansible.cfg to pick up roles path.
+ - "printf '[defaults]\nroles_path = ../' > ansible.cfg"
+
+script:
+ # Check the role/playbook's syntax.
+ - "ansible-playbook -i tests/inventory tests/$SITE --syntax-check"
+
+ # Run the role/playbook with ansible-playbook.
+ - "ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo"
+
+ # Run the role/playbook again, checking to make sure it's idempotent.
+ - >
+ ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo
+ | grep -q 'changed=0.*failed=0'
+ && (echo 'Idempotence test: pass' && exit 0)
+ || (echo 'Idempotence test: fail' && exit 1)
diff --git a/defaults/main.yml b/defaults/main.yml
new file mode 100644
index 0000000..f0fc211
--- /dev/null
+++ b/defaults/main.yml
@@ -0,0 +1,3 @@
+---
+ntp_enabled: true
+ntp_timezone: America/Chicago
diff --git a/tasks/main.yml b/tasks/main.yml
index 144c455..8ee5d87 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -13,9 +13,16 @@
apt: name=ntp state=installed
when: ansible_os_family == 'Debian'
-- name: Ensure NTP is running.
+- name: Ensure NTP is running and enabled at system start.
service: >
name={{ ntp_daemon }}
state=started
enabled=yes
when: ntp_enabled
+
+- name: Ensure NTP is stopped and disabled at system start.
+ service: >
+ name={{ ntp_daemon }}
+ state=stopped
+ enabled=no
+ when: !ntp_enabled
diff --git a/tests/inventory b/tests/inventory
new file mode 100644
index 0000000..2fbb50c
--- /dev/null
+++ b/tests/inventory
@@ -0,0 +1 @@
+localhost
diff --git a/tests/test.yml b/tests/test.yml
new file mode 100644
index 0000000..9093df7
--- /dev/null
+++ b/tests/test.yml
@@ -0,0 +1,5 @@
+---
+- hosts: localhost
+ remote_user: root
+ roles:
+ - ansible-role-ntp