Skip to content

Commit

Permalink
Adds test of juliendufresne.influxdb role against ubuntu 16.04 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliendufresne committed Jul 8, 2016
1 parent 62544eb commit 7b9f6a8
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/playbooks/roles/
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Test Ansible Roles
==================

Tests an ansible roles against ubuntu 16.04

Requirements
------------

* Vagrant version 1.8.4+ (needed to install latest ansible version)
* Virtualbox - [Website](https://www.virtualbox.org/) - [download page](https://www.virtualbox.org/wiki/Downloads)

Since ansible will be installed in the vagrant box, you don't need it on your host.
38 changes: 38 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Vagrant.require_version ">= 1.8.4"
ENV["LC_ALL"] = "en_US.UTF-8"

Vagrant.configure(2) do |config|
config.vm.box = "geerlingguy/ubuntu1604"
config.vm.box_check_update = false
config.vm.hostname = "ansible-role-ubuntu-1604"

config.vm.network "private_network", type: "dhcp"

config.vm.provider :virtualbox do |vb|
vb.name = "ansible_role_ubuntu_1604"
vb.memory = 512
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--ioapic", "on"]
end

config.vm.define :ansible_role_ubuntu_1604 do |ansible_role_ubuntu_1604|
end

config.vm.provision "ansible", type: "ansible_local" do |ansible|
ansible.galaxy_role_file = "requirements.yml"
ansible.install = true
ansible.install_mode = :pip
ansible.inventory_path = "inventory"
ansible.playbook = "playbooks/influxdb.yml"
ansible.limit = "all"
end

config.vm.synced_folder ".", "/vagrant", :nfs => true, :mount_options => ["rw", "tcp", "nolock", "noacl", "async"]

if Vagrant.has_plugin?("vagrant-hostmanager")
config.hostmanager.enabled = false
end
if Vagrant.has_plugin?("vagrant-vbguest")
config.vbguest.auto_update = false
end
end
1 change: 1 addition & 0 deletions inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testservers ansible_connection=local
27 changes: 27 additions & 0 deletions playbooks/influxdb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- hosts: testservers
vars:
influxdb_databases:
- _internal
- my_db
influxdb_users:
- type: admin
name: admin
password: admin
- type: user
name: grafana
password: grafana
rights:
- "my_db:READ"
- type: user
name: telegraf
password: telegraf
rights:
- "my_db:WRITE"
- type: user
name: john
password: john
rights:
- "my_db:ALL"
roles:
- juliendufresne.influxdb
2 changes: 2 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
- src: juliendufresne.influxdb
28 changes: 28 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

handle_result() {
local args=$1

if [ ${args} -ne 0 ]
then
printf "\e[1;31m%s\e[0m\n" "fail"

return 1;
fi
printf "\e[1;32m%s\e[0m\n" "pass"

return 0;
}

printf "* booting machine: "
vagrant up --no-provision &>/dev/null
handle_result $?

OUTPUT_FILE=$(mktemp)
printf "* Fresh provisioning test: "
vagrant provision &>"${OUTPUT_FILE}"
grep -q 'unreachable=0.*failed=0' "${OUTPUT_FILE}"
handle_result $?
rm "${OUTPUT_FILE}"

vagrant destroy -f >/dev/null

0 comments on commit 7b9f6a8

Please sign in to comment.