Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds --enable-vbguest option #42

Merged
merged 1 commit into from
Jul 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Vagrantfile.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Vagrant.require_version ">= 1.8.4"
ENV["LC_ALL"] = "en_US.UTF-8"

if ${is_vbguest_enabled} and not Vagrant.has_plugin? "vagrant-vbguest"
if system "sudo vagrant plugin install vagrant-vbguest"
exec "vagrant #{ARGV.join(' ')}"
else
abort "Installation of vagrant-vbguest plugin has failed. Aborting."
end
end

Vagrant.configure(2) do |config|
config.vm.box = "${vagrant_box}"
config.vm.box_check_update = false
Expand All @@ -26,6 +34,6 @@ Vagrant.configure(2) do |config|
config.hostmanager.enabled = false
end
if Vagrant.has_plugin?("vagrant-vbguest")
config.vbguest.auto_update = false
config.vbguest.auto_update = ${is_vbguest_enabled}
end
end
29 changes: 16 additions & 13 deletions config/default.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
| Ansible role | Vagrant box |
| ----------------------- | ------------------- |
| juliendufresne.influxdb | bento/debian-7.9 |
| juliendufresne.influxdb | bento/debian-7.10 |
| juliendufresne.influxdb | bento/debian-8.1 |
| juliendufresne.influxdb | bento/debian-8.2 |
| juliendufresne.influxdb | bento/debian-8.3 |
| juliendufresne.influxdb | bento/debian-8.4 |
| juliendufresne.influxdb | bento/ubuntu-12.04 |
| juliendufresne.influxdb | bento/ubuntu-14.04 |
| juliendufresne.influxdb | bento/ubuntu-15.04 |
| juliendufresne.influxdb | bento/ubuntu-15.10 |
| juliendufresne.influxdb | bento/ubuntu-16.04 |
| Ansible role | Vagrant box | enable-vbguest |
| ----------------------- | ------------------- | -------------- |
| juliendufresne.influxdb | bento/debian-7.9 | no |
| juliendufresne.influxdb | bento/debian-7.10 | no |
| juliendufresne.influxdb | bento/debian-8.1 | no |
| juliendufresne.influxdb | bento/debian-8.2 | no |
| juliendufresne.influxdb | bento/debian-8.3 | no |
| juliendufresne.influxdb | bento/debian-8.4 | no |
| juliendufresne.influxdb | bento/ubuntu-12.04 | no |
| juliendufresne.influxdb | bento/ubuntu-14.04 | no |
| juliendufresne.influxdb | bento/ubuntu-15.04 | no |
| juliendufresne.influxdb | bento/ubuntu-15.10 | no |
| juliendufresne.influxdb | bento/ubuntu-16.04 | no |
| juliendufresne.influxdb | bento/centos-6.7 | yes |
| juliendufresne.influxdb | geerlingguy/centos6 | yes |
| juliendufresne.influxdb | geerlingguy/centos7 | no |
5 changes: 4 additions & 1 deletion src/_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ clean_previous_vagrant_box() {
}

create_vagrantfile() {
local vagrant_box="$1"
local is_vbguest_enabled="$2"
local line=

while read -r line
Expand Down Expand Up @@ -58,6 +60,7 @@ run() {
local vagrant_box="$2"
local repository_directory="$3"
local is_verbose=$4
local is_vbguest_enabled="$5"
local testing_directory="$(mktemp -d)"

printf "# Testing ansible role \033[1;34m%s\033[0m in vagrant box \033[1;34m%s\033[0m\n" "${ansible_role}" "${vagrant_box}"
Expand All @@ -82,7 +85,7 @@ run() {

cd "${testing_directory}"

create_vagrantfile
create_vagrantfile "${vagrant_box}" "${is_vbguest_enabled}"
local report_file=$(ensure_report_file_exists "${repository_directory}" "${ansible_role}")

boot_vagrant_box ${is_verbose}
Expand Down
1 change: 1 addition & 0 deletions src/_usage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ usage() {
e.g: '--config-file default' may be resolved with <repository_root>/config/default.md
-h, --help show this help.
-v, --verbose increase verbosity.
--enable-vbguest enable the vagrant-vbguest plugin and install it if needed.
--vagrant-box VAGRANT_BOX use specified vagrant box instead of default one. This option may be specified multiple times.
"
}
13 changes: 11 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ IS_VERBOSE=false
VAGRANT_BOXES=
ANSIBLE_ROLES=
CONFIG_FILE=
ENABLE_VBGUEST="false"
while [[ $# -ge 1 ]]
do
case "$1" in
Expand All @@ -34,6 +35,9 @@ do
[ $? -ne 0 ] && { printf "$CONFIG_FILE"; exit 1; }
shift
;;
--enable-vbguest)
ENABLE_VBGUEST="true"
;;
-h|--help)
usage
exit 0
Expand Down Expand Up @@ -71,7 +75,7 @@ then
do
for VAGRANT_BOX in ${VAGRANT_BOXES}
do
run "${ANSIBLE_ROLE}" "${VAGRANT_BOX}" "${REPOSITORY_DIRECTORY}" ${IS_VERBOSE}
run "${ANSIBLE_ROLE}" "${VAGRANT_BOX}" "${REPOSITORY_DIRECTORY}" ${IS_VERBOSE} ${ENABLE_VBGUEST}
done
done
exit 0;
Expand All @@ -84,6 +88,11 @@ do
line=$(echo "${line}" | sed 's/^\s*|//' | sed 's/|\s*$//')
CURRENT_ANSIBLE_ROLE=$(echo "${line}" | cut -d '|' -f 1 | sed 's/^\s*//' | sed 's/\s*$//')
CURRENT_VAGRANT_BOX=$(echo "${line}" | cut -d '|' -f 2 | sed 's/^\s*//' | sed 's/\s*$//')
ENABLE_VBGUEST="false"
if [ "yes" == "$(echo "${line}" | cut -d '|' -f 3 | sed 's/^\s*//' | sed 's/\s*$//')" ]
then
ENABLE_VBGUEST="true"
fi

if [ -n "${ANSIBLE_ROLES}" ]
then
Expand Down Expand Up @@ -113,5 +122,5 @@ do

${FOUND} || continue

run "${CURRENT_ANSIBLE_ROLE}" "${CURRENT_VAGRANT_BOX}" "${REPOSITORY_DIRECTORY}" ${IS_VERBOSE}
run "${CURRENT_ANSIBLE_ROLE}" "${CURRENT_VAGRANT_BOX}" "${REPOSITORY_DIRECTORY}" ${IS_VERBOSE} ${ENABLE_VBGUEST}
done