diff --git a/ansible/config.yml b/ansible/config.yml index 2bcbf91..3ed7430 100644 --- a/ansible/config.yml +++ b/ansible/config.yml @@ -31,5 +31,5 @@ with_dict: git/.gitignore: .gitignore - name: setup ssh keys - local_action: ruby ~/.dotfiles/setup_ssh_keys.rb + local_action: command ruby ~/.dotfiles/scripts/setup_ssh_keys.rb when: ansible_domain == "local" diff --git a/scripts/setup_ssh_keys.rb b/scripts/setup_ssh_keys.rb new file mode 100644 index 0000000..8d26af9 --- /dev/null +++ b/scripts/setup_ssh_keys.rb @@ -0,0 +1,21 @@ +require 'fileutils' + +include FileUtils + +def with_mount(image) + out = `hdiutil mount #{image}` + mountpoint = out.split(/\s+/).last + yield(mountpoint) +ensure + puts `hdiutil unmount #{mountpoint}` +end + +cd File.expand_path('~/.ssh') + +with_mount "~/Dropbox/sekritz.sparseimage" do |mountpoint| + Dir["#{mountpoint}/ssh keys/*"].each do |file| + cp file, File.basename(file) + puts `chmod go-r #{File.basename(file)}` + puts `ssh-add -K #{File.basename(file)}` + end +end