diff options
author | Ryan Harper <ryan.harper@canonical.com> | 2016-09-01 15:49:20 -0500 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2016-10-20 15:40:36 -0400 |
commit | d8534561ba76db25b6fc0044eb1bfda63686e859 (patch) | |
tree | f0dce5f0ab4a3dcf1a1bceb49b387628cfc98c14 /cloudinit/util.py | |
parent | ba0adb9b5100735358a76fdee7b251dba224a4cd (diff) | |
download | vyos-cloud-init-d8534561ba76db25b6fc0044eb1bfda63686e859.tar.gz vyos-cloud-init-d8534561ba76db25b6fc0044eb1bfda63686e859.zip |
Add support for snap create-user on Ubuntu Core images.
Ubuntu Core images use the `snap create-user` to add users to an
Ubuntu Core system. Add support for creating snap users by adding
a key to the users dictionary.
users:
- name: bob
snapuser: bob@bobcom.io
Or via the 'snappy' dictionary:
snappy:
email: bob@bobcom.io
Users may also create a snap user without contacting the SSO by
providing a 'system-user' assertion by importing them into snapd.
Additionally, Ubuntu Core systems have a read-only /etc/passwd such that
the normal useradd/groupadd commands do not function without an additional
flag, '--extrausers', which redirects the pwd to /var/lib/extrausers.
Move the system_is_snappy() check from cc_snappy module to util for
re-use and then update the Distro class to append '--extrausers' if
the system is Ubuntu Core.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 4cff83c5..4b3fd0cb 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -2374,3 +2374,15 @@ def get_installed_packages(target=None): pkgs_inst.add(re.sub(":.*", "", pkg)) return pkgs_inst + + +def system_is_snappy(): + # channel.ini is configparser loadable. + # snappy will move to using /etc/system-image/config.d/*.ini + # this is certainly not a perfect test, but good enough for now. + content = load_file("/etc/system-image/channel.ini", quiet=True) + if 'ubuntu-core' in content.lower(): + return True + if os.path.isdir("/etc/system-image/config.d/"): + return True + return False |