Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experimental import of existing cluster
Here's the idea: - Install DeepSea on some node (your salt master). - Install salt-minion on every existing ceph node - Hook up the minions to the masters as usual. - Run the prep and discovery stages (hoping that prep doesn't do anything annoying like install updates and reboot half your cluster). - Now you've got all possible roles and hardware profiles that DeepSea would have come up with when given a clean slate. - Run `salt-run populate.engulf_existing_cluster`. This will generate a policy.cfg with roles matching whatever was discovered running on all those ceph nodes. Any node running a mon will have role-mon. Any node running rgw will have role-rgw, etc. Any node with the client admin keyring will have role-admin. To be clear, I'm presently just trying to get a feel for the shape of this thing. The current implementation will *not* assign hardware profiles for storage nodes. Don't expect this to give you a working cluster. In fact, if you run it on a working cluster, then proceed with the configure, deploy and services stages, you should expect to have a broken cluster immediately thereafter. There's a huge list of missing things, including but not limited to: - Verify the cluster is actually healthy and everything is running first. Ensure none of the config is inconsistent. - Get the existing cluster's fsid, network settings and any custom config. - Generate storage/hardware profiles to match what's deployed - Save the existing daemon keys rather than generating new ones - Invoke engulf_existing_cluster automatically during discovery if and only if there's no policy.cfg already and a cluster is detected (maybe). - Test on every possible imaginable cluster to make sure it's not going to do anything stupid. - Check for ALL the errors. Signed-off-by: Tim Serong <tserong@suse.com>
- Loading branch information
Showing
3 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ts=8 et sw=4 sts=4 | ||
|
||
import os | ||
|
||
def _extract_key(filename): | ||
# This is pretty similar to keyring.secret()... | ||
if os.path.exists(filename): | ||
with open(filename, 'r') as keyring: | ||
for line in keyring: | ||
if "key" in line and " = " in line: | ||
return line.split(" = ")[1].strip() | ||
return "" | ||
|
||
def inspect(**kwargs): | ||
# deliberately only looking for things ceph-deploy can deploy | ||
ceph_services = ['ceph-mon', 'ceph-osd', 'ceph-mds', 'ceph-radosgw'] | ||
|
||
# | ||
# running_services will be something like: | ||
# | ||
# { | ||
# 'ceph-mon': [ 'hostname' ], | ||
# 'ceph-osd': [ '0', '1', '2', ... ] | ||
# } | ||
# | ||
running_services = {} | ||
for rs in __salt__['service.get_running'](): | ||
instance = rs.split('@') | ||
if len(instance) == 2 and instance[0] in ceph_services: | ||
if not running_services.has_key(instance[0]): | ||
running_services[instance[0]] = [] | ||
running_services[instance[0]].append(instance[1]) | ||
|
||
ceph_keys = {} | ||
|
||
ceph_keys["ceph.client.admin"] = _extract_key("/etc/ceph/ceph.client.admin.keyring") | ||
ceph_keys["bootstrap-osd"] = _extract_key("/var/lib/ceph/bootstrap-osd/ceph.keyring") | ||
|
||
if "ceph-mon" in running_services.keys(): | ||
ceph_keys["mon"] = _extract_key("/var/lib/ceph/mon/ceph-" + running_services["ceph-mon"][0] + "/keyring") | ||
|
||
# TODO: something similar to the above for MDS and RGW keys (but be aware | ||
# there might be multiple instances. Hell, there could be multiple instances | ||
# for MONs too on one host, if someone has set up something really weird... | ||
|
||
# note that some keys will be empty strings if not present | ||
return { | ||
"running_services": running_services, | ||
"ceph_keys": ceph_keys | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters