yaml: catch and surface errors with the yaml installation
When working on the fix of LP #2007241 and LP #2007234, some logic was
implemented to import only the system-installed yaml package. However,
after further discussion, the team, with the help of reviewers,
concluded that this is indeed an error, and should be just treated
correctly to avoid a crash (and consequently an oops report).
This commit substitutes the previous logic with two exception handlers:
one for the missing yaml package, another for any yaml package which
cannot perform the basic operations we need.
Since we are now migrating some of the uaclient.conf items
into a different file, we are also leaving a backup file
behind, uaclient.conf.dpkg-bak, in case the user has made some
comments on the original config file. This will allow the
user to retrieve those comments if needed
Some apt functions require us to change the global apt config.
Since we might be changing behavior on other parts of the code
that require apt functionality, we are now using a context manager
to guarantee that the original system config is kept after
we call an apt function