Skip to content

Instantly share code, notes, and snippets.

@choplin
Last active August 29, 2015 14:07
Show Gist options
  • Save choplin/6c18b2d8519f21e113db to your computer and use it in GitHub Desktop.
Save choplin/6c18b2d8519f21e113db to your computer and use it in GitHub Desktop.
---
- hosts: foo
tasks:
- command: ssh-keygen -f ~/.ssh/id_rsa -P ''
- command: cat .ssh/id_rsa.pub
register: key
- hosts: bar
tasks:
- authorized_key: user=vagrant key="{{ hostvars[item].key.stdout }}"
with_items: groups['foo']
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
[
{name: 'foo1', ip: '192.168.77.21'},
{name: 'foo2', ip: '192.168.77.22'},
{name: 'foo3', ip: '192.168.77.23'},
{name: 'bar1', ip: '192.168.77.24'},
{name: 'bar2', ip: '192.168.77.25'},
{name: 'bar3', ip: '192.168.77.26'},
].each do |m|
config.vm.define m[:name] do |c|
c.vm.box = "sl65"
c.vm.network "private_network", ip: m[:ip]
end
end
config.vm.define "foo1" do |c|
c.vm.provision "ansible" do |ansible|
ansible.playbook = "site.yml"
ansible.limit = 'all'
ansible.groups = {
"foo" => %w(foo1 foo2 foo3),
"bar" => %w(bar1 bar2 bar3)
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment