Skip to content

Instantly share code, notes, and snippets.

@gdvalle
Created June 17, 2014 20:28
Show Gist options
  • Save gdvalle/80c838757e2b48b88334 to your computer and use it in GitHub Desktop.
Save gdvalle/80c838757e2b48b88334 to your computer and use it in GitHub Desktop.
Script to reproduce slow Ansible file copy
#!/usr/bin/env bash
#
# Breaking commit: https://github.com/ansible/ansible/commit/460794d697ee8fa4a959e76442bd9a2e777d6251
# Last working commit: https://github.com/ansible/ansible/commit/237b9cb05669f22099cc6c47de44c5f6321869c3
#
# It appears that the kv_regex.match() hangs ansible during larger file copies.
#
FSIZE=60000
HOST="localhost"
ANSIBLE_ARGS="-i '$HOST,' -v -D test.yml"
TESTFILE_SRC=/tmp/testfile_src
TESTFILE_DEST=/tmp/testfile_dest
echo "System info:"
uname -a
lsb_release -a
ssh -V
ansible --version
ansible-playbook --version
python --version
echo
rm -f $TESTFILE_SRC
rm -f $TESTFILE_DEST
dd if=/dev/urandom bs=1 count=$FSIZE | base64 > $TESTFILE_SRC
echo "Generated $TESTFILE_SRC"
cat > test.yml <<EOF
- hosts: $HOST
gather_facts: no
tasks:
- copy: src=$TESTFILE_SRC dest=$TESTFILE_DEST
EOF
echo "First run"
time ansible-playbook $ANSIBLE_ARGS
echo "Second run - no changes"
time ansible-playbook $ANSIBLE_ARGS
echo a >> $TESTFILE_SRC
echo "Third run - $TESTFILE_SRC changed: one character appended"
time ansible-playbook $ANSIBLE_ARGS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment