diff options
Diffstat (limited to 'cloudinit/config/cc_users_groups.py')
-rw-r--r-- | cloudinit/config/cc_users_groups.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/cloudinit/config/cc_users_groups.py b/cloudinit/config/cc_users_groups.py index a6ce49ac..13eb1102 100644 --- a/cloudinit/config/cc_users_groups.py +++ b/cloudinit/config/cc_users_groups.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from cloudinit import distros from cloudinit import util from cloudinit.settings import PER_INSTANCE @@ -24,10 +25,20 @@ frequency = PER_INSTANCE def handle(name, cfg, cloud, log, _args): - distro = cloud.distro - ((users, default_user), groups) = distro.normalize_users_groups(cfg) + def_u = None + def_u_gs = None + try: + def_u = cloud.distro.get_default_user() + def_u_gs = cloud.distro.get_default_user_groups() + except NotImplementedError: + log.warn(("Distro has not implemented default user " + "creation. No default user will be added.")) + + ((users, default_user), groups) = distros.normalize_users_groups(cfg, + def_u, + def_u_gs) for (name, members) in groups.items(): - distro.create_group(name, members) + cloud.distro.create_group(name, members) if default_user: user = default_user['name'] @@ -41,8 +52,8 @@ def handle(name, cfg, cloud, log, _args): 'sudo': "ALL=(ALL) NOPASSWD:ALL", } u_config = util.mergemanydict([def_base_config, config]) - distro.create_user(user, **u_config) + cloud.distro.create_user(user, **u_config) log.info("Added default '%s' user with passwordless sudo", user) for (user, config) in users.items(): - distro.create_user(user, **config) + cloud.distro.create_user(user, **config) |