Skip to content

Commit

Permalink
adds readme notes for rsync.yml, updates comments, updates _staging.e…
Browse files Browse the repository at this point in the history
…xample
  • Loading branch information
discopatrick committed Jul 12, 2016
1 parent fc4bccc commit bef74bb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,14 @@ Most vagrant boxes come with a default 'vagrant' user with passwordless sudo. On

In this playbook, the very first role is to add the admin user - this is done while logging in as root (set as `remote_user` at task level in the admin_user role, to override the playbook level setting described below). This only needs to be done on remote machines though, so the 'development group' is excluded from this role.

Any roles or tasks beyond this should use the standard user. This is set at playbook level as `remote_user`. This in turn is set via a group_var called `my_remote_user` - because the user will be different depending on the environment ('vagrant' on the development box, 'admin' elsewhere).
Any roles or tasks beyond this should use the standard user. This is set at playbook level as `remote_user`. This in turn is set via a group_var called `my_remote_user` - because the user will be different depending on the environment ('vagrant' on the development box, 'admin' elsewhere).

### rsync.yml

A playbook to sync a folder on one remote host, to a folder on another remote host.

Note: Add your own remote hosts to the inventory first (see hosts/_staging.example). Also run remote-admin-user.yml on both servers you wish to sync, before running this playbook. This adds the admin user, and your local public key, to the servers.

Currently tested on two remote hosts (not vagrant).

View the comments in the playbook for more info.
18 changes: 14 additions & 4 deletions hosts/_staging.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# rename this file to _staging, uncomment the lines below,
# and add your own staging hostname
## rename this file to _staging, uncomment the lines below,
## and add your own staging hosts

#[staging]
#your_staging_hostname_or_ip
# ansible-pocs-1 ansible_ssh_host=your_host_ip_1
# ansible-pocs-2 ansible_ssh_host=your_host_ip_2

# [staging]
# ansible-pocs-1
# ansible-pocs-2

## ForwardAgent is necessary when running a task that connects
## a remote host to another remote host/server, e.g. running
## rsync, or pulling from Github
# [staging:vars]
# ansible_ssh_extra_args="-o ForwardAgent=yes"
8 changes: 4 additions & 4 deletions playbooks/rsync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

tasks:

# try writing a task with hosts defined at task level?

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

## This playbook is run against host ansible-pocs-1, but this task is
## delegated to ansible-pocs-2. In practice this means that the task
## first logs into ansible-pocs-2 and then runs rsync from there back
## to ansible-pocs-1.
- name: sync remote folder to remote folder
synchronize:
src: /home/admin/syncthis
Expand All @@ -24,5 +26,3 @@
# mode: push ## default is push
delegate_to: ansible-pocs-2

# - name: use rsync manually
# command: "rsync [email protected]:~/syncthis ~/"

0 comments on commit bef74bb

Please sign in to comment.