Commit Graph

1602 Commits

Author SHA1 Message Date
Jörg Thalheim
160fe82576 fix serialisation of SopsKey type 2024-10-04 15:36:30 +00:00
Jörg Thalheim
9c25b4d61c error if we cannot load a dataclass from file 2024-10-04 15:36:30 +00:00
Jörg Thalheim
ca4ff0611c default key type to age and rename to age-key/pgp-key 2024-10-04 15:36:30 +00:00
Jörg Thalheim
4cd4334b1c secrets: do not shadow python builtins 2024-10-04 15:36:30 +00:00
Louis Opter
d18c0fa3ae Fix: do not assume users use age keys in vars/sops
With added support for PGP for users keys, do not assume an age key is
going to be present in secrets files.
2024-10-04 15:36:30 +00:00
Louis Opter
b2e796145a Fix: use new sops api in clan secrets machines 2024-10-04 15:36:30 +00:00
Louis Opter
7a673ea95f Draft: clan-cli: secrets: Add support for PGP keys with sops-nix
To use a PGP key instead of an age key you can set `SOPS_PGP_FP`. (You
can use `gpg -k --fingerprint --fingerprint` to get your PGP encryption
key fingerprint, remove spaces from it).

The internal manifest file already supported a type field, and so I built
from there.

With those changes, I was able to add my PGP key, and update all my
secrets with it, instead of the age key originally generated:

```
% clan secrets key show | jq
{
  "key": "ADB6276965590A096004F6D1E114CBAE8FA29165",
  "type": "pgp"
}
% clan secrets key update
% for s in $(clan secrets list) ; do clan secrets users add-secret kal-pgp-from-2022-12-to-2024-12 "$s"; done
% for s in $(clan secrets list) ; do clan secrets users remove-secret --debug kal "$s" ; done
```
2024-10-04 15:36:30 +00:00
DavHau
11c37ebeba vars/keygen: fix + cleanup tests
- generate keys in ./sops instead of ./sops/vars for now
- don't initialize all flakes with sops keys, only generate when needed
- use the new 'clan vars keygen' in tests
2024-10-04 17:25:17 +02:00
DavHau
2a9ced1e26 vars: add 'clan vars keygen' 2024-10-04 16:13:49 +02:00
DavHau
ae53ea7399 vars: refactor - copy logic to sops secret module
This is in preparation for moving the storage away from ./sops to ./vars/sops
2024-10-04 14:31:22 +02:00
DavHau
4a0207f0b3 sops: refactor some function names for clarity 2024-10-02 13:56:43 +02:00
Johannes Kirschbauer
536ae8701d Inventory/docs: display explizit roles only 2024-10-02 10:01:44 +02:00
Jörg Thalheim
ca8f36201b test superflous test_vm_qmp
we already have other tests covering this and VMs + NixOS are slow
2024-10-01 20:57:07 +02:00
Jörg Thalheim
27b1aeb827 add temp_dir fixture 2024-10-01 20:54:19 +02:00
Jörg Thalheim
4826582547 add more custom prefixes for temporary directories 2024-10-01 20:54:19 +02:00
Jörg Thalheim
196f78d2da abort tests on python warning 2024-10-01 20:54:19 +02:00
Jörg Thalheim
8b205c78bf fix resource leaks in qmp tests 2024-10-01 20:54:19 +02:00
clan-bot
2f38955066 Merge pull request 'fix resource leaks' (#2191) from fix-warning into main 2024-10-01 18:03:58 +00:00
Jörg Thalheim
4207aef029 don't leak memory in global table unless we want to record performance 2024-10-01 19:32:00 +02:00
Jörg Thalheim
13aed0792e fix file descriptor leak in cmd.run()
we were leaking pipes.
2024-10-01 19:27:47 +02:00
clan-bot
a57f409224 Merge pull request 'generate: don't set type=bool in argparse.BooleanOptionalAction' (#2190) from fix-warning into main 2024-10-01 17:04:49 +00:00
Jörg Thalheim
f9a42831e4 start to name temporary directories in more places 2024-10-01 18:57:59 +02:00
Jörg Thalheim
a5e18fda08 generate: don't set type=bool in argparse.BooleanOptionalAction 2024-10-01 18:48:54 +02:00
Louis Opter
3f2bb2b958 Update outdated help messages and fix a typo 2024-09-29 15:52:58 +00:00
Jörg Thalheim
62af2bab55 fix broken eval check when nixpkgs.pkgs nixos option is used 2024-09-29 16:59:02 +02:00
Jörg Thalheim
9cf2bd4f6e make default hardware report commit message nicer 2024-09-29 16:59:02 +02:00
Jörg Thalheim
bf7246104d allow to overwrite hardware configuration
now that we call it "update" hardware configurration and we are heading
towards facter anyway, we don't need all the force overide logic. Just
allow this to be overwritten by default.
2024-09-29 16:59:02 +02:00
Jörg Thalheim
b4652539a5 wrap hardware generate arguments into an object 2024-09-29 16:59:02 +02:00
Jörg Thalheim
7816a3e639 don't expose polymorphic api 2024-09-29 16:21:53 +02:00
Jörg Thalheim
372a5f3907 remove unused location from ClanError 2024-09-29 16:21:53 +02:00
Jörg Thalheim
1940880dcb put error description in same line as error for cli 2024-09-29 16:21:53 +02:00
Jörg Thalheim
1e11cd79c4 if error doesn't have a message set, print a stack trace 2024-09-29 16:21:53 +02:00
Jörg Thalheim
84383a4a48 if command fails, print command and exit code, regardless if error message is set 2024-09-29 16:21:53 +02:00
Jörg Thalheim
07e031f256 expose nixos-facter in cli 2024-09-29 16:21:53 +02:00
Qubasa
945c491d05 clan flash: Remove root requirement for flash, add a flash-template 2024-09-24 13:42:21 +02:00
Jörg Thalheim
d0ed48284b use packaged nixos-facter in generate_hardware_info 2024-09-24 11:38:33 +02:00
Qubasa
a27880a65e clan-cli: Move clan machines import to clan machines create 2024-09-23 17:11:48 +02:00
DavHau
e49d1f0127 vars/sops: improve shared secrets, switching backend
When a second machine checks for a shared secret, now the exists() call returns negative and only when updating the secrets for that machine, the machine is added to the sops receivers.

Also throw proper errors when the user switches backends without cleaning the files first.
2024-09-20 15:06:54 +02:00
Jörg Thalheim
8a8b473236 rename hw-generate to update-hardware-config 2024-09-20 13:42:18 +02:00
DavHau
0a8b7f38a8 vars: implement migration
Migrating generated files from the facts subsystem to the vars subsystem is now possible.

HowTo:
1. declare `clan.core.vars.generators.<generator>.migrateFact = my_service` where `my_service` refers to a service from `clan.core.facts.services`
2. run `clan vers generate your_machine` or `clan machines update your_machine`

Vars will only be migrated for a generator if:
1. The facts service specified via `migrateFact` does exist
2. None of the vars to generate exist yet
3. All public var names exist in the public facts store
4. All secret var names exist in the secret fact store

If the migration is deemed possible, the generator script will not be executed. Instead the files from the public or secret facts store are read and stored into the corresponding vars store
2024-09-19 17:57:03 +02:00
DavHau
01c833f2bc vars/generate: improve output when vars are updated
fixes #2076

- print old and new value if possible
- also inform the user if something hasn't changed
2024-09-18 16:57:01 +02:00
Johannes Kirschbauer
9a24b1ee16 Inventory: docs fixup 2024-09-18 08:31:00 +02:00
DavHau
6fc27d402b vars: allow setting a default for values 2024-09-17 21:11:38 +02:00
DavHau
4ce3cf16bb vars: generate vars for clan install
fixes #2087
2024-09-17 20:41:39 +02:00
DavHau
bd79e6aef6 vars: generate proper commit messages
fixes #2126
2024-09-17 20:22:18 +02:00
Johannes Kirschbauer
72f79dee37 Inventory: docs improvements 2024-09-16 22:52:40 +02:00
DavHau
51bf3187d7 vars/tests: fix nix eval triggering git concurrent access
Prevents this error: Another git process seems to be running in this repository
2024-09-16 18:58:22 +02:00
Qubasa
e9bfb129a1 clan-cli: Init clan machines import 2024-09-16 18:15:55 +02:00
Johannes Kirschbauer
27768aa04b Update: inventory classes check 2024-09-16 12:52:28 +00:00
Johannes Kirschbauer
dc57c3d948 CLI: api.register type preservation 2024-09-16 12:52:28 +00:00