]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-daemon: default output file names
authorSage Weil <sage@redhat.com>
Sun, 17 Nov 2019 23:49:21 +0000 (17:49 -0600)
committerSage Weil <sage@redhat.com>
Sun, 17 Nov 2019 23:50:13 +0000 (17:50 -0600)
- These are reasonable names that a user would probably want
- If they run bootstrap in /etc/ceph then they are already installed in
  the right location
- This means that the bootstrap command has only 1 (!) required argument
  (--mon-ip or equivalent)

Signed-off-by: Sage Weil <sage@redhat.com>
doc/bootstrap.rst
src/ceph-daemon/ceph-daemon
test_ceph_daemon.sh

index f3032c397101dffbf00159c5ff4fce364faedc89..8c51d7a885a7e51f0ef545d42455c436ca7534b4 100644 (file)
@@ -35,7 +35,7 @@ To create a new cluster, you need to know:
 
 To bootstrap the cluster,::
 
-  sudo ceph-daemon bootstrap --mon-ip *<mon-ip>* --output-config ceph.conf --output-keyring ceph.keyring --output-pub-ssh-key ceph.pub
+  sudo ceph-daemon bootstrap --mon-ip *<mon-ip>*
 
 This command does a few things:
 
@@ -43,7 +43,7 @@ This command does a few things:
   local host.  A minimal configuration file needed to communicate with
   the new cluster is written to ``ceph.conf`` in the local directory.
 * A copy of the ``client.admin`` administrative (privileged!) secret
-  key is written to ``ceph.keyring`` in the local directory.
+  key is written to ``ceph.client.admin.keyring`` in the local directory.
 * Generates a new SSH key, and adds the public key to the local root user's
   ``/root/.ssh/authorized_keys`` file.  A copy of the public key is written
   to ``ceph.pub`` in the local directory.
index 095eacd6289cf13d1558c1943fe6197c563fbc64..f2646633796af9a8966a33e916f572764b3d777a 100755 (executable)
@@ -876,6 +876,15 @@ def command_version():
 
 def command_bootstrap():
     # type: () -> int
+
+    # verify output files
+    if not args.allow_overwrite:
+        for f in [args.output_config, args.output_keyring, args.output_pub_ssh_key]:
+            if os.path.exists(f):
+                raise RuntimeError('%s already exists; delete or pass '
+                                   '--allow-overwrite to overwrite' % f)
+
+    # initial vars
     fsid = args.fsid or make_fsid()
     hostname = get_hostname()
     mon_id = args.mon_id or hostname
@@ -1103,16 +1112,15 @@ def command_bootstrap():
                  '[client.crash.%s]\n\tkey = %s\n' % (hostname, crash_key))
 
     # output files
-    if args.output_keyring:
-        with open(args.output_keyring, 'w') as f:
-            os.fchmod(f.fileno(), 0o600)
-            f.write('[client.admin]\n'
-                    '\tkey = ' + admin_key + '\n')
-        logger.info('Wrote keyring to %s' % args.output_keyring)
-    if args.output_config:
-        with open(args.output_config, 'w') as f:
-            f.write(config)
-        logger.info('Wrote config to %s' % args.output_config)
+    with open(args.output_keyring, 'w') as f:
+        os.fchmod(f.fileno(), 0o600)
+        f.write('[client.admin]\n'
+                '\tkey = ' + admin_key + '\n')
+    logger.info('Wrote keyring to %s' % args.output_keyring)
+
+    with open(args.output_config, 'w') as f:
+        f.write(config)
+    logger.info('Wrote config to %s' % args.output_config)
 
     logger.info('Waiting for mgr to start...')
     while True:
@@ -1139,10 +1147,9 @@ def command_bootstrap():
         tmp_pub.write(ssh_pub)
         tmp_pub.flush()
 
-        if args.output_pub_ssh_key:
-            with open(args.output_pub_ssh_key, 'w') as f:
-                f.write(ssh_pub)
-            logger.info('Wrote public SSH key to to %s' % args.output_pub_ssh_key)
+        with open(args.output_pub_ssh_key, 'w') as f:
+            f.write(ssh_pub)
+        logger.info('Wrote public SSH key to to %s' % args.output_pub_ssh_key)
 
         cli([
             'config-key',
@@ -1205,12 +1212,12 @@ def command_bootstrap():
                         args.initial_dashboard_user,
                         password))
 
-    if args.output_config and args.output_keyring:
-        logger.info('You can access the Ceph CLI with:\n\n'
-                    '\tsudo %s shell -c %s -k %s\n' % (
-                        sys.argv[0],
-                        args.output_config,
-                        args.output_keyring))
+    logger.info('You can access the Ceph CLI with:\n\n'
+                '\tsudo %s shell -c %s -k %s\n' % (
+                    sys.argv[0],
+                    args.output_config,
+                    args.output_keyring))
+
     logger.info('Bootstrap complete.')
     return 0
 
@@ -1826,12 +1833,15 @@ def _get_parser():
         help='cluster FSID')
     parser_bootstrap.add_argument(
         '--output-keyring',
+        default='ceph.client.admin.keyring',
         help='location to write keyring file with new cluster admin and mon keys')
     parser_bootstrap.add_argument(
         '--output-config',
+        default='ceph.conf',
         help='location to write conf file to connect to new cluster')
     parser_bootstrap.add_argument(
         '--output-pub-ssh-key',
+        default='ceph.pub',
         help='location to write the cluster\'s public SSH key')
     parser_bootstrap.add_argument(
         '--skip-ssh',
@@ -1860,6 +1870,10 @@ def _get_parser():
         '--skip-pull',
         action='store_true',
         help='do not pull the latest image before bootstrapping')
+    parser_bootstrap.add_argument(
+        '--allow-overwrite',
+        action='store_true',
+        help='allow overwrite of existing --output-* config/keyring/ssh files')
 
     parser_deploy = subparsers.add_parser(
     'deploy', help='deploy a daemon')
index ed697530e6f0eecf0e0e6280d16c8b4921668f11..5da07986ce459d4b38ea96f366d61aa6896582a7 100755 (executable)
@@ -24,7 +24,8 @@ $CEPH_DAEMON $A \
     --mon-ip $ip \
     --config c \
     --output-keyring k \
-    --output-config c
+    --output-config c \
+    --allow-overwrite
 chmod 644 k c
 
 if [ -n "$ip2" ]; then