Merge ~raharper/cloud-init:snapuser-create into cloud-init:master
| Status: | Merged |
|---|---|
| Merged at revision: | 21632972df034c200578e1fbc121a07f20bb8774 |
| Proposed branch: | ~raharper/cloud-init:snapuser-create |
| Merge into: | cloud-init:master |
| Diff against target: |
753 lines (+600/-15) 8 files modified
cloudinit/config/cc_snap_config.py (+183/-0) cloudinit/config/cc_snappy.py (+4/-14) cloudinit/distros/__init__.py (+35/-0) cloudinit/util.py (+12/-0) config/cloud.cfg (+1/-0) doc/examples/cloud-config-user-groups.txt (+8/-0) tests/unittests/test_distros/test_user_data_normalize.py (+65/-0) tests/unittests/test_handler/test_handler_snappy.py (+292/-1) |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| cloud-init commiters | 2016-09-01 | Pending | |
|
Review via email:
|
|||
Description of the Change
Add support for snap create-user on Ubuntu Core images
Ubuntu Core images use the `snap create-user` to add users to a Ubuntu
Core system. Add support for creating snap users by added a key to
the users dictionary:
users:
- name: bob
snapuser: <email address hidden>
Or via the 'snappy' dictionary:
snappy:
email: <email address hidden>
These methods will contact the Ubuntu SSO infrastructure to request
user information (including public ssh keys if present) for creating
the user.
Users may also create a snap user without contacting the SSO by
providing a 'system-user' assertion by importing them into snapd.
snappy:
email: <email address hidden>
known: true
assertions:
- |
<assertion text here>
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/
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.
- 90577ef... by Ryan Harper on 2016-09-16
| Scott Moser (smoser) wrote : | # |
- ba627b5... by Ryan Harper on 2016-10-06
- e5a6164... by Ryan Harper on 2016-10-06
- 9fb5a34... by Ryan Harper on 2016-10-07
- a9b54d0... by Ryan Harper on 2016-10-07
- 76774db... by Ryan Harper on 2016-10-12
- b543c0f... by Ryan Harper on 2016-10-12
- 3db49a7... by Ryan Harper on 2016-10-13
| Jon Grimm (jgrimm) wrote : | # |
Quick look just because I wanted to know more about the impl.
| Ryan Harper (raharper) wrote : | # |
Thanks for looking at the code!
- a55ae1f... by Ryan Harper on 2016-10-14
| Jon Grimm (jgrimm) wrote : | # |
Thanks, it was enlightening and easy to read.
- 1b96428... by Ryan Harper on 2016-10-14
| Scott Moser (smoser) wrote : | # |
over all, looks good.
you dont have to clean up the handle, but if you see easy way to do that that'd be nice.
is the snappy path now valid on non-snappy system ? (ubuntu server with 'snap' support).
lastly, please just review your commit message and make sure its up to date with all changes (it may well be, just think you made some changes since you wrote it).
| Ryan Harper (raharper) wrote : | # |
On Wed, Oct 19, 2016 at 8:04 AM, Scott Moser <email address hidden> wrote:
> over all, looks good.
> you dont have to clean up the handle, but if you see easy way to do that
> that'd be nice.
>
> is the snappy path now valid on non-snappy system ? (ubuntu server with
> 'snap' support).
>
It is, and util.is_
confirm.
>
>
> lastly, please just review your commit message and make sure its up to
> date with all changes (it may well be, just think you made some changes
> since you wrote it).
>
ACK, it needs updating to account for the snappy: namespace changes.
>
>
> Diff comments:
>
> > diff --git a/cloudinit/
> b/cloudinit/
> > new file mode 100644
> > index 0000000..667b9c6
> > --- /dev/null
> > +++ b/cloudinit/
> > @@ -0,0 +1,177 @@
> > +# vi: ts=4 expandtab
> > +#
> > +# Copyright (C) 2016 Canonical Ltd.
> > +#
> > +# Author: Ryan Harper <email address hidden>
> > +#
> > +# This program is free software: you can redistribute it and/or
> modify
> > +# it under the terms of the GNU General Public License version 3, as
> > +# published by the Free Software Foundation.
> > +#
> > +# This program is distributed in the hope that it will be useful,
> > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > +# GNU General Public License for more details.
> > +#
> > +# You should have received a copy of the GNU General Public License
> > +# along with this program. If not, see <
> http://
> > +
> > +"""
> > +Snappy
> > +------
> > +**Summary:** snap_config modules allows configuration of snapd.
> > +
> > +This module uses the same ``snappy`` namespace for configuration but
> > +acts only only a subset of the configuration.
> > +
> > +If ``assertions`` is set and the user has included a list of assertions
> > +then cloud-init will collect the assertions into a single assertion file
> > +and invoke ``snap ack <path to file with assertions>`` which will
> attempt
> > +to load the provided assertions into the snapd assertion database.
> > +
> > +If ``email`` is set, this value is used to create an authorized user for
> > +contacting and installing snaps from the Ubuntu Store. This is done by
> > +calling ``snap create-user`` command.
> > +
> > +If ``known`` is set to True, then it is expected the user also included
> > +an assertion of type ``system-user``. When ``snap create-user`` is
> called
> > +cloud-init will append '--known' flag which instructs snapd to look for
> > +a system-user assertion with the details. If ``known`` is not set, then
> > +``snap create-user`` will contact the Ubuntu SSO for validating and
> importing
> > +a system-user for the instance.
> > +
> > +.. note::
> > + If the system is already managed, then cloud-init will not attempt
> to
> > + create a system-user.
> > +
> > +**Internal name:** ``cc_snap_config``
> > +
> > +**Module frequency:** per instance
> > +
> > +**Supported distros:** ubuntu
> > +
> > +**Config keys**::
> > +
> > + #cloud-confi...
| Ryan Harper (raharper) wrote : | # |
On Wed, Oct 19, 2016 at 8:52 AM, Ryan Harper <email address hidden>
wrote:
>
>
> On Wed, Oct 19, 2016 at 8:04 AM, Scott Moser <email address hidden> wrote:
>
>> over all, looks good.
>> you dont have to clean up the handle, but if you see easy way to do that
>> that'd be nice.
>>
>> is the snappy path now valid on non-snappy system ? (ubuntu server with
>> 'snap' support).
>>
>
> It is, and util.is_
> confirm.
>
is_system_snappy is looking for 'all-snap' style images; so snaps on
classic don't
respond. We'd need to design something for validating that it works on
snaps on classic
setups.
One key difference is that all-snap systems have non-writable /etc ; where
as snapd on classic doesn't. If we added classic systems to the
is_system_snappy check, then users would get added
to /var/lib/extrausers instead of /etc; I think that's non-optimal and
introduces changes to existing
behavior.
Ryan
- 53d8cb4... by Ryan Harper on 2016-10-19
| Scott Moser (smoser) wrote : | # |
over all, looks good.
you dont have to clean up the handle, but if you see easy way to do that that'd be nice.
is the snappy path now valid on non-snappy system ? (ubuntu server with 'snap' support).
lastly, please just review your commit message and make sure its up to date with all changes (it may well be, just think you made some changes since you wrote it).
- a353f18... by Ryan Harper on 2016-10-20
| Scott Moser (smoser) wrote : | # |
I merged this.
Had to fix flake8 tox and made one code change. basically in add_snap_user i returned if there was no 'email' and then un-indented the rest of that block.


Is this still needed or desired ?