Configure apt environment based on bootstrap environment choice#1392
Configure apt environment based on bootstrap environment choice#1392rocodes wants to merge 6 commits intofeat/sdw-keyring-compatfrom
Conversation
aac4d00 to
e468b35
Compare
dde0a4c to
4c2c82d
Compare
|
(triggered openqa, will rebase once #1210 is merged then mark ready for review) |
597582e to
03dff50
Compare
03dff50 to
7e70c5c
Compare
…ing key and repo urls.
7e70c5c to
3556876
Compare
legoktm
left a comment
There was a problem hiding this comment.
Overall it looks good, most of my comments are related to the tests.
| ### BEGIN TESTS ### | ||
|
|
||
| # Get config, needed for test | ||
| ENV, CONFIG = _get_expected_config() |
There was a problem hiding this comment.
Let's turn these into pytest fixtures.
| return key_info | ||
|
|
||
|
|
||
| def _validate_key(info: dict, expected_fpr: str, expected_uid: str, expected_expiry: str): |
There was a problem hiding this comment.
instead of checking things and raising exceptions, I think we can just use normal pytest assertions
| def test_key_apt_sources(): | ||
| """Check the key in the apt_sources file used for provisioning Debian-based templates.""" | ||
| app = Qubes() | ||
| for template in ["small", "large"]: |
| CONFIG["signing_key_uid"], | ||
| CONFIG["signing_key_exp"], | ||
| ) | ||
| except ValueError as e: |
There was a problem hiding this comment.
Above I suggested using assertions in _read_and_validate_key so then we don't need to catch exception and then immediately fail. Plus if we use parameterization then the test name will also have the VM name.
|
|
||
| # Append repo URL with appropriate distribution | ||
| {% set _ = sdvars.update({"distribution": "bookworm"}) %} | ||
| {% set apt_config = environments.get(env) %} |
There was a problem hiding this comment.
I'm wondering if we just leave this called sdvars even though it's different, just to cut down on the number of salt files modified in this PR that are entirely just s/sdvars/apt_config/.
There was a problem hiding this comment.
It's up to you, but I just found sdvars such a confusing/nondescriptive name that it seemed like this would be long-term easier to understand.
| - qvm: dom0-install-debian-minimal-template | ||
|
|
||
| # Store signing key in salt cache so that it can later be provisioned to templates in their apt-sources files. | ||
| # Using cp.push or cp.cache_file don't work due to the minion-minion setup. |
There was a problem hiding this comment.
Sorry, this is going over my head. Why can't the step in fpf-apt-repo.sls just read the original apt_config['keyfile']?
There was a problem hiding this comment.
apt_config['keyfile'] is a reference to the signing key in /etc/pki in dom0, and which one it is depends on the keyring package (test key or real release key).
The fpf-apt-repo.sls steps are run on the Debian VMs, but the bootstrap keyring files live in dom0.
The debian vms have access to /srv/salt (as salt://) and to the cache dir but not to dom0 files, so somewhere in a state that's run on dom0 (I just picked this file for simplicity since then we only do it once, at initial provisioning time, and after that the key is managed via the keyring package), we cache the key, and then the VMs can read it.
There was a problem hiding this comment.
Gotcha, appreciate the explanation. How about:
# Debian VMs need access to the signing key for initial provisioning, store it in salt cache since they
# only have access to the cache and `/srv/salt`, not all of dom0.
# Using cp.push or cp.cache_file don't work due to the minion-minion setup.
| return False | ||
|
|
||
|
|
||
| # A bit clunky, but we have limited tooling options in dom0. |
There was a problem hiding this comment.
Cursed but if it works, it works :)
Could you add an explicit TODO: use sequoia here instead - I think we can do that once we're on 4.3.
3556876 to
bd921d6
Compare
bd921d6 to
daf10a2
Compare
…y shipped to dom0 in /etc/pki from securedrop-workstation-keyring. Key must be cached by dom0 and retrieved by the vm. Consolidate all apt repo configuration into sd-default-config.sls (delete sd-default-config.yml). Rename sdvars to apt_config for clarity.
daf10a2 to
c8a9ccf
Compare
5c0d7b8 to
f44bbc3
Compare
…he keyring is used consistently across yum and apt components. Move test_sources functionality out of launcher tests. Deprecate skip_in_dom0 conftest annotation.
…bootstrap is complete
…dd it to bootstrap target openqa
510a4bb to
ecef9c2
Compare
|
The CI failure shows that the installation is looking for the prod key, when it should be looking for the test key. Here's why: sd-default-config.sls file correctly selects the apt configuration we want when it's run on dom0, but even when it's imported |
|
The right solution is to use pillars #1053, which is how Saltstack handles configurable data, and what the qubes team uses. It's possible to have dev- or staging- only pillar files that don't ship with the prod rpm (for example, that are installed into place when a developer runs a make target), and that can optionally override prod defaults. It's possible to use pillars conservatively/only for the dev and staging setups, leaving all prod stuff defined in the sls files in /srv/salt. Then, for example, if a pillar file is available (because devs installed it - it wouldn't be shipped with the prod rpm), the prod repo data could be overridden with apt-test, or as we switch to new Debian versions, the apt-sources file could contain an new testing repo with another distribution, etc. (This is what whonix does with their testing pillar). It's also possible to move more of our configuration to pillars, eg and ship a file in I'm saying all this because someone else will probably have to pick this up if it's a priority due to the upcoming changes in my schedule. I'm going to reluctantly close this ticket; I think it would take a pretty short amount of time if we were just converting sd-default-config to prod by default plus an optional dev configuration on top, and I'm not thrilled about leaving things in a halfway state, but it's not something I can finish off in the next day or so. |
Ready for a look, depends on #1210 [edit: merged!]
Fixes #1058
Fixes #1232
Refs #1053 (can supersede/close with another approach in a followup PR)
Use bootstrap rpm instead of config.json to decide what environment (dev, staging, prod) we're using.
Test plan
feat/sdw-keyring-compatChecklist
This change accounts for:
MANIFEST.inandrpm-build/SPECS/securedrop-workstation-dom0-config.spec)