Skip to content

Commit

Permalink
Sync configurations to Dropbox.
Browse files Browse the repository at this point in the history
  • Loading branch information
lexrus committed Dec 29, 2014
1 parent 7f715e2 commit 3a97f6d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
53 changes: 53 additions & 0 deletions 100_sync_with_dropbox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---

- hosts: localhost
gather_facts: no
vars:
dropbox_folder: "~/Dropbox/.ios-dev-playbook"
hosts_file: "ansible_hosts.ini"
tasks:
- stat: path="{{ dropbox_folder }}/group_vars"
register: group_folder
- file: path="{{ dropbox_folder }}" state=directory
when: not group_folder.stat.exists

- stat: path="{{ dropbox_folder }}/host_vars"
register: host_folder
- file: path="{{ dropbox_folder }}" state=directory
when: not host_folder.stat.exists

- stat: path="{{ dropbox_folder }}/{{ hosts_file }}"
register: dropbox_hosts_config
- stat: path="{{ hosts_file }}"
register: hosts_config
- copy: src="{{ hosts_file }}" dest="{{ dropbox_folder }}/{{ hosts_file }}" backup=true
when: not dropbox_hosts_config.stat.exists and hosts_config.stat.exists

- stat: path="{{ dropbox_folder }}/{{ hosts_file }}"
register: dropbox_hosts_config
- stat: path="{{ hosts_file }}"
register: hosts_config
- command: "rm -rf {{ hosts_file }}"
when: dropbox_hosts_config.stat.exists
- file: src="{{ dropbox_folder }}/{{ hosts_file }}" dest="{{ hosts_file }}" state=link
when: dropbox_hosts_config.stat.exists

- copy: src={{ item }} dest={{ dropbox_folder }}/group_vars/
with_fileglob:
- group_vars/*.yml
- command: rm -rf {{ item }}
with_fileglob:
- group_vars/*.yml
- file: src="{{ item }}" dest="group_vars/{{ item | basename }}" state=link
with_fileglob:
- "{{ dropbox_folder }}/group_vars/*.yml"

- copy: src={{ item }} dest={{ dropbox_folder }}/host_vars/
with_fileglob:
- host_vars/*.yml
- command: rm -rf {{ item }}
with_fileglob:
- host_vars/*.yml
- file: src="{{ item }}" dest="host_vars/{{ item | basename }}" state=link
with_fileglob:
- "{{ dropbox_folder }}/host_vars/*.yml"
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
desc "Sync to/with Dropbox"
task :dropbox do
exec "ansible-playbook 100_sync_with_dropbox.yml -i ansible_localhost.ini"
end

desc "Install dependencies"
task :deps do
exec "ansible-galaxy install --ignore-errors --force " \
Expand Down
4 changes: 3 additions & 1 deletion ansible.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[defaults]
display_skipped_hosts = False
hostfile = ./ansible_hosts.ini
roles_path = ./roles/
gathering = smart

[ssh_connection]
pipelining=True

ssh_args = -o ControlMaster=auto -o ControlPersist=30m

0 comments on commit 3a97f6d

Please sign in to comment.