Commit e17c2165 authored by Visay Keo's avatar Visay Keo

[IMP] Group ansible params into variable

This helps making line length shorter and prepare for integration of
more optional tags to pass to ansible.
parent e772d84a
......@@ -4,12 +4,12 @@ CHANGELOG
3.0-dev
---------
-
- [IMP] Group ansible params into variable
3.0.0
-----
- [IMP] Add more useful params with nicer message
- [IMP] Add more useful params with nicer message
- [TASK] Update example in README
- [IMP] Add flow command resource:publish
......
......@@ -141,6 +141,18 @@ fi
# Use Development context if Flow Context is not set
FLOW_CONTEXT=${FLOW_CONTEXT:=Development}
# Prepare all parameters for ansible
ANSIBLE_PARAMS="-i ${PACKAGE_DIR}/ansible/hosts.ini ${PACKAGE_DIR}/ansible/playbook.yml"
if [ -n "${VERBOSE_LEVEL}" ]; then
ANSIBLE_PARAMS="${ANSIBLE_PARAMS} $VERBOSE_LEVEL"
fi
if [ -n "${ANSIBLE_TAGS}" ]; then
ANSIBLE_PARAMS="${ANSIBLE_PARAMS} ${ANSIBLE_TAGS}"
fi
# Prepare all parameters for ansible extra vars
ANSIBLE_EXTRA_VARS="stage=${STAGE} ssh_user=${REMOTE_USER} local_path=${ROOT_DIR} remote_path=${REMOTE_PATH} local_flow_context=${FLOW_CONTEXT}"
echo -e ${GREEN}"ENVIRONMENT SUMMARY:"${NC}
echo "====================="
echo -e "FROM: ${GREEN}${REMOTE_USER}${NC}"
......@@ -157,7 +169,7 @@ if [[ -n "${DRY_RUN}" ]]; then
echo
echo -e ${BROWN}"The following command should be executed"${NC}
echo "----------------------------------------"
echo "ansible-playbook -i ${PACKAGE_DIR}/ansible/hosts.ini ${PACKAGE_DIR}/ansible/playbook.yml ${VERBOSE_LEVEL} ${ANSIBLE_TAGS} --extra-vars \"stage=${STAGE} ssh_user=${REMOTE_USER} local_path=${ROOT_DIR} remote_path=${REMOTE_PATH} local_flow_context=${FLOW_CONTEXT}\""
echo "ansible-playbook ${ANSIBLE_PARAMS} --extra-vars \"${ANSIBLE_EXTRA_VARS}\""
echo
exit 0
fi
......@@ -176,9 +188,7 @@ echo -e ${GREEN}"#############################"
echo "### STARTING CONTENT SYNC ###"
echo -e "#############################"${NC}
ansible-playbook -i ${PACKAGE_DIR}/ansible/hosts.ini ${PACKAGE_DIR}/ansible/playbook.yml ${VERBOSE_LEVEL} ${ANSIBLE_TAGS} \
--extra-vars "stage=${STAGE} ssh_user=${REMOTE_USER} local_path=${ROOT_DIR} remote_path=${REMOTE_PATH} local_flow_context=${FLOW_CONTEXT}" \
|| ERROR="1"
ansible-playbook ${ANSIBLE_PARAMS} --extra-vars "${ANSIBLE_EXTRA_VARS}" || ERROR="1"
if [[ -n "${ERROR}" ]]; then
echo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment