X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fbash%2Ffunction%2Fansible.sh;h=431acc7c5db67e0a0d21715c240adf0053eb6f72;hb=b0d6fc976be09da5d5c0d57b58a87d8b0b286ca4;hp=a9314b4cd2b69d8b60061edc37377865d9250b08;hpb=2045a26e54b45a5fd7635102ceda1662d84a2047;p=csit.git diff --git a/resources/libraries/bash/function/ansible.sh b/resources/libraries/bash/function/ansible.sh index a9314b4cd2..431acc7c5d 100644 --- a/resources/libraries/bash/function/ansible.sh +++ b/resources/libraries/bash/function/ansible.sh @@ -17,6 +17,7 @@ set -exuo pipefail function ansible_hosts () { + # Run ansible playbook on hosts in working topology file. Ansible scope is # determined by tags passed as parameters to this function. # @@ -27,8 +28,7 @@ function ansible_hosts () { set -exuo pipefail if ! installed sshpass; then - sudo apt-get update -y || die "apt-get update failed!" - sudo apt-get install -y sshpass || die "Install sshpass failed!" + die "Please install sshpass!" fi if ! installed ansible-playbook; then @@ -40,7 +40,7 @@ function ansible_hosts () { die "Failed to read hosts from working topology!" } pushd "${TOOLS_DIR}"/testbed-setup/ansible || die "Pushd failed!" - ansible-playbook \ + ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook \ --vault-password-file=vault_pass \ --extra-vars '@vault.yml' \ --inventory inventories/lf_inventory/hosts site.yaml \ @@ -51,15 +51,15 @@ function ansible_hosts () { function installed () { - set -exuo pipefail - # Check if the given utility is installed. Fail if not installed. # # Arguments: # - ${1} - Utility to check. - # Returns: + # Returns (implicitly): # - 0 - If command is installed. # - 1 - If command is not installed. + set -exuo pipefail + command -v "${1}" -} \ No newline at end of file +}