Skip to content

Instantly share code, notes, and snippets.

@eduardobaitello
Last active January 25, 2018 15:02
Show Gist options
  • Save eduardobaitello/5adee904ec9cf004b1384ee0f15e56fa to your computer and use it in GitHub Desktop.
Save eduardobaitello/5adee904ec9cf004b1384ee0f15e56fa to your computer and use it in GitHub Desktop.
Comparison of Ansible copy module (recursive) with scp
# FILE STRUCTURE USED FOR TESTS
Note: php-site is a clone from https://github.com/phalcon/php-sites
eduardo@Notebook:test_ansible_copy$ tree
.
├── hosts.ini
└── playbooks
├── playbook.yml
└── roles
└── recursive-copy
├── files
│   └── php-site
│   ├── app
│   │   ├── cache
│   │   │   └── dummy
│   │   ├── config
│   │   │   ├── config.php
│   │   │   └── routes.php
│   │   ├── controllers
│   │   │   ├── AboutController.php
│   │   │   ├── ControllerBase.php
│   │   │   ├── CopyrightController.php
│   │   │   ├── DocumentationController.php
│   │   │   ├── DownloadsController.php
│   │   │   ├── HelpController.php
│   │   │   ├── IndexController.php
│   │   │   ├── LinksController.php
│   │   │   ├── MailingController.php
│   │   │   └── NewsController.php
│   │   ├── library
│   │   │   └── UIElements.php
│   │   ├── messages
│   │   │   ├── en
│   │   │   │   ├── downloads.php
│   │   │   │   ├── index.php
│   │   │   │   └── main.php
│   │   │   └── es
│   │   │   ├── downloads.php
│   │   │   ├── index.php
│   │   │   └── main.php
│   │   ├── models
│   │   │   ├── Categories.php
│   │   │   ├── NewsCategories.php
│   │   │   └── News.php
│   │   └── views
│   │   ├── about
│   │   │   └── index.phtml
│   │   ├── copyright
│   │   │   └── index.phtml
│   │   ├── documentation
│   │   │   └── index.phtml
│   │   ├── downloads
│   │   │   └── index.phtml
│   │   ├── help
│   │   │   └── index.phtml
│   │   ├── index
│   │   │   └── index.phtml
│   │   ├── index.phtml
│   │   ├── layouts
│   │   │   ├── documentation.phtml
│   │   │   ├── downloads.phtml
│   │   │   ├── index.phtml
│   │   │   ├── links.phtml
│   │   │   ├── mailing.phtml
│   │   │   ├── main.phtml
│   │   │   └── news.phtml
│   │   ├── links
│   │   │   └── index.phtml
│   │   ├── mailing
│   │   │   └── index.phtml
│   │   └── news
│   │   ├── show.phtml
│   │   ├── showYear.phtml
│   │   └── tagged.phtml
│   ├── index.html
│   ├── public
│   │   ├── bootstrap
│   │   │   ├── css
│   │   │   │   ├── bootstrap.css
│   │   │   │   ├── bootstrap.min.css
│   │   │   │   ├── bootstrap-responsive.css
│   │   │   │   └── bootstrap-responsive.min.css
│   │   │   ├── img
│   │   │   │   ├── glyphicons-halflings.png
│   │   │   │   └── glyphicons-halflings-white.png
│   │   │   └── js
│   │   │   ├── bootstrap.js
│   │   │   └── bootstrap.min.js
│   │   ├── css
│   │   │   └── style.css
│   │   ├── favicon.ico
│   │   ├── img
│   │   │   ├── icon_date.gif
│   │   │   ├── icon_tags.gif
│   │   │   ├── index.html
│   │   │   ├── logo.png
│   │   │   └── php.gif
│   │   ├── index.php
│   │   └── js
│   │   ├── jquery.min.js
│   │   ├── prettify
│   │   │   ├── lang-apollo.js
│   │   │   ├── lang-clj.js
│   │   │   ├── lang-css.js
│   │   │   ├── lang-go.js
│   │   │   ├── lang-hs.js
│   │   │   ├── lang-lisp.js
│   │   │   ├── lang-lua.js
│   │   │   ├── lang-ml.js
│   │   │   ├── lang-n.js
│   │   │   ├── lang-proto.js
│   │   │   ├── lang-scala.js
│   │   │   ├── lang-sql.js
│   │   │   ├── lang-tex.js
│   │   │   ├── lang-vb.js
│   │   │   ├── lang-vhdl.js
│   │   │   ├── lang-wiki.js
│   │   │   ├── lang-xq.js
│   │   │   ├── lang-yaml.js
│   │   │   ├── prettify.css
│   │   │   └── prettify.js
│   │   └── utils.js
│   ├── README.md
│   ├── schemas
│   │   └── php_site.sql
│   └── scripts
│   ├── update-categories.php
│   ├── update-events-html.php
│   ├── update-news-html.php
│   └── update-news.php
└── tasks
└── main.yml
37 directories, 90 files
# SIZE OF php-site DIRECTORY
eduardo@Notebook:test_ansible_copy$ du -hs playbooks/roles/recursive-copy/files/php-site
1,8M playbooks/roles/recursive-copy/files/php-site
# HOSTS, PLAYBOOK AND ROLE FILES USED
eduardo@Notebook:test_ansible_copy$ cat hosts.ini
[local]
localhost
[test]
192.168.2.101
[test:vars]
ansible_ssh_pass = somepass
eduardo@Notebook:test_ansible_copy$ cat playbooks/playbook.yml
- name: Ansible slow copy
hosts: test
remote_user: test
gather_facts: false
roles:
- recursive-copy
eduardo@Notebook:test_ansible_copy$ cat playbooks/roles/recursive-copy/tasks/main.yml
- name: Recursive copy of php-site dir
copy:
src: php-site
dest: /tmp/
# PLAYBOOK EXECUTION (1m22s)
eduardo@Notebook:test_ansible_copy$ export ANSIBLE_HOST_KEY_CHECKING='False'
eduardo@Notebook:test_ansible_copy$ export ANSIBLE_SCP_IF_SSH='True'
eduardo@Notebook:test_ansible_copy$ time ansible-playbook -i hosts.ini playbooks/playbook.yml
PLAY [Ansible slow copy] ********************************************************************************************************************************************
TASK [recursive-copy : Recursive copy of php-site dir] **************************************************************************************************************
changed: [192.168.2.101]
PLAY RECAP **********************************************************************************************************************************************************
192.168.2.101 : ok=1 changed=1 unreachable=0 failed=0
real 1m22,483s
user 0m12,023s
sys 0m9,963s
# SCP RECURSIVE COPY (2 seconds...Including the password typing...)
eduardo@Notebook:test_ansible_copy$ time scp -q -r playbooks/roles/recursive-copy/files/php-site test@192.168.2.101:/tmp
test@192.168.2.101's password:
real 0m1,995s
user 0m0,043s
sys 0m0,038s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment