## Setup with Vagrant
-First source the `rc` file:
-
- $ source rc
-
-Edit your `/etc/hosts` file with:
-
- # Ansible hosts
- 127.0.0.1 ceph-mon0
- 127.0.0.1 ceph-mon1
- 127.0.0.1 ceph-mon2
- 127.0.0.1 ceph-osd0
- 127.0.0.1 ceph-osd1
- 127.0.0.1 ceph-osd2
- 127.0.0.1 ceph-rgw
-
-**Now since we use Vagrant and port forwarding, don't forget to collect the SSH local port of your VMs.**
-Then edit your `hosts` file accordingly.
-
-Ok let's get serious now.
Run your virtual machines:
```bash
$ vagrant up
...
...
-...
-```
-
-Test if Ansible can access the virtual machines:
-
-```bash
-$ ansible all -m ping
-ceph-mon0 | success >> {
- "changed": false,
- "ping": "pong"
-}
-
-ceph-mon1 | success >> {
- "changed": false,
- "ping": "pong"
-}
-
-ceph-osd0 | success >> {
- "changed": false,
- "ping": "pong"
-}
-
-ceph-osd2 | success >> {
- "changed": false,
- "ping": "pong"
-}
-
-ceph-mon2 | success >> {
- "changed": false,
- "ping": "pong"
-}
-
-ceph-osd1 | success >> {
- "changed": false,
- "ping": "pong"
-}
-
-ceph-rgw | success >> {
- "changed": false,
- "ping": "pong"
-}
-```
-
-**DON'T FORGET TO GENERATE A FSID FOR THE CLUSTER AND A KEY FOR THE MONITOR**
-
-For this go to `group_vars/all` and `group_vars/mons` and append the fsid and key.
-
-These are **ONLY** examples, **DON'T USE THEM IN PRODUCTION**:
-
-* fsid: 4a158d27-f750-41d5-9e7f-26ce4c9d2d45
-* monitor: AQAWqilTCDh7CBAAawXt6kyTgLFCxSvJhTEmuw==
-
-Ready to deploy? Let's go!
-
-```bash
-$ ansible-playbook -f 7 -v site.yml
-...
...
____________
< PLAY RECAP >
|| ||
-ceph-mon0 : ok=13 changed=10 unreachable=0 failed=0
-ceph-mon1 : ok=13 changed=9 unreachable=0 failed=0
-ceph-mon2 : ok=13 changed=9 unreachable=0 failed=0
-ceph-osd0 : ok=19 changed=12 unreachable=0 failed=0
-ceph-osd1 : ok=19 changed=12 unreachable=0 failed=0
-ceph-osd2 : ok=19 changed=12 unreachable=0 failed=0
-ceph-rgw : ok=23 changed=16 unreachable=0 failed=0
+mon0 : ok=16 changed=11 unreachable=0 failed=0
+mon1 : ok=16 changed=10 unreachable=0 failed=0
+mon2 : ok=16 changed=11 unreachable=0 failed=0
+osd0 : ok=19 changed=7 unreachable=0 failed=0
+osd1 : ok=19 changed=7 unreachable=0 failed=0
+osd2 : ok=19 changed=7 unreachable=0 failed=0
+rgw : ok=20 changed=17 unreachable=0 failed=0
```
Check the status:
pgmap v17: 192 pgs, 3 pools, 9470 bytes data, 21 objects
205 MB used, 29728 MB / 29933 MB avail
192 active+clean
+```
+
+To re-run the Ansible provisioning scripts:
+
+```bash
+$ vagrant provision
+```
+
+## Specifying fsid and secret key in production
+
+The Vagrantfile specifies an fsid for the cluster and a secret key for the
+monitor. If using these playbooks in production, you must generate your own `fsid`
+in `group_vars/all` and `monitor_secret` in `group_vars/mons`. Those files contain
+information about how to generate appropriate values for these variables.
+
+
+
# -*- mode: ruby -*-
# vi: set ft=ruby :
-# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+
VAGRANTFILE_API_VERSION = "2"
+NMONS = 3
+NOSDS = 3
+
+ansible_provision = Proc.new do |ansible|
+ ansible.playbook = "site.yml"
+ # Note: Can't do ranges like mon[0-2] in groups because
+ # these aren't supported by Vagrant, see
+ # https://github.com/mitchellh/vagrant/issues/3539
+ ansible.groups = {
+ "mons" => (0..NMONS-1).map {|j| "mon#{j}"},
+ "osds" => (0..NOSDS-1).map {|j| "osd#{j}"},
+ "mdss" => [],
+ "rgws" => ["rgw"]
+ }
+
+ # In a production deployment, these should be secret
+ ansible.extra_vars = {
+ fsid: "4a158d27-f750-41d5-9e7f-26ce4c9d2d45",
+ monitor_secret: "AQAWqilTCDh7CBAAawXt6kyTgLFCxSvJhTEmuw=="
+ }
+ ansible.limit = 'all'
+end
+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
+
config.vm.define :rgw do |rgw|
rgw.vm.network :private_network, ip: "192.168.0.2"
rgw.vm.host_name = "ceph-rgw"
end
end
- (0..2).each do |i|
+ (0..NMONS-1).each do |i|
config.vm.define "mon#{i}" do |mon|
mon.vm.hostname = "ceph-mon#{i}"
mon.vm.network :private_network, ip: "192.168.0.1#{i}"
end
end
- (0..2).each do |i|
+ (0..NOSDS-1).each do |i|
config.vm.define "osd#{i}" do |osd|
osd.vm.hostname = "ceph-osd#{i}"
osd.vm.network :private_network, ip: "192.168.0.10#{i}"
vb.customize ["modifyvm", :id, "--memory", "192"]
end
end
+
+ # Run the provisioner after the last machine comes up
+ if i == (NOSDS-1)
+ osd.vm.provision "ansible", &ansible_provision
+ end
end
end
end