Sadly, passing an alternative config file to apt using -o CLI options
does not work because apt:
1) Reads the configuration file first
2) Reads CLI options (and override specified settings) second
Therefore, the default configuration file is always read, instead of the
one we supply.
To specify an alternative configuration file, the recommendation from
the apt maintainer is to supply an APT_CONFIG variable, hinting apt to
read said file instead of the default.
We now generate a temporary file, write the directives we need to it
using the python apt library, and then execute apt-get with a path to
this temporary file set in APT_CONFIG.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
AD is by nature an optional feature.
Yet, we need to make its model part of the POSTINSTALL_MODEL_NAMES set.
That would turn this into a required controller.
Thus, explicitly mark AD as configured
For as long as TUI doesn't have a matching controller.
In LP: #2008271, an invalid but reasonable-looking layout was supplied
in autoinstall, which makes it all the way to curthooks before failing
with an inscruitble and difficult to find error from ckbcomp.
Validate ahead of time these values.
Even though AD joining is not that critical.
I noticed in lab higher success rates when not specifying the computer
name option in realm join CLI.
But I'm not convident enough to say that this would behave better than
Ubiquity's original implementation, which does use the computer name
option.
It turns out that the `realm --install /target` does a chroot.
So curtin in target command is not necessary for that.
The same doesn't hold for pam-auth-update.
Setting hostnames is still a requirement, because realm calls adcli
under the hood, which doesn't go through chroot.
There is a quite non-straightforward sequencing between the AD
controller and Joiner classes.
A client may do a blocking call to join_result_GET at any moment.
It should only be blocking if the ADModel is set.
Curtin commands are not tested here, though.
AD controller offers the blockign endpoint.
AD Joiner creates a task when the AD Controller join_domain() is called.
Install controller requests that in the end of the post install method.
AD Controller calls itself on dry run for testing purposes
TODO:
- refine tests;
- do the real join.
Network manager can create routes at metric aka priority above 20000.
These can stick around if they are not the best choice, or they may
disappear quickly.
Do not consider one of these routes as a valid default route for
has_network purposes.
The existing event based method of watching for has_network has a flaw.
The incoming route_change events from probert do not distinguish routes
on the same interface but a different metric, so if 2 routes on one
interface appear, we only get one event. Then if one of those routes is
removed, we will inappropriately remove this route from the
default_routes list.
Aside from the code watching the event stream, the set of default routes
is an elaborate boolean value.
Simplify the code by passing around a boolean, and when we get a
route_change event, use that to go looking again at the list of default
routes.
LP: #2004659