]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add --single-host-defaults option to bootstrap
authorSage Weil <sage@newdream.net>
Mon, 12 Apr 2021 15:51:33 +0000 (11:51 -0400)
committerSage Weil <sage@newdream.net>
Tue, 4 May 2021 16:15:59 +0000 (11:15 -0500)
[global] osd_crush_choose_leaf_type = 0
[global] osd_pool_default_size = 2
[mgr] mgr_standby_modules = false

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit ae899d37692284c7991229a7a47a2fce1bfbeca7)

src/cephadm/cephadm

index 0bf5b34bc819a5a883938756fe7997c85588f1df..f55cc8f81efae17ecc186a59ee5b73f77e12feb0 100755 (executable)
@@ -3839,6 +3839,7 @@ def prepare_bootstrap_config(
     cp.set('global', 'fsid', fsid)
     cp.set('global', 'mon_host', mon_addr)
     cp.set('global', 'container_image', image)
+
     if not cp.has_section('mon'):
         cp.add_section('mon')
     if (
@@ -3846,6 +3847,30 @@ def prepare_bootstrap_config(
             and not cp.has_option('mon', 'auth allow insecure global id reclaim')
     ):
         cp.set('mon', 'auth_allow_insecure_global_id_reclaim', 'false')
+
+    if ctx.single_host_defaults:
+        logger.info('Adjusting default settings to suit single-host cluster...')
+        # replicate across osds, not hosts
+        if (
+                not cp.has_option('global', 'osd_crush_choose_leaf_type')
+                and not cp.has_option('global', 'osd crush choose leaf type')
+        ):
+            cp.set('global', 'osd_crush_choose_leaf_type', '0')
+        # replica 2x
+        if (
+                not cp.has_option('global', 'osd_pool_default_size')
+                and not cp.has_option('global', 'osd pool default size')
+        ):
+            cp.set('global', 'osd_pool_default_size', '2')
+        # disable mgr standby modules (so we can colocate multiple mgrs on one host)
+        if not cp.has_section('mgr'):
+            cp.add_section('mgr')
+        if (
+                not cp.has_option('mgr', 'mgr_standby_modules')
+                and not cp.has_option('mgr', 'mgr standby modules')
+        ):
+            cp.set('mgr', 'mgr_standby_modules', 'false')
+
     cpf = StringIO()
     cp.write(cpf)
     config = cpf.getvalue()
@@ -7771,6 +7796,10 @@ def _get_parser():
     parser_bootstrap.add_argument(
         '--cluster-network',
         help='subnet to use for cluster replication, recovery and heartbeats (in CIDR notation network/mask)')
+    parser_bootstrap.add_argument(
+        '--single-host-defaults',
+        action='store_true',
+        help='adjust configuration defaults to suit a single-host cluster')
 
     parser_deploy = subparsers.add_parser(
         'deploy', help='deploy a daemon')