Last active
May 28, 2022 13:48
-
-
Save odyssey4me/5817160155cc9ff7bd46aaef87fc2c07 to your computer and use it in GitHub Desktop.
Working with rsync and chown, with rsync and with Ansible's synchronize module. Playbook 1 only works for Ansible<2.3 and Playbook 2 works for Ansible 2.3+. The subtle difference was discovered in https://github.com/ansible/ansible/issues/23575 - for Ansible 2.3+ DO NOT QUOTE the rsync_opts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@foo:~# rm -rf test; mkdir test; touch test/test{1,2,3}; chown ubuntu test/test1; chown aptly test/test2; ls -al test/ | |
total 8 | |
drwxr-xr-x 2 root root 4096 Nov 30 10:47 . | |
drwx------ 11 root root 4096 Nov 30 10:47 .. | |
-rw-r--r-- 1 ubuntu root 0 Nov 30 10:47 test1 | |
-rw-r--r-- 1 aptly root 0 Nov 30 10:47 test2 | |
-rw-r--r-- 1 root root 0 Nov 30 10:47 test3 | |
root@foo:~# rsync -avz --chown 'nginx:www-data' -e "ssh -i ~/.ssh/my.key" --verbose test root@bar:/tmp/ | |
opening connection using: ssh -i "~/.ssh/my.key" -l root bar rsync --server -vvlogDtprze.iLsfx "--usermap=*:nginx" "--groupmap=*:www-data" . /tmp/ (13 args) | |
sending incremental file list | |
delta-transmission enabled | |
test/ | |
test/test1 | |
test/test2 | |
test/test3 | |
total: matches=0 hash_hits=0 false_alarms=0 data=0 | |
sent 232 bytes received 108 bytes 680.00 bytes/sec | |
total size is 0 speedup is 0.00 | |
root@foo:~# ssh -i ~/.ssh/my.key root@bar 'ls -al /tmp/test/' | |
total 44 | |
drwxr-xr-x 2 nginx www-data 4096 Nov 30 2017 . | |
drwxrwxrwt 10 root root 36864 Nov 30 10:42 .. | |
-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test1 | |
-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2 | |
-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3 | |
-rw-r--r-- 1 nginx www-data 0 Nov 30 10:12 test4 | |
-rw-r--r-- 1 nginx www-data 0 Nov 30 10:31 test5 | |
-rw-r--r-- 1 nginx www-data 0 Nov 30 10:31 test6 | |
root@foo:~# rm -rf test | |
root@foo:~# rsync -avz --chown 'aptly:www-data' -e "ssh -i ~/.ssh/my.key" --verbose root@bar:/tmp/test ~/ | |
opening connection using: ssh -i "~/.ssh/my.key" -l root bar rsync --server --sender -vvlogDtprze.iLsfx . /tmp/test (12 args) | |
receiving incremental file list | |
delta-transmission enabled | |
test/ | |
test/test1 | |
test/test2 | |
test/test3 | |
test/test4 | |
test/test5 | |
test/test6 | |
total: matches=0 hash_hits=0 false_alarms=0 data=0 | |
sent 142 bytes received 446 bytes 1,176.00 bytes/sec | |
total size is 0 speedup is 0.00 | |
root@foo:~# ls -al test/ | |
total 8 | |
drwxr-xr-x 2 aptly www-data 4096 Nov 30 10:47 . | |
drwx------ 11 root root 4096 Nov 30 10:50 .. | |
-rw-r--r-- 1 aptly www-data 0 Nov 30 10:47 test1 | |
-rw-r--r-- 1 aptly www-data 0 Nov 30 10:47 test2 | |
-rw-r--r-- 1 aptly www-data 0 Nov 30 10:47 test3 | |
-rw-r--r-- 1 aptly www-data 0 Nov 30 10:12 test4 | |
-rw-r--r-- 1 aptly www-data 0 Nov 30 10:31 test5 | |
-rw-r--r-- 1 aptly www-data 0 Nov 30 10:31 test6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ansible-2.1) root@foo:~# ansible --version | |
ansible 2.1.6.0 | |
config file = | |
configured module search path = Default w/o overrides | |
(ansible-2.1) root@foo:~# rsync --version | |
rsync version 3.1.1 protocol version 31 | |
Copyright (C) 1996-2014 by Andrew Tridgell, Wayne Davison, and others. | |
Web site: http://rsync.samba.org/ | |
Capabilities: | |
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints, | |
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, | |
append, ACLs, xattrs, iconv, symtimes, prealloc | |
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you | |
are welcome to redistribute it under certain conditions. See the GNU | |
General Public Licence for details. | |
(ansible-2.1) root@foo:~# ansible-playbook -i /tmp/inventory 1-test-playbook.yml | |
PLAY [localhost] *************************************************************** | |
TASK [setup] ******************************************************************* | |
ok: [localhost] | |
TASK [command] ***************************************************************** | |
changed: [localhost] | |
[WARNING]: Consider using file module with state=absent rather than running rm | |
TASK [debug] ******************************************************************* | |
ok: [localhost] => { | |
"_output": { | |
"changed": true, | |
"cmd": "rm -rf ~/test\n mkdir ~/test\n touch test/test{1,2,3}\n chown ubuntu test/test1\n chown aptly test/test2\n ls -al test/", | |
"delta": "0:00:00.011701", | |
"end": "2017-11-30 11:38:06.503200", | |
"rc": 0, | |
"start": "2017-11-30 11:38:06.491499", | |
"stderr": "", | |
"stdout": "total 8\ndrwxr-xr-x 2 root root 4096 Nov 30 11:38 .\ndrwx------ 14 root root 4096 Nov 30 11:38 ..\n-rw-r--r-- 1 ubuntu root 0 Nov 30 11:38 test1\n-rw-r--r-- 1 aptly root 0 Nov 30 11:38 test2\n-rw-r--r-- 1 root root 0 Nov 30 11:38 test3", | |
"stdout_lines": [ | |
"total 8", | |
"drwxr-xr-x 2 root root 4096 Nov 30 11:38 .", | |
"drwx------ 14 root root 4096 Nov 30 11:38 ..", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 11:38 test1", | |
"-rw-r--r-- 1 aptly root 0 Nov 30 11:38 test2", | |
"-rw-r--r-- 1 root root 0 Nov 30 11:38 test3" | |
], | |
"warnings": [ | |
"Consider using file module with state=absent rather than running rm" | |
] | |
} | |
} | |
PLAY [mirrors] ***************************************************************** | |
TASK [setup] ******************************************************************* | |
ok: [bar] | |
TASK [command] ***************************************************************** | |
changed: [bar] | |
[WARNING]: Consider using synchronize module rather than running rsync | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_output": { | |
"changed": true, | |
"cmd": "rsync --version", | |
"delta": "0:00:00.003326", | |
"end": "2017-11-30 11:30:52.276882", | |
"rc": 0, | |
"start": "2017-11-30 11:30:52.273556", | |
"stderr": "", | |
"stdout": "rsync version 3.1.0 protocol version 31\nCopyright (C) 1996-2013 by Andrew Tridgell, Wayne Davison, and others.\nWeb site: http://rsync.samba.org/\nCapabilities:\n 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,\n socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,\n append, ACLs, xattrs, iconv, symtimes, prealloc\n\nrsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you\nare welcome to redistribute it under certain conditions. See the GNU\nGeneral Public Licence for details.", | |
"stdout_lines": [ | |
"rsync version 3.1.0 protocol version 31", | |
"Copyright (C) 1996-2013 by Andrew Tridgell, Wayne Davison, and others.", | |
"Web site: http://rsync.samba.org/", | |
"Capabilities:", | |
" 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,", | |
" socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,", | |
" append, ACLs, xattrs, iconv, symtimes, prealloc", | |
"", | |
"rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you", | |
"are welcome to redistribute it under certain conditions. See the GNU", | |
"General Public Licence for details." | |
], | |
"warnings": [ | |
"Consider using synchronize module rather than running rsync" | |
] | |
} | |
} | |
TASK [file] ******************************************************************** | |
changed: [bar] | |
TASK [synchronize] ************************************************************* | |
changed: [bar] | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_synchronize": { | |
"changed": true, | |
"cmd": "/usr/bin/rsync --delay-updates -F --compress --delete-after --archive --rsh 'ssh -i /root/.ssh/my.key -S none -o StrictHostKeyChecking=no' --verbose --chown='nginx:www-data' --out-format='<<CHANGED>>%i %n%L' \"/root/test\" \"root@bar:/tmp/\"", | |
"msg": "building file list ... done\ncd+++++++++ test/\n<f+++++++++ test/test1\n<f+++++++++ test/test2\n<f+++++++++ test/test3\n\nsent 270 bytes received 79 bytes 698.00 bytes/sec\ntotal size is 0 speedup is 0.00\n", | |
"rc": 0, | |
"stdout_lines": [ | |
"building file list ... done", | |
"cd+++++++++ test/", | |
"<f+++++++++ test/test1", | |
"<f+++++++++ test/test2", | |
"<f+++++++++ test/test3", | |
"sent 270 bytes received 79 bytes 698.00 bytes/sec", | |
"total size is 0 speedup is 0.00" | |
] | |
} | |
} | |
TASK [command] ***************************************************************** | |
changed: [bar] | |
[WARNING]: Consider using file module with state=touch rather than running touch | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_output": { | |
"changed": true, | |
"cmd": "touch /tmp/test/test{4,5,6}\n chown ubuntu /tmp/test/test{1,4}\n ls -al /tmp/test/", | |
"delta": "0:00:00.006868", | |
"end": "2017-11-30 11:30:53.476477", | |
"rc": 0, | |
"start": "2017-11-30 11:30:53.469609", | |
"stderr": "", | |
"stdout": "total 44\ndrwxr-xr-x 2 nginx www-data 4096 Nov 30 11:30 .\ndrwxrwxrwt 11 root root 36864 Nov 30 11:30 ..\n-rw-r--r-- 1 ubuntu www-data 0 Nov 30 2017 test1\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3\n-rw-r--r-- 1 ubuntu root 0 Nov 30 11:30 test4\n-rw-r--r-- 1 root root 0 Nov 30 11:30 test5\n-rw-r--r-- 1 root root 0 Nov 30 11:30 test6", | |
"stdout_lines": [ | |
"total 44", | |
"drwxr-xr-x 2 nginx www-data 4096 Nov 30 11:30 .", | |
"drwxrwxrwt 11 root root 36864 Nov 30 11:30 ..", | |
"-rw-r--r-- 1 ubuntu www-data 0 Nov 30 2017 test1", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 11:30 test4", | |
"-rw-r--r-- 1 root root 0 Nov 30 11:30 test5", | |
"-rw-r--r-- 1 root root 0 Nov 30 11:30 test6" | |
], | |
"warnings": [ | |
"Consider using file module with state=touch rather than running touch" | |
] | |
} | |
} | |
TASK [synchronize] ************************************************************* | |
changed: [bar] | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_synchronize": { | |
"changed": true, | |
"cmd": "/usr/bin/rsync --delay-updates -F --compress --delete-after --archive --rsh 'ssh -i /root/.ssh/my.key -S none -o StrictHostKeyChecking=no' --verbose --chown='aptly:www-data' --out-format='<<CHANGED>>%i %n%L' \"root@bar:/tmp/test/\" \"/root/test\"", | |
"msg": "receiving file list ... done\n.d..t.og... ./\n.f....og... test1\n.f.....g... test2\n.f....og... test3\n>f+++++++++ test4\n>f+++++++++ test5\n>f+++++++++ test6\n\nsent 130 bytes received 294 bytes 848.00 bytes/sec\ntotal size is 0 speedup is 0.00\n", | |
"rc": 0, | |
"stdout_lines": [ | |
"receiving file list ... done", | |
".d..t.og... ./", | |
".f....og... test1", | |
".f.....g... test2", | |
".f....og... test3", | |
">f+++++++++ test4", | |
">f+++++++++ test5", | |
">f+++++++++ test6", | |
"sent 130 bytes received 294 bytes 848.00 bytes/sec", | |
"total size is 0 speedup is 0.00" | |
] | |
} | |
} | |
PLAY [localhost] *************************************************************** | |
TASK [setup] ******************************************************************* | |
ok: [localhost] | |
TASK [command] ***************************************************************** | |
changed: [localhost] | |
TASK [debug] ******************************************************************* | |
ok: [localhost] => { | |
"_output": { | |
"changed": true, | |
"cmd": "ls -al test/", | |
"delta": "0:00:00.004630", | |
"end": "2017-11-30 11:38:22.379155", | |
"rc": 0, | |
"start": "2017-11-30 11:38:22.374525", | |
"stderr": "", | |
"stdout": "total 8\ndrwxr-xr-x 2 aptly www-data 4096 Nov 30 11:30 .\ndrwx------ 14 root root 4096 Nov 30 11:38 ..\n-rw-r--r-- 1 aptly www-data 0 Nov 30 11:38 test1\n-rw-r--r-- 1 aptly www-data 0 Nov 30 11:38 test2\n-rw-r--r-- 1 aptly www-data 0 Nov 30 11:38 test3\n-rw-r--r-- 1 aptly www-data 0 Nov 30 11:30 test4\n-rw-r--r-- 1 aptly www-data 0 Nov 30 11:30 test5\n-rw-r--r-- 1 aptly www-data 0 Nov 30 11:30 test6", | |
"stdout_lines": [ | |
"total 8", | |
"drwxr-xr-x 2 aptly www-data 4096 Nov 30 11:30 .", | |
"drwx------ 14 root root 4096 Nov 30 11:38 ..", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 11:38 test1", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 11:38 test2", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 11:38 test3", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 11:30 test4", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 11:30 test5", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 11:30 test6" | |
], | |
"warnings": [] | |
} | |
} | |
PLAY RECAP ********************************************************************* | |
bar : ok=10 changed=5 unreachable=0 failed=0 | |
localhost : ok=6 changed=2 unreachable=0 failed=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ansible-2.2) root@foo:~# ansible --version | |
ansible 2.2.3.0 | |
config file = | |
configured module search path = Default w/o overrides | |
(ansible-2.2) root@foo:~# rsync --version | |
rsync version 3.1.1 protocol version 31 | |
Copyright (C) 1996-2014 by Andrew Tridgell, Wayne Davison, and others. | |
Web site: http://rsync.samba.org/ | |
Capabilities: | |
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints, | |
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, | |
append, ACLs, xattrs, iconv, symtimes, prealloc | |
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you | |
are welcome to redistribute it under certain conditions. See the GNU | |
General Public Licence for details. | |
(ansible-2.2) root@foo:~# ansible-playbook -i /tmp/inventory 1-test-playbook.yml | |
PLAY [localhost] *************************************************************** | |
TASK [setup] ******************************************************************* | |
ok: [localhost] | |
TASK [command] ***************************************************************** | |
changed: [localhost] | |
[WARNING]: Consider using file module with state=absent rather than running rm | |
TASK [debug] ******************************************************************* | |
ok: [localhost] => { | |
"_output": { | |
"changed": true, | |
"cmd": "rm -rf ~/test\n mkdir ~/test\n touch test/test{1,2,3}\n chown ubuntu test/test1\n chown aptly test/test2\n ls -al test/", | |
"delta": "0:00:00.010744", | |
"end": "2017-11-30 11:44:27.175609", | |
"rc": 0, | |
"start": "2017-11-30 11:44:27.164865", | |
"stderr": "", | |
"stdout": "total 8\ndrwxr-xr-x 2 root root 4096 Nov 30 11:44 .\ndrwx------ 14 root root 4096 Nov 30 11:44 ..\n-rw-r--r-- 1 ubuntu root 0 Nov 30 11:44 test1\n-rw-r--r-- 1 aptly root 0 Nov 30 11:44 test2\n-rw-r--r-- 1 root root 0 Nov 30 11:44 test3", | |
"stdout_lines": [ | |
"total 8", | |
"drwxr-xr-x 2 root root 4096 Nov 30 11:44 .", | |
"drwx------ 14 root root 4096 Nov 30 11:44 ..", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 11:44 test1", | |
"-rw-r--r-- 1 aptly root 0 Nov 30 11:44 test2", | |
"-rw-r--r-- 1 root root 0 Nov 30 11:44 test3" | |
], | |
"warnings": [ | |
"Consider using file module with state=absent rather than running rm" | |
] | |
} | |
} | |
PLAY [mirrors] ***************************************************************** | |
TASK [setup] ******************************************************************* | |
ok: [bar] | |
TASK [command] ***************************************************************** | |
changed: [bar] | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_output": { | |
"changed": true, | |
"cmd": "rsync --version", | |
"delta": "0:00:00.004121", | |
"end": "2017-11-30 11:37:00.894614", | |
"rc": 0, | |
"start": "2017-11-30 11:37:00.890493", | |
"stderr": "", | |
"stdout": "rsync version 3.1.0 protocol version 31\nCopyright (C) 1996-2013 by Andrew Tridgell, Wayne Davison, and others.\nWeb site: http://rsync.samba.org/\nCapabilities:\n 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,\n socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,\n append, ACLs, xattrs, iconv, symtimes, prealloc\n\nrsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you\nare welcome to redistribute it under certain conditions. See the GNU\nGeneral Public Licence for details.", | |
"stdout_lines": [ | |
"rsync version 3.1.0 protocol version 31", | |
"Copyright (C) 1996-2013 by Andrew Tridgell, Wayne Davison, and others.", | |
"Web site: http://rsync.samba.org/", | |
"Capabilities:", | |
" 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,", | |
" socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,", | |
" append, ACLs, xattrs, iconv, symtimes, prealloc", | |
"", | |
"rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you", | |
"are welcome to redistribute it under certain conditions. See the GNU", | |
"General Public Licence for details." | |
], | |
"warnings": [] | |
} | |
} | |
TASK [file] ******************************************************************** | |
changed: [bar] | |
TASK [synchronize] ************************************************************* | |
changed: [bar] | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_synchronize": { | |
"attempts": 1, | |
"changed": true, | |
"cmd": "/usr/bin/rsync --delay-updates -F --compress --delete-after --archive --rsh 'ssh -i /root/.ssh/my.key -S none -o StrictHostKeyChecking=no' --verbose --chown='nginx:www-data' --out-format='<<CHANGED>>%i %n%L' \"/root/test\" \"root@bar:/tmp/\"", | |
"msg": "building file list ... done\ncd+++++++++ test/\n<f+++++++++ test/test1\n<f+++++++++ test/test2\n<f+++++++++ test/test3\n\nsent 266 bytes received 79 bytes 690.00 bytes/sec\ntotal size is 0 speedup is 0.00\n", | |
"rc": 0, | |
"stdout_lines": [ | |
"building file list ... done", | |
"cd+++++++++ test/", | |
"<f+++++++++ test/test1", | |
"<f+++++++++ test/test2", | |
"<f+++++++++ test/test3", | |
"sent 266 bytes received 79 bytes 690.00 bytes/sec", | |
"total size is 0 speedup is 0.00" | |
] | |
} | |
} | |
TASK [command] ***************************************************************** | |
changed: [bar] | |
[WARNING]: Consider using file module with state=touch rather than running touch | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_output": { | |
"changed": true, | |
"cmd": "touch /tmp/test/test{4,5,6}\n chown ubuntu /tmp/test/test{1,4}\n ls -al /tmp/test/", | |
"delta": "0:00:00.013669", | |
"end": "2017-11-30 11:37:02.159302", | |
"rc": 0, | |
"start": "2017-11-30 11:37:02.145633", | |
"stderr": "", | |
"stdout": "total 44\ndrwxr-xr-x 2 nginx www-data 4096 Nov 30 11:37 .\ndrwxrwxrwt 11 root root 36864 Nov 30 11:37 ..\n-rw-r--r-- 1 ubuntu www-data 0 Nov 30 2017 test1\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3\n-rw-r--r-- 1 ubuntu root 0 Nov 30 11:37 test4\n-rw-r--r-- 1 root root 0 Nov 30 11:37 test5\n-rw-r--r-- 1 root root 0 Nov 30 11:37 test6", | |
"stdout_lines": [ | |
"total 44", | |
"drwxr-xr-x 2 nginx www-data 4096 Nov 30 11:37 .", | |
"drwxrwxrwt 11 root root 36864 Nov 30 11:37 ..", | |
"-rw-r--r-- 1 ubuntu www-data 0 Nov 30 2017 test1", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 11:37 test4", | |
"-rw-r--r-- 1 root root 0 Nov 30 11:37 test5", | |
"-rw-r--r-- 1 root root 0 Nov 30 11:37 test6" | |
], | |
"warnings": [ | |
"Consider using file module with state=touch rather than running touch" | |
] | |
} | |
} | |
TASK [synchronize] ************************************************************* | |
changed: [bar] | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_synchronize": { | |
"attempts": 1, | |
"changed": true, | |
"cmd": "/usr/bin/rsync --delay-updates -F --compress --delete-after --archive --rsh 'ssh -i /root/.ssh/my.key -S none -o StrictHostKeyChecking=no' --verbose --chown='aptly:www-data' --out-format='<<CHANGED>>%i %n%L' \"root@bar:/tmp/test/\" \"/root/test\"", | |
"msg": "receiving file list ... done\n.d..t.og... ./\n.f....og... test1\n.f.....g... test2\n.f....og... test3\n>f+++++++++ test4\n>f+++++++++ test5\n>f+++++++++ test6\n\nsent 130 bytes received 287 bytes 278.00 bytes/sec\ntotal size is 0 speedup is 0.00\n", | |
"rc": 0, | |
"stdout_lines": [ | |
"receiving file list ... done", | |
".d..t.og... ./", | |
".f....og... test1", | |
".f.....g... test2", | |
".f....og... test3", | |
">f+++++++++ test4", | |
">f+++++++++ test5", | |
">f+++++++++ test6", | |
"sent 130 bytes received 287 bytes 278.00 bytes/sec", | |
"total size is 0 speedup is 0.00" | |
] | |
} | |
} | |
PLAY [localhost] *************************************************************** | |
TASK [setup] ******************************************************************* | |
ok: [localhost] | |
TASK [command] ***************************************************************** | |
changed: [localhost] | |
TASK [debug] ******************************************************************* | |
ok: [localhost] => { | |
"_output": { | |
"changed": true, | |
"cmd": "ls -al test/", | |
"delta": "0:00:00.004557", | |
"end": "2017-11-30 11:44:30.709930", | |
"rc": 0, | |
"start": "2017-11-30 11:44:30.705373", | |
"stderr": "", | |
"stdout": "total 8\ndrwxr-xr-x 2 aptly www-data 4096 Nov 30 11:37 .\ndrwx------ 14 root root 4096 Nov 30 11:44 ..\n-rw-r--r-- 1 aptly www-data 0 Nov 30 11:44 test1\n-rw-r--r-- 1 aptly www-data 0 Nov 30 11:44 test2\n-rw-r--r-- 1 aptly www-data 0 Nov 30 11:44 test3\n-rw-r--r-- 1 aptly www-data 0 Nov 30 11:37 test4\n-rw-r--r-- 1 aptly www-data 0 Nov 30 11:37 test5\n-rw-r--r-- 1 aptly www-data 0 Nov 30 11:37 test6", | |
"stdout_lines": [ | |
"total 8", | |
"drwxr-xr-x 2 aptly www-data 4096 Nov 30 11:37 .", | |
"drwx------ 14 root root 4096 Nov 30 11:44 ..", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 11:44 test1", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 11:44 test2", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 11:44 test3", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 11:37 test4", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 11:37 test5", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 11:37 test6" | |
], | |
"warnings": [] | |
} | |
} | |
PLAY RECAP ********************************************************************* | |
bar : ok=10 changed=5 unreachable=0 failed=0 | |
localhost : ok=6 changed=2 unreachable=0 failed=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ansible-2.3) root@foo:~# ansible --version | |
ansible 2.3.2.0 | |
config file = | |
configured module search path = Default w/o overrides | |
python version = 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609] | |
(ansible-2.3) root@foo:~# rsync --version | |
rsync version 3.1.1 protocol version 31 | |
Copyright (C) 1996-2014 by Andrew Tridgell, Wayne Davison, and others. | |
Web site: http://rsync.samba.org/ | |
Capabilities: | |
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints, | |
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, | |
append, ACLs, xattrs, iconv, symtimes, prealloc | |
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you | |
are welcome to redistribute it under certain conditions. See the GNU | |
General Public Licence for details. | |
(ansible-2.3) root@foo:~# ansible-playbook -i /tmp/inventory 1-test-playbook.yml | |
PLAY [localhost] ******************************************************************************************************************************************************************************************************************************************************** | |
TASK [Gathering Facts] ************************************************************************************************************************************************************************************************************************************************** | |
ok: [localhost] | |
TASK [command] ********************************************************************************************************************************************************************************************************************************************************** | |
[WARNING]: Consider using file module with state=absent rather than running rm | |
changed: [localhost] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [localhost] => { | |
"_output": { | |
"changed": true, | |
"cmd": "rm -rf ~/test\n mkdir ~/test\n touch test/test{1,2,3}\n chown ubuntu test/test1\n chown aptly test/test2\n ls -al test/", | |
"delta": "0:00:00.010929", | |
"end": "2017-11-30 11:26:11.085079", | |
"rc": 0, | |
"start": "2017-11-30 11:26:11.074150", | |
"stderr": "", | |
"stderr_lines": [], | |
"stdout": "total 8\ndrwxr-xr-x 2 root root 4096 Nov 30 11:26 .\ndrwx------ 13 root root 4096 Nov 30 11:26 ..\n-rw-r--r-- 1 ubuntu root 0 Nov 30 11:26 test1\n-rw-r--r-- 1 aptly root 0 Nov 30 11:26 test2\n-rw-r--r-- 1 root root 0 Nov 30 11:26 test3", | |
"stdout_lines": [ | |
"total 8", | |
"drwxr-xr-x 2 root root 4096 Nov 30 11:26 .", | |
"drwx------ 13 root root 4096 Nov 30 11:26 ..", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 11:26 test1", | |
"-rw-r--r-- 1 aptly root 0 Nov 30 11:26 test2", | |
"-rw-r--r-- 1 root root 0 Nov 30 11:26 test3" | |
], | |
"warnings": [ | |
"Consider using file module with state=absent rather than running rm" | |
] | |
} | |
} | |
PLAY [mirrors] ********************************************************************************************************************************************************************************************************************************************************** | |
TASK [Gathering Facts] ************************************************************************************************************************************************************************************************************************************************** | |
ok: [bar] | |
TASK [command] ********************************************************************************************************************************************************************************************************************************************************** | |
changed: [bar] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [bar] => { | |
"_output": { | |
"changed": true, | |
"cmd": "rsync --version", | |
"delta": "0:00:00.004818", | |
"end": "2017-11-30 11:28:01.881159", | |
"rc": 0, | |
"start": "2017-11-30 11:28:01.876341", | |
"stderr": "", | |
"stderr_lines": [], | |
"stdout": "rsync version 3.1.0 protocol version 31\nCopyright (C) 1996-2013 by Andrew Tridgell, Wayne Davison, and others.\nWeb site: http://rsync.samba.org/\nCapabilities:\n 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,\n socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,\n append, ACLs, xattrs, iconv, symtimes, prealloc\n\nrsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you\nare welcome to redistribute it under certain conditions. See the GNU\nGeneral Public Licence for details.", | |
"stdout_lines": [ | |
"rsync version 3.1.0 protocol version 31", | |
"Copyright (C) 1996-2013 by Andrew Tridgell, Wayne Davison, and others.", | |
"Web site: http://rsync.samba.org/", | |
"Capabilities:", | |
" 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,", | |
" socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,", | |
" append, ACLs, xattrs, iconv, symtimes, prealloc", | |
"", | |
"rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you", | |
"are welcome to redistribute it under certain conditions. See the GNU", | |
"General Public Licence for details." | |
] | |
} | |
} | |
TASK [file] ************************************************************************************************************************************************************************************************************************************************************* | |
changed: [bar] | |
TASK [synchronize] ****************************************************************************************************************************************************************************************************************************************************** | |
changed: [bar] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [bar] => { | |
"_synchronize": { | |
"attempts": 1, | |
"changed": true, | |
"cmd": "/usr/bin/rsync --delay-updates -F --compress --delete-after --archive --rsh=/usr/bin/ssh -S none -i /root/.ssh/my.key -o StrictHostKeyChecking=no --verbose --chown='nginx:www-data' --out-format=<<CHANGED>>%i %n%L /root/test root@bar:/tmp/", | |
"msg": "building file list ... done\ncd+++++++++ test/\n<f+++++++++ test/test1\n<f+++++++++ test/test2\n<f+++++++++ test/test3\n\nsent 266 bytes received 147 bytes 826.00 bytes/sec\ntotal size is 0 speedup is 0.00\n", | |
"rc": 0, | |
"stdout_lines": [ | |
"building file list ... done", | |
"cd+++++++++ test/", | |
"<f+++++++++ test/test1", | |
"<f+++++++++ test/test2", | |
"<f+++++++++ test/test3", | |
"sent 266 bytes received 147 bytes 826.00 bytes/sec", | |
"total size is 0 speedup is 0.00" | |
] | |
} | |
} | |
TASK [command] ********************************************************************************************************************************************************************************************************************************************************** | |
[WARNING]: Consider using file module with state=touch rather than running touch | |
changed: [bar] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [bar] => { | |
"_output": { | |
"changed": true, | |
"cmd": "touch /tmp/test/test{4,5,6}\n chown ubuntu /tmp/test/test{1,4}\n ls -al /tmp/test/", | |
"delta": "0:00:00.008062", | |
"end": "2017-11-30 11:18:45.440952", | |
"rc": 0, | |
"start": "2017-11-30 11:18:45.432890", | |
"stderr": "", | |
"stderr_lines": [], | |
"stdout": "total 44\ndrwxr-xr-x 2 root root 4096 Nov 30 11:18 .\ndrwxrwxrwt 11 root root 36864 Nov 30 11:18 ..\n-rw-r--r-- 1 ubuntu root 0 Nov 30 2017 test1\n-rw-r--r-- 1 1001 root 0 Nov 30 2017 test2\n-rw-r--r-- 1 root root 0 Nov 30 2017 test3\n-rw-r--r-- 1 ubuntu root 0 Nov 30 11:18 test4\n-rw-r--r-- 1 root root 0 Nov 30 11:18 test5\n-rw-r--r-- 1 root root 0 Nov 30 11:18 test6", | |
"stdout_lines": [ | |
"total 44", | |
"drwxr-xr-x 2 root root 4096 Nov 30 11:18 .", | |
"drwxrwxrwt 11 root root 36864 Nov 30 11:18 ..", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 2017 test1", | |
"-rw-r--r-- 1 1001 root 0 Nov 30 2017 test2", | |
"-rw-r--r-- 1 root root 0 Nov 30 2017 test3", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 11:18 test4", | |
"-rw-r--r-- 1 root root 0 Nov 30 11:18 test5", | |
"-rw-r--r-- 1 root root 0 Nov 30 11:18 test6" | |
], | |
"warnings": [ | |
"Consider using file module with state=touch rather than running touch" | |
] | |
} | |
} | |
TASK [synchronize] ****************************************************************************************************************************************************************************************************************************************************** | |
changed: [bar] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [bar] => { | |
"_synchronize": { | |
"attempts": 1, | |
"changed": true, | |
"cmd": "/usr/bin/rsync --delay-updates -F --compress --delete-after --archive --rsh=/usr/bin/ssh -S none -i /root/.ssh/my.key -o StrictHostKeyChecking=no --verbose --chown='aptly:www-data' --out-format=<<CHANGED>>%i %n%L root@bar:/tmp/test/ /root/test", | |
"msg": "receiving file list ... done\n.d..t...... ./\n>f+++++++++ test4\n>f+++++++++ test5\n>f+++++++++ test6\n\nsent 121 bytes received 262 bytes 766.00 bytes/sec\ntotal size is 0 speedup is 0.00\n", | |
"rc": 0, | |
"stdout_lines": [ | |
"receiving file list ... done", | |
".d..t...... ./", | |
">f+++++++++ test4", | |
">f+++++++++ test5", | |
">f+++++++++ test6", | |
"sent 121 bytes received 262 bytes 766.00 bytes/sec", | |
"total size is 0 speedup is 0.00" | |
] | |
} | |
} | |
PLAY [localhost] ******************************************************************************************************************************************************************************************************************************************************** | |
TASK [Gathering Facts] ************************************************************************************************************************************************************************************************************************************************** | |
ok: [localhost] | |
TASK [command] ********************************************************************************************************************************************************************************************************************************************************** | |
changed: [localhost] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [localhost] => { | |
"_output": { | |
"changed": true, | |
"cmd": "ls -al test/", | |
"delta": "0:00:00.004179", | |
"end": "2017-11-30 11:26:13.906115", | |
"rc": 0, | |
"start": "2017-11-30 11:26:13.901936", | |
"stderr": "", | |
"stderr_lines": [], | |
"stdout": "total 8\ndrwxr-xr-x 2 root root 4096 Nov 30 11:18 .\ndrwx------ 13 root root 4096 Nov 30 11:26 ..\n-rw-r--r-- 1 ubuntu root 0 Nov 30 11:26 test1\n-rw-r--r-- 1 aptly root 0 Nov 30 11:26 test2\n-rw-r--r-- 1 root root 0 Nov 30 11:26 test3\n-rw-r--r-- 1 ubuntu root 0 Nov 30 11:18 test4\n-rw-r--r-- 1 root root 0 Nov 30 11:18 test5\n-rw-r--r-- 1 root root 0 Nov 30 11:18 test6", | |
"stdout_lines": [ | |
"total 8", | |
"drwxr-xr-x 2 root root 4096 Nov 30 11:18 .", | |
"drwx------ 13 root root 4096 Nov 30 11:26 ..", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 11:26 test1", | |
"-rw-r--r-- 1 aptly root 0 Nov 30 11:26 test2", | |
"-rw-r--r-- 1 root root 0 Nov 30 11:26 test3", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 11:18 test4", | |
"-rw-r--r-- 1 root root 0 Nov 30 11:18 test5", | |
"-rw-r--r-- 1 root root 0 Nov 30 11:18 test6" | |
] | |
} | |
} | |
PLAY RECAP ************************************************************************************************************************************************************************************************************************************************************** | |
bar : ok=10 changed=5 unreachable=0 failed=0 | |
localhost : ok=6 changed=2 unreachable=0 failed=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
connection: local | |
tasks: | |
- shell: | | |
rm -rf ~/test | |
mkdir ~/test | |
touch test/test{1,2,3} | |
chown ubuntu test/test1 | |
chown aptly test/test2 | |
ls -al test/ | |
register: _output | |
args: | |
executable: /bin/bash | |
- debug: | |
var: _output | |
- hosts: bar | |
tasks: | |
- shell: | | |
rsync --version | |
register: _output | |
args: | |
executable: /bin/bash | |
- debug: | |
var: _output | |
- file: | |
path: "/tmp/test" | |
state: absent | |
- synchronize: | |
src: "~/test" | |
dest: "/tmp/" | |
mode: push | |
delete: yes | |
rsync_opts: | |
- "--verbose" | |
- "--chown='nginx:www-data'" | |
register: _synchronize | |
until: _synchronize | success | |
retries: 5 | |
delay: 5 | |
- debug: | |
var: _synchronize | |
- shell: | | |
touch /tmp/test/test{4,5,6} | |
chown ubuntu /tmp/test/test{1,4} | |
ls -al /tmp/test/ | |
register: _output | |
args: | |
executable: /bin/bash | |
- debug: | |
var: _output | |
- synchronize: | |
src: "/tmp/test/" | |
dest: "~/test" | |
mode: pull | |
delete: yes | |
rsync_opts: | |
- "--verbose" | |
- "--chown='aptly:www-data'" | |
register: _synchronize | |
until: _synchronize | success | |
retries: 5 | |
delay: 5 | |
- debug: | |
var: _synchronize | |
- hosts: localhost | |
connection: local | |
tasks: | |
- shell: | | |
ls -al test/ | |
register: _output | |
args: | |
executable: /bin/bash | |
- debug: | |
var: _output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ansible-2.2) root@foo:~# ansible --version | |
ansible 2.2.3.0 | |
config file = | |
configured module search path = Default w/o overrides | |
(ansible-2.2) root@foo:~# rsync --version | |
rsync version 3.1.1 protocol version 31 | |
Copyright (C) 1996-2014 by Andrew Tridgell, Wayne Davison, and others. | |
Web site: http://rsync.samba.org/ | |
Capabilities: | |
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints, | |
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, | |
append, ACLs, xattrs, iconv, symtimes, prealloc | |
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you | |
are welcome to redistribute it under certain conditions. See the GNU | |
General Public Licence for details. | |
(ansible-2.2) root@foo:~# ansible-playbook -i /tmp/inventory 2-test-playbook.yml | |
PLAY [localhost] *************************************************************** | |
TASK [setup] ******************************************************************* | |
ok: [localhost] | |
TASK [command] ***************************************************************** | |
changed: [localhost] | |
[WARNING]: Consider using file module with state=absent rather than running rm | |
TASK [debug] ******************************************************************* | |
ok: [localhost] => { | |
"_output": { | |
"changed": true, | |
"cmd": "rm -rf ~/test\n mkdir ~/test\n touch test/test{1,2,3}\n chown ubuntu test/test1\n chown aptly test/test2\n ls -al test/", | |
"delta": "0:00:00.018222", | |
"end": "2017-11-30 12:56:13.751431", | |
"rc": 0, | |
"start": "2017-11-30 12:56:13.733209", | |
"stderr": "", | |
"stdout": "total 8\ndrwxr-xr-x 2 root root 4096 Nov 30 12:56 .\ndrwx------ 15 root root 4096 Nov 30 12:56 ..\n-rw-r--r-- 1 ubuntu root 0 Nov 30 12:56 test1\n-rw-r--r-- 1 aptly root 0 Nov 30 12:56 test2\n-rw-r--r-- 1 root root 0 Nov 30 12:56 test3", | |
"stdout_lines": [ | |
"total 8", | |
"drwxr-xr-x 2 root root 4096 Nov 30 12:56 .", | |
"drwx------ 15 root root 4096 Nov 30 12:56 ..", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 12:56 test1", | |
"-rw-r--r-- 1 aptly root 0 Nov 30 12:56 test2", | |
"-rw-r--r-- 1 root root 0 Nov 30 12:56 test3" | |
], | |
"warnings": [ | |
"Consider using file module with state=absent rather than running rm" | |
] | |
} | |
} | |
PLAY [mirrors] ***************************************************************** | |
TASK [setup] ******************************************************************* | |
ok: [bar] | |
TASK [command] ***************************************************************** | |
changed: [bar] | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_output": { | |
"changed": true, | |
"cmd": "rsync --version", | |
"delta": "0:00:00.003360", | |
"end": "2017-11-30 12:48:47.176286", | |
"rc": 0, | |
"start": "2017-11-30 12:48:47.172926", | |
"stderr": "", | |
"stdout": "rsync version 3.1.0 protocol version 31\nCopyright (C) 1996-2013 by Andrew Tridgell, Wayne Davison, and others.\nWeb site: http://rsync.samba.org/\nCapabilities:\n 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,\n socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,\n append, ACLs, xattrs, iconv, symtimes, prealloc\n\nrsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you\nare welcome to redistribute it under certain conditions. See the GNU\nGeneral Public Licence for details.", | |
"stdout_lines": [ | |
"rsync version 3.1.0 protocol version 31", | |
"Copyright (C) 1996-2013 by Andrew Tridgell, Wayne Davison, and others.", | |
"Web site: http://rsync.samba.org/", | |
"Capabilities:", | |
" 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,", | |
" socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,", | |
" append, ACLs, xattrs, iconv, symtimes, prealloc", | |
"", | |
"rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you", | |
"are welcome to redistribute it under certain conditions. See the GNU", | |
"General Public Licence for details." | |
], | |
"warnings": [] | |
} | |
} | |
TASK [file] ******************************************************************** | |
changed: [bar] | |
TASK [synchronize] ************************************************************* | |
changed: [bar] | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_synchronize": { | |
"attempts": 1, | |
"changed": true, | |
"cmd": "/usr/bin/rsync --delay-updates -F --compress --delete-after --archive --rsh 'ssh -i /root/.ssh/my.key -S none -o StrictHostKeyChecking=no' --verbose --chown=nginx:www-data --out-format='<<CHANGED>>%i %n%L' \"/root/test\" \"root@bar:/tmp/\"", | |
"msg": "building file list ... done\ncd+++++++++ test/\n<f+++++++++ test/test1\n<f+++++++++ test/test2\n<f+++++++++ test/test3\n\nsent 270 bytes received 79 bytes 698.00 bytes/sec\ntotal size is 0 speedup is 0.00\n", | |
"rc": 0, | |
"stdout_lines": [ | |
"building file list ... done", | |
"cd+++++++++ test/", | |
"<f+++++++++ test/test1", | |
"<f+++++++++ test/test2", | |
"<f+++++++++ test/test3", | |
"sent 270 bytes received 79 bytes 698.00 bytes/sec", | |
"total size is 0 speedup is 0.00" | |
] | |
} | |
} | |
TASK [command] ***************************************************************** | |
changed: [bar] | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_output": { | |
"changed": true, | |
"cmd": "ls -al /tmp/test/", | |
"delta": "0:00:00.003785", | |
"end": "2017-11-30 12:48:48.419578", | |
"rc": 0, | |
"start": "2017-11-30 12:48:48.415793", | |
"stderr": "", | |
"stdout": "total 44\ndrwxr-xr-x 2 nginx www-data 4096 Nov 30 2017 .\ndrwxrwxrwt 11 root root 36864 Nov 30 12:48 ..\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test1\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3", | |
"stdout_lines": [ | |
"total 44", | |
"drwxr-xr-x 2 nginx www-data 4096 Nov 30 2017 .", | |
"drwxrwxrwt 11 root root 36864 Nov 30 12:48 ..", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test1", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3" | |
], | |
"warnings": [] | |
} | |
} | |
TASK [command] ***************************************************************** | |
changed: [bar] | |
[WARNING]: Consider using file module with state=touch rather than running touch | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_output": { | |
"changed": true, | |
"cmd": "touch /tmp/test/test{4,5,6}\n chown ubuntu /tmp/test/test{1,4}\n ls -al /tmp/test/", | |
"delta": "0:00:00.005503", | |
"end": "2017-11-30 12:48:48.705574", | |
"rc": 0, | |
"start": "2017-11-30 12:48:48.700071", | |
"stderr": "", | |
"stdout": "total 44\ndrwxr-xr-x 2 nginx www-data 4096 Nov 30 12:48 .\ndrwxrwxrwt 11 root root 36864 Nov 30 12:48 ..\n-rw-r--r-- 1 ubuntu www-data 0 Nov 30 2017 test1\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3\n-rw-r--r-- 1 ubuntu root 0 Nov 30 12:48 test4\n-rw-r--r-- 1 root root 0 Nov 30 12:48 test5\n-rw-r--r-- 1 root root 0 Nov 30 12:48 test6", | |
"stdout_lines": [ | |
"total 44", | |
"drwxr-xr-x 2 nginx www-data 4096 Nov 30 12:48 .", | |
"drwxrwxrwt 11 root root 36864 Nov 30 12:48 ..", | |
"-rw-r--r-- 1 ubuntu www-data 0 Nov 30 2017 test1", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 12:48 test4", | |
"-rw-r--r-- 1 root root 0 Nov 30 12:48 test5", | |
"-rw-r--r-- 1 root root 0 Nov 30 12:48 test6" | |
], | |
"warnings": [ | |
"Consider using file module with state=touch rather than running touch" | |
] | |
} | |
} | |
TASK [synchronize] ************************************************************* | |
changed: [bar] | |
TASK [debug] ******************************************************************* | |
ok: [bar] => { | |
"_synchronize": { | |
"attempts": 1, | |
"changed": true, | |
"cmd": "/usr/bin/rsync --delay-updates -F --compress --delete-after --archive --rsh 'ssh -i /root/.ssh/my.key -S none -o StrictHostKeyChecking=no' --verbose --chown=aptly:www-data --out-format='<<CHANGED>>%i %n%L' \"root@bar:/tmp/test/\" \"/root/test\"", | |
"msg": "receiving file list ... done\n.d..t.og... ./\n.f....og... test1\n.f.....g... test2\n.f....og... test3\n>f+++++++++ test4\n>f+++++++++ test5\n>f+++++++++ test6\n\nsent 130 bytes received 298 bytes 856.00 bytes/sec\ntotal size is 0 speedup is 0.00\n", | |
"rc": 0, | |
"stdout_lines": [ | |
"receiving file list ... done", | |
".d..t.og... ./", | |
".f....og... test1", | |
".f.....g... test2", | |
".f....og... test3", | |
">f+++++++++ test4", | |
">f+++++++++ test5", | |
">f+++++++++ test6", | |
"sent 130 bytes received 298 bytes 856.00 bytes/sec", | |
"total size is 0 speedup is 0.00" | |
] | |
} | |
} | |
PLAY [localhost] *************************************************************** | |
TASK [setup] ******************************************************************* | |
ok: [localhost] | |
TASK [command] ***************************************************************** | |
changed: [localhost] | |
TASK [debug] ******************************************************************* | |
ok: [localhost] => { | |
"_output": { | |
"changed": true, | |
"cmd": "ls -al test/", | |
"delta": "0:00:00.006370", | |
"end": "2017-11-30 12:56:17.299381", | |
"rc": 0, | |
"start": "2017-11-30 12:56:17.293011", | |
"stderr": "", | |
"stdout": "total 8\ndrwxr-xr-x 2 aptly www-data 4096 Nov 30 12:48 .\ndrwx------ 15 root root 4096 Nov 30 12:56 ..\n-rw-r--r-- 1 aptly www-data 0 Nov 30 12:56 test1\n-rw-r--r-- 1 aptly www-data 0 Nov 30 12:56 test2\n-rw-r--r-- 1 aptly www-data 0 Nov 30 12:56 test3\n-rw-r--r-- 1 aptly www-data 0 Nov 30 12:48 test4\n-rw-r--r-- 1 aptly www-data 0 Nov 30 12:48 test5\n-rw-r--r-- 1 aptly www-data 0 Nov 30 12:48 test6", | |
"stdout_lines": [ | |
"total 8", | |
"drwxr-xr-x 2 aptly www-data 4096 Nov 30 12:48 .", | |
"drwx------ 15 root root 4096 Nov 30 12:56 ..", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 12:56 test1", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 12:56 test2", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 12:56 test3", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 12:48 test4", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 12:48 test5", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 12:48 test6" | |
], | |
"warnings": [] | |
} | |
} | |
PLAY RECAP ********************************************************************* | |
bar : ok=12 changed=6 unreachable=0 failed=0 | |
localhost : ok=6 changed=2 unreachable=0 failed=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ansible-2.3) root@foo:~# ansible --version | |
ansible 2.3.2.0 | |
config file = | |
configured module search path = Default w/o overrides | |
python version = 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609] | |
(ansible-2.3) root@foo:~# rsync --version | |
rsync version 3.1.1 protocol version 31 | |
Copyright (C) 1996-2014 by Andrew Tridgell, Wayne Davison, and others. | |
Web site: http://rsync.samba.org/ | |
Capabilities: | |
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints, | |
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, | |
append, ACLs, xattrs, iconv, symtimes, prealloc | |
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you | |
are welcome to redistribute it under certain conditions. See the GNU | |
General Public Licence for details. | |
(ansible-2.3) root@foo:~# ansible-playbook -i /tmp/inventory 2-test-playbook.yml | |
PLAY [localhost] ******************************************************************************************************************************************************************************************************************************************************** | |
TASK [Gathering Facts] ************************************************************************************************************************************************************************************************************************************************** | |
ok: [localhost] | |
TASK [command] ********************************************************************************************************************************************************************************************************************************************************** | |
[WARNING]: Consider using file module with state=absent rather than running rm | |
changed: [localhost] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [localhost] => { | |
"_output": { | |
"changed": true, | |
"cmd": "rm -rf ~/test\n mkdir ~/test\n touch test/test{1,2,3}\n chown ubuntu test/test1\n chown aptly test/test2\n ls -al test/", | |
"delta": "0:00:00.012306", | |
"end": "2017-11-30 12:50:29.827682", | |
"rc": 0, | |
"start": "2017-11-30 12:50:29.815376", | |
"stderr": "", | |
"stderr_lines": [], | |
"stdout": "total 8\ndrwxr-xr-x 2 root root 4096 Nov 30 12:50 .\ndrwx------ 15 root root 4096 Nov 30 12:50 ..\n-rw-r--r-- 1 ubuntu root 0 Nov 30 12:50 test1\n-rw-r--r-- 1 aptly root 0 Nov 30 12:50 test2\n-rw-r--r-- 1 root root 0 Nov 30 12:50 test3", | |
"stdout_lines": [ | |
"total 8", | |
"drwxr-xr-x 2 root root 4096 Nov 30 12:50 .", | |
"drwx------ 15 root root 4096 Nov 30 12:50 ..", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 12:50 test1", | |
"-rw-r--r-- 1 aptly root 0 Nov 30 12:50 test2", | |
"-rw-r--r-- 1 root root 0 Nov 30 12:50 test3" | |
], | |
"warnings": [ | |
"Consider using file module with state=absent rather than running rm" | |
] | |
} | |
} | |
PLAY [mirrors] ********************************************************************************************************************************************************************************************************************************************************** | |
TASK [Gathering Facts] ************************************************************************************************************************************************************************************************************************************************** | |
ok: [bar] | |
TASK [command] ********************************************************************************************************************************************************************************************************************************************************** | |
changed: [bar] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [bar] => { | |
"_output": { | |
"changed": true, | |
"cmd": "rsync --version", | |
"delta": "0:00:00.004084", | |
"end": "2017-11-30 12:43:03.061420", | |
"rc": 0, | |
"start": "2017-11-30 12:43:03.057336", | |
"stderr": "", | |
"stderr_lines": [], | |
"stdout": "rsync version 3.1.0 protocol version 31\nCopyright (C) 1996-2013 by Andrew Tridgell, Wayne Davison, and others.\nWeb site: http://rsync.samba.org/\nCapabilities:\n 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,\n socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,\n append, ACLs, xattrs, iconv, symtimes, prealloc\n\nrsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you\nare welcome to redistribute it under certain conditions. See the GNU\nGeneral Public Licence for details.", | |
"stdout_lines": [ | |
"rsync version 3.1.0 protocol version 31", | |
"Copyright (C) 1996-2013 by Andrew Tridgell, Wayne Davison, and others.", | |
"Web site: http://rsync.samba.org/", | |
"Capabilities:", | |
" 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,", | |
" socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,", | |
" append, ACLs, xattrs, iconv, symtimes, prealloc", | |
"", | |
"rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you", | |
"are welcome to redistribute it under certain conditions. See the GNU", | |
"General Public Licence for details." | |
] | |
} | |
} | |
TASK [file] ************************************************************************************************************************************************************************************************************************************************************* | |
changed: [bar] | |
TASK [synchronize] ****************************************************************************************************************************************************************************************************************************************************** | |
changed: [bar] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [bar] => { | |
"_synchronize": { | |
"attempts": 1, | |
"changed": true, | |
"cmd": "/usr/bin/rsync --delay-updates -F --compress --delete-after --archive --rsh=/usr/bin/ssh -S none -i /root/.ssh/my.key -o StrictHostKeyChecking=no --verbose --chown=nginx:www-data --out-format=<<CHANGED>>%i %n%L /root/test root@bar:/tmp/", | |
"msg": "building file list ... done\ncd+++++++++ test/\n<f+++++++++ test/test1\n<f+++++++++ test/test2\n<f+++++++++ test/test3\n\nsent 266 bytes received 79 bytes 690.00 bytes/sec\ntotal size is 0 speedup is 0.00\n", | |
"rc": 0, | |
"stdout_lines": [ | |
"building file list ... done", | |
"cd+++++++++ test/", | |
"<f+++++++++ test/test1", | |
"<f+++++++++ test/test2", | |
"<f+++++++++ test/test3", | |
"sent 266 bytes received 79 bytes 690.00 bytes/sec", | |
"total size is 0 speedup is 0.00" | |
] | |
} | |
} | |
TASK [command] ********************************************************************************************************************************************************************************************************************************************************** | |
changed: [bar] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [bar] => { | |
"_output": { | |
"changed": true, | |
"cmd": "ls -al /tmp/test/", | |
"delta": "0:00:00.003735", | |
"end": "2017-11-30 12:43:04.289291", | |
"rc": 0, | |
"start": "2017-11-30 12:43:04.285556", | |
"stderr": "", | |
"stderr_lines": [], | |
"stdout": "total 44\ndrwxr-xr-x 2 nginx www-data 4096 Nov 30 2017 .\ndrwxrwxrwt 11 root root 36864 Nov 30 12:43 ..\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test1\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3", | |
"stdout_lines": [ | |
"total 44", | |
"drwxr-xr-x 2 nginx www-data 4096 Nov 30 2017 .", | |
"drwxrwxrwt 11 root root 36864 Nov 30 12:43 ..", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test1", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3" | |
] | |
} | |
} | |
TASK [command] ********************************************************************************************************************************************************************************************************************************************************** | |
[WARNING]: Consider using file module with state=touch rather than running touch | |
changed: [bar] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [bar] => { | |
"_output": { | |
"changed": true, | |
"cmd": "touch /tmp/test/test{4,5,6}\n chown ubuntu /tmp/test/test{1,4}\n ls -al /tmp/test/", | |
"delta": "0:00:00.006863", | |
"end": "2017-11-30 12:43:04.547450", | |
"rc": 0, | |
"start": "2017-11-30 12:43:04.540587", | |
"stderr": "", | |
"stderr_lines": [], | |
"stdout": "total 44\ndrwxr-xr-x 2 nginx www-data 4096 Nov 30 12:43 .\ndrwxrwxrwt 11 root root 36864 Nov 30 12:43 ..\n-rw-r--r-- 1 ubuntu www-data 0 Nov 30 2017 test1\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2\n-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3\n-rw-r--r-- 1 ubuntu root 0 Nov 30 12:43 test4\n-rw-r--r-- 1 root root 0 Nov 30 12:43 test5\n-rw-r--r-- 1 root root 0 Nov 30 12:43 test6", | |
"stdout_lines": [ | |
"total 44", | |
"drwxr-xr-x 2 nginx www-data 4096 Nov 30 12:43 .", | |
"drwxrwxrwt 11 root root 36864 Nov 30 12:43 ..", | |
"-rw-r--r-- 1 ubuntu www-data 0 Nov 30 2017 test1", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test2", | |
"-rw-r--r-- 1 nginx www-data 0 Nov 30 2017 test3", | |
"-rw-r--r-- 1 ubuntu root 0 Nov 30 12:43 test4", | |
"-rw-r--r-- 1 root root 0 Nov 30 12:43 test5", | |
"-rw-r--r-- 1 root root 0 Nov 30 12:43 test6" | |
], | |
"warnings": [ | |
"Consider using file module with state=touch rather than running touch" | |
] | |
} | |
} | |
TASK [synchronize] ****************************************************************************************************************************************************************************************************************************************************** | |
changed: [bar] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [bar] => { | |
"_synchronize": { | |
"attempts": 1, | |
"changed": true, | |
"cmd": "/usr/bin/rsync --delay-updates -F --compress --delete-after --archive --rsh=/usr/bin/ssh -S none -i /root/.ssh/my.key -o StrictHostKeyChecking=no --verbose --chown=aptly:www-data --out-format=<<CHANGED>>%i %n%L root@bar:/tmp/test/ /root/test", | |
"msg": "receiving file list ... done\n.d..t.og... ./\n.f....og... test1\n.f.....g... test2\n.f....og... test3\n>f+++++++++ test4\n>f+++++++++ test5\n>f+++++++++ test6\n\nsent 130 bytes received 294 bytes 848.00 bytes/sec\ntotal size is 0 speedup is 0.00\n", | |
"rc": 0, | |
"stdout_lines": [ | |
"receiving file list ... done", | |
".d..t.og... ./", | |
".f....og... test1", | |
".f.....g... test2", | |
".f....og... test3", | |
">f+++++++++ test4", | |
">f+++++++++ test5", | |
">f+++++++++ test6", | |
"sent 130 bytes received 294 bytes 848.00 bytes/sec", | |
"total size is 0 speedup is 0.00" | |
] | |
} | |
} | |
PLAY [localhost] ******************************************************************************************************************************************************************************************************************************************************** | |
TASK [Gathering Facts] ************************************************************************************************************************************************************************************************************************************************** | |
ok: [localhost] | |
TASK [command] ********************************************************************************************************************************************************************************************************************************************************** | |
changed: [localhost] | |
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************ | |
ok: [localhost] => { | |
"_output": { | |
"changed": true, | |
"cmd": "ls -al test/", | |
"delta": "0:00:00.004991", | |
"end": "2017-11-30 12:50:33.122093", | |
"rc": 0, | |
"start": "2017-11-30 12:50:33.117102", | |
"stderr": "", | |
"stderr_lines": [], | |
"stdout": "total 8\ndrwxr-xr-x 2 aptly www-data 4096 Nov 30 12:43 .\ndrwx------ 15 root root 4096 Nov 30 12:50 ..\n-rw-r--r-- 1 aptly www-data 0 Nov 30 12:50 test1\n-rw-r--r-- 1 aptly www-data 0 Nov 30 12:50 test2\n-rw-r--r-- 1 aptly www-data 0 Nov 30 12:50 test3\n-rw-r--r-- 1 aptly www-data 0 Nov 30 12:43 test4\n-rw-r--r-- 1 aptly www-data 0 Nov 30 12:43 test5\n-rw-r--r-- 1 aptly www-data 0 Nov 30 12:43 test6", | |
"stdout_lines": [ | |
"total 8", | |
"drwxr-xr-x 2 aptly www-data 4096 Nov 30 12:43 .", | |
"drwx------ 15 root root 4096 Nov 30 12:50 ..", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 12:50 test1", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 12:50 test2", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 12:50 test3", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 12:43 test4", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 12:43 test5", | |
"-rw-r--r-- 1 aptly www-data 0 Nov 30 12:43 test6" | |
] | |
} | |
} | |
PLAY RECAP ************************************************************************************************************************************************************************************************************************************************************** | |
bar : ok=12 changed=6 unreachable=0 failed=0 | |
localhost : ok=6 changed=2 unreachable=0 failed=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
connection: local | |
tasks: | |
- shell: | | |
rm -rf ~/test | |
mkdir ~/test | |
touch test/test{1,2,3} | |
chown ubuntu test/test1 | |
chown aptly test/test2 | |
ls -al test/ | |
register: _output | |
args: | |
executable: /bin/bash | |
- debug: | |
var: _output | |
- hosts: mirrors | |
tasks: | |
- shell: | | |
rsync --version | |
register: _output | |
args: | |
executable: /bin/bash | |
- debug: | |
var: _output | |
- file: | |
path: "/tmp/test" | |
state: absent | |
- synchronize: | |
src: "~/test" | |
dest: "/tmp/" | |
mode: push | |
delete: yes | |
rsync_opts: | |
- "--verbose" | |
- "--chown=nginx:www-data" | |
register: _synchronize | |
until: _synchronize | success | |
retries: 5 | |
delay: 5 | |
- debug: | |
var: _synchronize | |
- shell: | | |
ls -al /tmp/test/ | |
register: _output | |
args: | |
executable: /bin/bash | |
- debug: | |
var: _output | |
- shell: | | |
touch /tmp/test/test{4,5,6} | |
chown ubuntu /tmp/test/test{1,4} | |
ls -al /tmp/test/ | |
register: _output | |
args: | |
executable: /bin/bash | |
- debug: | |
var: _output | |
- synchronize: | |
src: "/tmp/test/" | |
dest: "~/test" | |
mode: pull | |
delete: yes | |
rsync_opts: | |
- "--verbose" | |
- "--chown=aptly:www-data" | |
register: _synchronize | |
until: _synchronize | success | |
retries: 5 | |
delay: 5 | |
- debug: | |
var: _synchronize | |
- hosts: localhost | |
connection: local | |
tasks: | |
- shell: | | |
ls -al test/ | |
register: _output | |
args: | |
executable: /bin/bash | |
- debug: | |
var: _output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment