colmena: configuration et doc
This commit is contained in:
parent
dd227a92dc
commit
ef1453ab1e
5 changed files with 106 additions and 84 deletions
33
README.md
33
README.md
|
@ -71,3 +71,36 @@ commande :
|
|||
```bash
|
||||
$ nix fmt
|
||||
```
|
||||
|
||||
## Colmena
|
||||
|
||||
Pour faciliter le redeploiement des machines, l'outils colmena est utilisé.
|
||||
Pour cela, l'ensemble des machines doivent être écrite dans la `flake` au
|
||||
format `colmena.<name>`. Des tags peuvent être ajouté avec `deployment.tags`
|
||||
afin redéployer un groupe de machines en même temps.
|
||||
|
||||
Pour utiliser les commandes suivantes, il est nécessaire d'avoir colmena sur
|
||||
son ordinateur. La commande `nix develop` s'en chargera.
|
||||
|
||||
Remarque :
|
||||
|
||||
> Si l'ensemble des fichiers du repertoire ne sont pas commit, alors colmena
|
||||
> considérera que le répertoire est "impure". S'il est vraiment nécessaire
|
||||
> d'appliquer la confifuration, il est possible de le faire à l'aide du flag
|
||||
> `--impure`.
|
||||
|
||||
### Build
|
||||
|
||||
```bash
|
||||
$ colmena build # Build toutes les machines
|
||||
$ colmena build --on <machine> # Build uniquement la machine <machine>
|
||||
$ colmena build --on @<tag> # Build les machines possédant ce tag
|
||||
```
|
||||
|
||||
### Apply
|
||||
|
||||
```bash
|
||||
$ colmena apply # Apply toutes les machines
|
||||
$ colmena apply --on <machine> # Apply uniquement la machine <machine>
|
||||
$ colmena apply --on @<tag> # Apply les machines possédant ce tag
|
||||
```
|
||||
|
|
116
flake.nix
116
flake.nix
|
@ -34,39 +34,9 @@
|
|||
}:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
imports = [ inputs.treefmt-nix.flakeModule ];
|
||||
|
||||
systems = [ "x86_64-linux" ];
|
||||
|
||||
flake = with nixpkgs.lib; {
|
||||
colmena = {
|
||||
meta = {
|
||||
nixpkgs = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
overlays = [ ];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
jitsi = {
|
||||
deployment = {
|
||||
targetHost = "jitsi.pub.infra.auro.re";
|
||||
targetPort = 22;
|
||||
targetUser = "root";
|
||||
tags = [ "services" ];
|
||||
};
|
||||
|
||||
imports = [
|
||||
./profiles/common
|
||||
agenix.nixosModules.default
|
||||
disko.nixosModules.disko
|
||||
./profiles/vm
|
||||
./disks/layout_vm.nix
|
||||
./hosts/vm/jitsi
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
nixosConfigurations =
|
||||
flake = with nixpkgs.lib;
|
||||
let
|
||||
defaultConfig = [
|
||||
./profiles/common
|
||||
|
@ -79,32 +49,70 @@
|
|||
./disks/layout_vm.nix
|
||||
]
|
||||
++ defaultConfig;
|
||||
in
|
||||
{
|
||||
grafana = nixosSystem {
|
||||
specialArgs = inputs;
|
||||
modules = [
|
||||
./hosts/vm/grafana
|
||||
]
|
||||
++ defaultVM;
|
||||
machines = {
|
||||
jitsi = {
|
||||
domain = "pub.infra.auro.re";
|
||||
tags = [ "vm" ];
|
||||
config = [ ./hosts/vm/jitsi ] ++ defaultVM;
|
||||
};
|
||||
log-2 = nixosSystem {
|
||||
specialArgs = inputs;
|
||||
modules = [
|
||||
grafana = {
|
||||
domain = "ext.infra.auro.re";
|
||||
tags = [ "vm" ];
|
||||
config = [
|
||||
./hosts/vm/grafana
|
||||
] ++ defaultVM;
|
||||
};
|
||||
log-2 = {
|
||||
domain = "int.infra.auro.re";
|
||||
tags = [ "vm" "log" ];
|
||||
config = [
|
||||
./hosts/vm/log-2
|
||||
./disks/layout_vm_log.nix
|
||||
]
|
||||
++ defaultVM;
|
||||
] ++ defaultVM;
|
||||
};
|
||||
# VL: Peut-être avoir de l'auto-discovery: On a beaucoup trop de machines
|
||||
jitsi = nixosSystem {
|
||||
};
|
||||
colmena_conf = builtins.mapAttrs
|
||||
(
|
||||
name: conf: {
|
||||
deployment = {
|
||||
targetHost = "${name}.${conf.domain}";
|
||||
targetPort = 22;
|
||||
targetUser = "root";
|
||||
tags = conf.tags;
|
||||
};
|
||||
networking = {
|
||||
hostName = name;
|
||||
domain = conf.domain;
|
||||
};
|
||||
imports = conf.config;
|
||||
}
|
||||
)
|
||||
machines;
|
||||
nixos_conf = builtins.mapAttrs
|
||||
(
|
||||
name: conf: nixosSystem {
|
||||
specialArgs = inputs;
|
||||
modules = [
|
||||
./hosts/vm/jitsi
|
||||
]
|
||||
++ defaultVM;
|
||||
modules = [{
|
||||
networking = {
|
||||
hostName = name;
|
||||
domain = conf.domain;
|
||||
};
|
||||
}] ++ conf.config;
|
||||
}
|
||||
)
|
||||
machines;
|
||||
in
|
||||
{
|
||||
colmena = {
|
||||
meta = {
|
||||
nixpkgs = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
overlays = [ ];
|
||||
};
|
||||
};
|
||||
} // colmena_conf;
|
||||
|
||||
nixosConfigurations = nixos_conf;
|
||||
};
|
||||
|
||||
perSystem = { config, pkgs, system, ... }:
|
||||
|
@ -116,13 +124,9 @@
|
|||
# Formatter
|
||||
treefmt.config = {
|
||||
package = pkgs.treefmt;
|
||||
|
||||
programs = {
|
||||
# *.nix
|
||||
nixpkgs-fmt.enable = true;
|
||||
|
||||
# *.md (and more)
|
||||
prettier.enable = true;
|
||||
nixpkgs-fmt.enable = true; # *.nix
|
||||
prettier.enable = true; # *.md (and more)
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -5,11 +5,6 @@
|
|||
./grafana.nix
|
||||
];
|
||||
|
||||
networking = {
|
||||
hostName = "grafana";
|
||||
domain = "ext.infra.auro.re";
|
||||
};
|
||||
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
|
||||
systemd.network = {
|
||||
|
|
|
@ -5,11 +5,6 @@
|
|||
./jitsi.nix
|
||||
];
|
||||
|
||||
networking = {
|
||||
hostName = "jitsi";
|
||||
domain = "pub.infra.auro.re";
|
||||
};
|
||||
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
|
||||
systemd.network = {
|
||||
|
|
|
@ -7,11 +7,6 @@
|
|||
|
||||
disko.devices.disk.logs.device = "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi1";
|
||||
|
||||
networking = {
|
||||
hostName = "log-2";
|
||||
domain = "int.infra.auro.re";
|
||||
};
|
||||
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
|
||||
systemd.network = {
|
||||
|
|
Loading…
Reference in a new issue