← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~harlowja/cloud-init/default-ug-config-not-code into lp:cloud-init

 

Joshua Harlow has proposed merging lp:~harlowja/cloud-init/default-ug-config-not-code into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~harlowja/cloud-init/default-ug-config-not-code/+merge/125611

Use config not code.
-- 
https://code.launchpad.net/~harlowja/cloud-init/default-ug-config-not-code/+merge/125611
Your team cloud init development team is requested to review the proposed merge of lp:~harlowja/cloud-init/default-ug-config-not-code into lp:cloud-init.
=== modified file 'cloudinit/distros/__init__.py'
--- cloudinit/distros/__init__.py	2012-09-18 17:27:41 +0000
+++ cloudinit/distros/__init__.py	2012-09-21 00:33:00 +0000
@@ -44,10 +44,7 @@
 
 
 class Distro(object):
-
     __metaclass__ = abc.ABCMeta
-    default_user = None
-    default_user_groups = None
 
     def __init__(self, name, cfg, paths):
         self._paths = paths
@@ -61,7 +58,6 @@
 
         user = self.get_default_user()
         groups = self.get_default_user_groups()
-
         if not user:
             raise NotImplementedError("No Default user")
 
@@ -71,12 +67,12 @@
                     'home': "/home/%s" % user,
                     'shell': "/bin/bash",
                     'lock_passwd': True,
-                    'gecos': "%s%s" % (user[0:1].upper(), user[1:]),
+                    'gecos': user.title(),
                     'sudo': "ALL=(ALL) NOPASSWD:ALL",
                     }
 
         if groups:
-            user_dict['groups'] = groups
+            user_dict['groups'] = ",".join(groups)
 
         self.create_user(**user_dict)
 
@@ -212,10 +208,10 @@
             return False
 
     def get_default_user(self):
-        return self.default_user
+        return self.get_option('default_user')
 
     def get_default_user_groups(self):
-        return self.default_user_groups
+        return self.get_option('default_user_groups')
 
     def create_user(self, name, **kwargs):
         """

=== modified file 'cloudinit/distros/fedora.py'
--- cloudinit/distros/fedora.py	2012-09-17 18:23:51 +0000
+++ cloudinit/distros/fedora.py	2012-09-21 00:33:00 +0000
@@ -28,5 +28,4 @@
 
 
 class Distro(rhel.Distro):
-    distro_name  = 'fedora'
-    default_user = 'ec2-user'
+    pass

=== modified file 'cloudinit/distros/ubuntu.py'
--- cloudinit/distros/ubuntu.py	2012-08-31 21:45:15 +0000
+++ cloudinit/distros/ubuntu.py	2012-09-21 00:33:00 +0000
@@ -28,8 +28,5 @@
 
 
 class Distro(debian.Distro):
+    pass
 
-    distro_name = 'ubuntu'
-    default_user = 'ubuntu'
-    default_user_groups = ("adm,audio,cdrom,dialout,floppy,video,"
-                            "plugdev,dip,netdev,sudo")

=== modified file 'config/cloud.cfg'
--- config/cloud.cfg	2012-09-19 09:07:24 +0000
+++ config/cloud.cfg	2012-09-21 00:33:00 +0000
@@ -1,7 +1,9 @@
 # The top level settings are used as module
 # and system configuration.
 
-# Implement for Ubuntu only: create the default 'ubuntu' user
+# A set of users which may be applied and/or used by various modules
+# when a 'default' entry is found it will reference the 'default_user'
+# from the distro configuration specified below
 users:
    - default
 
@@ -71,6 +73,19 @@
 system_info:
    # This will affect which distro class gets used
    distro: ubuntu
+   # Default user name + that default users groups (if added/used)
+   default_user: ubuntu
+   default_user_groups: 
+     - adm
+     - audio
+     - cdrom
+     - dialout
+     - floppy
+     - video
+     - plugdev
+     - dip
+     - netdev
+     - sudo
    # Other config here will be given to the distro class and/or path classes
    paths:
       cloud_dir: /var/lib/cloud/