diff --git a/.gitignore b/.gitignore index a058c8c..655d9a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .vagrant *.retry +.rsync diff --git a/playbooks/rsync.yml b/playbooks/rsync-remote.yml similarity index 91% rename from playbooks/rsync.yml rename to playbooks/rsync-remote.yml index 39f0c6f..5adc809 100644 --- a/playbooks/rsync.yml +++ b/playbooks/rsync-remote.yml @@ -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 @@ -33,4 +34,4 @@ synchronize: src: /home/admin/syncthis dest: /home/admin - delegate_to: "{{ groups['staging'][1] }}" + delegate_to: "{{ groups['staging'][1] }}" diff --git a/playbooks/rsync-vagrant-experiments.yml b/playbooks/rsync-vagrant-experiments.yml new file mode 100644 index 0000000..acaf8b6 --- /dev/null +++ b/playbooks/rsync-vagrant-experiments.yml @@ -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 diff --git a/playbooks/rsync-vagrant.yml b/playbooks/rsync-vagrant.yml new file mode 100644 index 0000000..825cd45 --- /dev/null +++ b/playbooks/rsync-vagrant.yml @@ -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