Commits

Mikhail Korobov committed ce3e415

DB_ROOT_PASSWORD handling is fixed

Comments (0)

Files changed (1)

fab_deploy/utils.py

         to = base_dir + name
     config_template = _config_template_path(name)
 
-    if config_template is None and skip_unexistent:
-        return
-    elif config_template is None:
-        operations._handle_failure('Config template "%s" not found' % name)
+    if config_template is None:
+        if skip_unexistent:
+            return
+        operations._handle_failure('Config template "%s" is not found' % name)
 
     files.upload_template(config_template, to, env.conf, use_jinja=True,
                           **kwargs)
     env.conf = getattr(env, 'conf', {})
     env.conf.setdefault('INSTANCE_NAME', user)
     env.conf.setdefault('PROJECT_PATH', '')
-    if env.conf.get('DB_USER') == 'root':
-        env.conf.setdefault('DB_ROOT_PASSWORD', env.conf.get('DB_PASSWORD'))
 
     HOME_DIR = '/home/%s' % user
     SRC_DIR = posixpath.join(HOME_DIR, 'src', env.conf['INSTANCE_NAME'])
 
     env.conf = defaults
 
+    if env.conf.DB_USER == 'root':
+        if 'DB_ROOT_PASSWORD' in env.conf and 'DB_PASSWORD' in env.conf:
+            msg = "DB_ROOT_PASSWORD and DB_PASSWORD must be the same because DB_USER is root"
+            assert env.conf.DB_ROOT_PASSWORD == env.conf.DB_PASSWORD, msg
+        else:
+            # auto-fill the missing option
+            password = env.conf.get('DB_ROOT_PASSWORD', env.conf.DB_PASSWORD)
+            env.conf.DB_PASSWORD = env.conf.DB_ROOT_PASSWORD = password
+
     for vcs in ['git', 'hg', 'none']: # expand VCS name to full import path
         if env.conf.VCS == vcs:
             env.conf.VCS = 'fab_deploy.vcs.' + vcs