Skip to content

Commit

Permalink
adds rsync playbooks, with working sync for remote to vagrant hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
discopatrick committed Jul 12, 2016
1 parent d9d2067 commit 5de3050
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vagrant
*.retry
.rsync
5 changes: 3 additions & 2 deletions playbooks/rsync.yml → playbooks/rsync-remote.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: ansible-pocs-1
- name: rsync with remote machines
hosts: ansible-pocs-1
remote_user: "{{ my_remote_user }}"
become: no
become_method: sudo
Expand Down Expand Up @@ -33,4 +34,4 @@
synchronize:
src: /home/admin/syncthis
dest: /home/admin
delegate_to: "{{ groups['staging'][1] }}"
delegate_to: "{{ groups['staging'][1] }}"
50 changes: 50 additions & 0 deletions playbooks/rsync-vagrant-experiments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---

- name: rsync with local vagrant machines
hosts: primary
remote_user: "{{ my_remote_user }}"
become: no
become_method: sudo
become_user: root

tasks:

- name: sync local folder to vagrant box folder
synchronize:
src: /Users/patrick/Documents/syncthis
dest: /home/vagrant

## This task fails - the error message complains of a missing
## public key file, although it is clearly present locally -
## but probably not on the 'secondary' machine. Why is it
## looking for a .vagrant folder on the 'secondary' machine?
## I suspect this is a problem with the fact that both vagrant
## machines are on 127.0.0.1 (albeit different ports) and
## AgentForwarding is getting confused, and failing.
# - name: sync vbox1 folder to vbox2 folder
# synchronize:
# src: /home/vagrant/syncthis
# dest: /home/vagrant
# delegate_to: secondary

- name: rsync vagrant box to remote box
hosts: ansible-pocs-1
remote_user: "{{ my_remote_user }}"
become: no
become_method: sudo
become_user: root

tasks:

## rsync in this task will need to be run on the vagrant box
## (because the remote box will not be able to connect to the
## vagrant box, as it is on our private network). Thus, the
## delegate_to setting should be the vagrant box, the mode
## should be 'pull' and the play host should be the remote box.
## THIS TASK FAILS for the same reasons as the previous play.
# - name: sync vagrant box to remote box
# synchronize:
# src: /home/admin/syncthis
# dest: /home/vagrant
# mode: pull
# delegate_to: primary
32 changes: 32 additions & 0 deletions playbooks/rsync-vagrant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---

- name: two step rsync - step 1
hosts: ansible-pocs-1
remote_user: "{{ my_remote_user }}"
become: no
become_method: sudo
become_user: root

tasks:

- name: sync remote box to local dir
synchronize:
src: /home/admin/syncthis
dest: ./.rsync
mode: pull
become: yes

- name: two step rsync - step 2
hosts: primary
remote_user: "{{ my_remote_user }}"
become: no
become_method: sudo
become_user: root

tasks:

- name: sync local dir to vagrant box
synchronize:
src: ./.rsync/syncthis
dest: /home/vagrant
mode: push

0 comments on commit 5de3050

Please sign in to comment.