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

move validate to roles - trap 'failed' to supply better feedback to end user. #2961

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions check-vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

INVENTORY=ansible_hosts
PLAYBOOK=validate-vars.yml
LOG=check-vars.log
CWD=`pwd`
if [ ! -f $PLAYBOOK ]; then
echo "Exiting: IIAB Playbook not found."
echo "Please run this in /opt/iiab/iiab (top level of the git repo)."
exit 1
fi

export ANSIBLE_LOG_PATH="$CWD"/"$LOG"

if [ -f $LOG ]; then
rm $LOG
fi

Start=`date`
ansible-playbook -i $INVENTORY $PLAYBOOK --connection=local
End=`date`
echo "check-vars run end: $End"
echo "check-vars run start: $Start"

if [ $(grep failed $LOG | wc -l) -gt 1 ]; then
echo "local_vars.yml contains errors, please check the entries listed below"
grep failed $LOG
else
echo "local_vars.yml seems fine, continuing"
fi
2 changes: 1 addition & 1 deletion iiab-configure
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ cp ./scripts/local_facts.fact /etc/ansible/facts.d/local_facts.fact
if grep -q sugar $IIAB_STATE_FILE && ! grep -q mongodb $IIAB_STATE_FILE; then
echo "mongodb_installed: True" >> $IIAB_STATE_FILE
fi

./check-vars
export ANSIBLE_LOG_PATH="$CWD/iiab-configure.log"
ansible -m setup -i $INVENTORY localhost ${ARGS} --connection=local | grep python
ansible-playbook -i $INVENTORY $PLAYBOOK --connection=local
1 change: 1 addition & 0 deletions iiab-from-console.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- /etc/iiab/iiab_state.yml

roles:
- { role: validate }
- { role: 0-init }
- { role: 4-server-options }
- { role: 5-xo-services }
Expand Down
3 changes: 3 additions & 0 deletions iiab-install
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ if [ ! -f $IIAB_STATE_FILE ]; then

EOF
fi
echo -e "\nChecking local_vars.yml for errors\n"
./check-vars

echo -e "\nTRY TO RERUN './iiab-install' IF IT FAILS DUE TO CONNECTIVITY ISSUES ETC!\n"

echo -e "Running local Ansible playbooks...\n...Stage 0 will now run\n...followed by Stages $(($STAGE + 1))-9\n...and then the Network Role.\n"
Expand Down
1 change: 1 addition & 0 deletions install-support.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- /etc/iiab/local_vars.yml

roles:
- { role: validate }
- { role: 0-init }
- { role: sshd }
- { role: openvpn }
File renamed without changes.
11 changes: 11 additions & 0 deletions validate-vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- hosts: all
become: yes

vars_files:
- vars/default_vars.yml
- vars/{{ ansible_local.local_facts.os_ver }}.yml
- /etc/iiab/local_vars.yml
- /etc/iiab/iiab_state.yml

roles:
- { role: validate }