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,7 +4,7 @@ CHANGELOG ...@@ -4,7 +4,7 @@ CHANGELOG
3.0-dev 3.0-dev
--------- ---------
- - [IMP] Group ansible params into variable
3.0.0 3.0.0
----- -----
......
...@@ -141,6 +141,18 @@ fi ...@@ -141,6 +141,18 @@ fi
# Use Development context if Flow Context is not set # Use Development context if Flow Context is not set
FLOW_CONTEXT=${FLOW_CONTEXT:=Development} 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 -e ${GREEN}"ENVIRONMENT SUMMARY:"${NC}
echo "=====================" echo "====================="
echo -e "FROM: ${GREEN}${REMOTE_USER}${NC}" echo -e "FROM: ${GREEN}${REMOTE_USER}${NC}"
...@@ -157,7 +169,7 @@ if [[ -n "${DRY_RUN}" ]]; then ...@@ -157,7 +169,7 @@ if [[ -n "${DRY_RUN}" ]]; then
echo echo
echo -e ${BROWN}"The following command should be executed"${NC} echo -e ${BROWN}"The following command should be executed"${NC}
echo "----------------------------------------" 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 echo
exit 0 exit 0
fi fi
...@@ -176,9 +188,7 @@ echo -e ${GREEN}"#############################" ...@@ -176,9 +188,7 @@ echo -e ${GREEN}"#############################"
echo "### STARTING CONTENT SYNC ###" echo "### STARTING CONTENT SYNC ###"
echo -e "#############################"${NC} echo -e "#############################"${NC}
ansible-playbook -i ${PACKAGE_DIR}/ansible/hosts.ini ${PACKAGE_DIR}/ansible/playbook.yml ${VERBOSE_LEVEL} ${ANSIBLE_TAGS} \ ansible-playbook ${ANSIBLE_PARAMS} --extra-vars "${ANSIBLE_EXTRA_VARS}" || ERROR="1"
--extra-vars "stage=${STAGE} ssh_user=${REMOTE_USER} local_path=${ROOT_DIR} remote_path=${REMOTE_PATH} local_flow_context=${FLOW_CONTEXT}" \
|| ERROR="1"
if [[ -n "${ERROR}" ]]; then if [[ -n "${ERROR}" ]]; then
echo 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