]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Use Vagrant's Ansible provisioner 82/head
authorLorin Hochstein <lorin.hochstein@sendgrid.com>
Sun, 11 May 2014 01:52:26 +0000 (21:52 -0400)
committerLorin Hochstein <lorin.hochstein@sendgrid.com>
Sun, 11 May 2014 23:34:37 +0000 (19:34 -0400)
Use Vagrant's built-in support for Ansible provisioner. This eliminates the need
for a hosts file, and simplifies the ansible config file.

Renames config from .ansible.cfg to ansible.cfg since Ansible expects the file
to be called ansible.cfg and be adjacent to Vagrantfile when using the Vagrant
provisioner.

.ansible.cfg [deleted file]
.gitignore
README.md
Vagrantfile
ansible.cfg [new file with mode: 0644]
hosts [deleted file]
rc [deleted file]

diff --git a/.ansible.cfg b/.ansible.cfg
deleted file mode 100644 (file)
index f3c0a80..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-[defaults]
-host_key_checking = False
-remote_user = vagrant
-hostfile = hosts
-ansible_managed = Ansible managed: modified on %Y-%m-%d %H:%M:%S by {uid}
-private_key_file = ~/.vagrant.d/insecure_private_key
-error_on_undefined_vars = False
-forks = 6
-#If set to False, ansible will not display any status for a task that is skipped. The default behavior is to display skipped tasks:
-display_skipped_hosts=True
index 80ebf27f6bc6bd04fde61f15cde4261dcbfce9c1..98550a81cc44ffc134de7423d6392eb32ecf0cea 100644 (file)
@@ -1,3 +1,4 @@
 .vagrant
 *.vdi
 *.keyring
+fetch/4a158d27-f750-41d5-9e7f-26ce4c9d2d45
index 443f151fca6592da8c281da22753324a960bb202..a5d72c734b58ac079a2235021e5bc33eacfefdd1 100644 (file)
--- a/README.md
+++ b/README.md
@@ -27,88 +27,12 @@ More details:
 
 ## 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 >
@@ -120,13 +44,13 @@ $ ansible-playbook -f 7 -v site.yml
                 ||     ||
 
 
-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:
@@ -141,3 +65,20 @@ $ vagrant ssh mon0 -c "sudo ceph -s"
       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.
+
+
+
index 0331e933711f2d21c4afae826ad7a3e6295ff431..964cc657946f00e92720b4a304a5ca7491b4ac0c 100644 (file)
@@ -1,13 +1,37 @@
 # -*- 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"
@@ -16,7 +40,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
     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}"
@@ -26,7 +50,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
     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}"
@@ -38,6 +62,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
           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
diff --git a/ansible.cfg b/ansible.cfg
new file mode 100644 (file)
index 0000000..8b83ba1
--- /dev/null
@@ -0,0 +1,2 @@
+[defaults]
+ansible_managed = Ansible managed: modified on %Y-%m-%d %H:%M:%S by {uid}
diff --git a/hosts b/hosts
deleted file mode 100644 (file)
index f412060..0000000
--- a/hosts
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-## If you use Vagrant and port forwarding, don't forget to grab the SSH local port of your VMs.
-#
-
-## Common setup example
-#
-[mons]
-ceph-mon0:2200
-ceph-mon1:2201
-ceph-mon2:2202
-[osds]
-ceph-osd0:2203
-ceph-osd1:2204
-ceph-osd2:2205
-[mdss]
-ceph-osd0:2203
-ceph-osd1:2204
-ceph-osd2:2205
-#[rgws]
-#ceph-rgw:2200
-
-# Colocation setup example
-#[mons]
-#ceph-osd0:2222
-#ceph-osd1:2200
-#ceph-osd2:2201
-#[osds]
-#ceph-osd0:2222
-#ceph-osd1:2200
-#ceph-osd2:2201
-#[mdss]
-#ceph-osd0:2222
-#ceph-osd1:2200
-#ceph-osd2:2201
diff --git a/rc b/rc
deleted file mode 100644 (file)
index 8997683..0000000
--- a/rc
+++ /dev/null
@@ -1 +0,0 @@
-export ANSIBLE_CONFIG=.ansible.cfg