Skip to content

Commit

Permalink
Creates a config file (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliendufresne authored Jul 9, 2016
1 parent 55883cb commit 7dac7c6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
6 changes: 6 additions & 0 deletions config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
| Ansible role | Vagrant box |
| ----------------------- | ------------------ |
| juliendufresne.grafana | bento/ubuntu-14.04 |
| juliendufresne.grafana | bento/ubuntu-16.04 |
| juliendufresne.influxdb | bento/ubuntu-14.04 |
| juliendufresne.influxdb | bento/ubuntu-16.04 |
58 changes: 46 additions & 12 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,54 @@ do
shift
done

if [ -z "${ANSIBLE_ROLES}" ]
if [ -n "${ANSIBLE_ROLES}" ] && [ -n "${VAGRANT_BOXES}" ]
then
ANSIBLE_ROLES="${DEFAULT_ANSIBLE_ROLE}"
fi

if [ -z "${VAGRANT_BOXES}" ]
then
VAGRANT_BOXES="${DEFAULT_VAGRANT_BOX}"
for ANSIBLE_ROLE in ${ANSIBLE_ROLES}
do
for VAGRANT_BOX in ${VAGRANT_BOXES}
do
run "${ANSIBLE_ROLE}" "${VAGRANT_BOX}" "${REPOSITORY_DIRECTORY}" ${IS_VERBOSE}
done
done
exit 0;
fi

for ANSIBLE_ROLE in ${ANSIBLE_ROLES}
# Use the configuration file
tail -n+3 config.md | while read line
do
for VAGRANT_BOX in ${VAGRANT_BOXES}
do
run "${ANSIBLE_ROLE}" "${VAGRANT_BOX}" "${REPOSITORY_DIRECTORY}" ${IS_VERBOSE}
done
FOUND=true
# Remove trailing pipe (because we can use them or not)
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*$//')

if [ -n "${ANSIBLE_ROLES}" ]
then
FOUND=false
for ANSIBLE_ROLE in ${ANSIBLE_ROLES}
do
if [ "${CURRENT_ANSIBLE_ROLE}" == "${ANSIBLE_ROLE}" ]
then
FOUND=true
break
fi
done
fi

if [ -n "${VAGRANT_BOXES}" ]
then
FOUND=false
for VAGRANT_BOX in ${VAGRANT_BOXES}
do
if [ "${CURRENT_VAGRANT_BOX}" == "${VAGRANT_BOX}" ]
then
FOUND=true
break
fi
done
fi

${FOUND} || continue

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

0 comments on commit 7dac7c6

Please sign in to comment.