Skip to content

Commit

Permalink
fixup! tests: Dip our toes into using Ansible
Browse files Browse the repository at this point in the history
  • Loading branch information
cgwalters committed Mar 9, 2018
1 parent 4b2d68f commit 4a3019e
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions tests/common/libvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,19 @@
vm_setup() {

export VM=${VM:-vmcheck}
local sshopts="-o User=root \
-o ControlMaster=auto \
-o ControlPath=/var/tmp/ssh-$VM-$(date +%s%N).sock \
-o ControlPersist=yes"
SSHOPTS="-o User=root -o ControlMaster=auto \
-o ControlPath=/var/tmp/ssh-$VM-$(date +%s%N).sock \
-o ControlPersist=yes"

# If we're provided with an ssh-config, make sure we tell
# ssh to pick it up.
if [ -f "${topsrcdir}/ssh-config" ]; then
sshopts="$sshopts -F ${topsrcdir}/ssh-config"
SSHOPTS="${SSHOPTS} -F ${topsrcdir}/ssh-config"
fi
export SSHOPTS

export SSH="ssh $sshopts $VM"
export SCP="scp $sshopts"

local HOSTS="${HOSTS:-${VM}}"
inventory=${topsrcdir}/ansible-inventory.ini
(echo '[vmcheck]' &&
for host in "${HOSTS}"; do
echo "${host}"
done &&
echo '[vmcheck:vars]' &&
echo 'ansible_ssh_common_args: "'${sshopts}'"'
) > ${inventory}.new && mv ${inventory}{.new,}
export SSH="ssh ${SSHOPTS} $VM"
export SCP="scp ${SSHOPTS}"
}

vm_ansible_inline() {
Expand All @@ -54,7 +44,7 @@ vm_ansible_inline() {
tasks:
EOF
sed -e 's,^, ,' >> ${playbook}
ansible-playbook -i ${topsrcdir}/ansible-inventory.yml ${playbook}
ansible-playbook -i ${VM}, --ssh-common-args "${SSHOPTS}" ${playbook}
rm -f ${playbook}
}

Expand Down

0 comments on commit 4a3019e

Please sign in to comment.