summaryrefslogtreecommitdiff
path: root/cloudinit/distros/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/distros/__init__.py')
-rw-r--r--cloudinit/distros/__init__.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index 13e4fd44..4cf8f745 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -507,13 +507,20 @@ def _normalize_users(u_cfg, def_user_cfg=None):
def normalize_users_groups(cfg, distro):
+ if not cfg:
+ cfg = {}
users = {}
groups = {}
if 'groups' in cfg:
groups = _normalize_groups(cfg['groups'])
+
+ # Handle the previous style of doing this...
old_user = None
- if 'user' in cfg:
+ if 'user' in cfg and cfg['user']:
old_user = str(cfg['user'])
+ if not 'users' in cfg:
+ cfg['users'] = old_user
+ old_user = None
if 'users' in cfg:
default_user_config = None
try:
@@ -527,7 +534,7 @@ def normalize_users_groups(cfg, distro):
# The old user replaces user[0]
base_users[0] = {'name': old_user}
elif not base_users and old_user:
- base.append({'name': old_user})
+ base_users.append({'name': old_user})
elif isinstance(base_users, (dict)):
# Sorry order not possible
if old_user and old_user not in base_users: