From c41eaabcfeb25523ed535107332254efba8680ef Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Wed, 26 Feb 2020 13:07:34 -0500 Subject: [PATCH] Move all of the grid files into new per-grid subdirectories Also put library code in a library directory --- morph/README.rst | 29 +++++++++++-------- .../production/config.json} | 0 morph/{ => grid/production}/grid.nix | 18 ++++++------ .../production}/storage000-config.nix | 0 .../production}/storage000-hardware.nix | 0 .../production}/storage001-config.nix | 0 .../production}/storage001-hardware.nix | 0 .../production}/storage002-config.nix | 0 .../production}/storage002-hardware.nix | 0 .../production}/storage003-config.nix | 0 .../production}/storage003-hardware.nix | 0 .../production}/storage004-config.nix | 0 .../production}/storage004-hardware.nix | 0 .../production}/storage005-config.nix | 0 .../production}/storage005-hardware.nix | 0 .../testing/config.json} | 0 .../testing/grid.nix} | 10 +++---- .../testing}/testing001-hardware.nix | 0 morph/{ => lib}/bootstrap-configuration.nix | 0 morph/{ => lib}/issuer-aws.nix | 0 morph/{ => lib}/issuer.nix | 6 ++-- morph/{ => lib}/make-grid.nix | 0 morph/{ => lib}/make-storage.nix | 4 +-- morph/{ => lib}/make-testing.nix | 2 +- 24 files changed, 37 insertions(+), 32 deletions(-) rename morph/{grid.config.json => grid/production/config.json} (100%) rename morph/{ => grid/production}/grid.nix (79%) rename morph/{ => grid/production}/storage000-config.nix (100%) rename morph/{ => grid/production}/storage000-hardware.nix (100%) rename morph/{ => grid/production}/storage001-config.nix (100%) rename morph/{ => grid/production}/storage001-hardware.nix (100%) rename morph/{ => grid/production}/storage002-config.nix (100%) rename morph/{ => grid/production}/storage002-hardware.nix (100%) rename morph/{ => grid/production}/storage003-config.nix (100%) rename morph/{ => grid/production}/storage003-hardware.nix (100%) rename morph/{ => grid/production}/storage004-config.nix (100%) rename morph/{ => grid/production}/storage004-hardware.nix (100%) rename morph/{ => grid/production}/storage005-config.nix (100%) rename morph/{ => grid/production}/storage005-hardware.nix (100%) rename morph/{testing-grid.config.json => grid/testing/config.json} (100%) rename morph/{testing-grid.nix => grid/testing/grid.nix} (64%) rename morph/{ => grid/testing}/testing001-hardware.nix (100%) rename morph/{ => lib}/bootstrap-configuration.nix (100%) rename morph/{ => lib}/issuer-aws.nix (100%) rename morph/{ => lib}/issuer.nix (83%) rename morph/{ => lib}/make-grid.nix (100%) rename morph/{ => lib}/make-storage.nix (97%) rename morph/{ => lib}/make-testing.nix (95%) diff --git a/morph/README.rst b/morph/README.rst index 3749ebf9..7f8bb655 100644 --- a/morph/README.rst +++ b/morph/README.rst @@ -7,20 +7,24 @@ and some JSON-based configuration in ``.config.json`` files. This configuration is fed to `morph`_ to make changes to the deployment. -bootstrap-configuration.nix ---------------------------- +lib +--- -This is meant as a minimal system configuration to use as part of crossgrading a Debian install to NixOS. -It has a lot of comments explaining different parts of Nix and NixOS. -You may want to browse it before looking at other ``.nix`` files here. +This contains Nix library code for defining the grids. -grid.config.json ----------------- +grid +---- -This contains configuration for Tahoe-LAFS. +Specific grid definitions live in subdirectories beneath this directory. + +config.json +~~~~~~~~~~~ + +As much as possible of the static configuration for the PrivateStorage.io application is provided in this file. +It is read by **grid.nix**. grid.nix --------- +~~~~~~~~ This is the `morph`_ entrypoint for the grid. This defines all of the servers that are part of the grid. @@ -30,14 +34,15 @@ You can do things like build the network:: morph build grid.nix + <hostname>-hardware.nix ------------------------ +~~~~~~~~~~~~~~~~~~~~~~~ These are the generated hardware-related configuration files for servers in the grid. These files are referenced from the corresponding ``<hostname>.nix`` files. <hostname>-config.nix ---------------------- +~~~~~~~~~~~~~~~~~~~~~ Each such file contains a minimal Nix expression supplying critical system configuration details. "Critical" roughly corresponds to anything which must be specified to have a bootable system. @@ -76,6 +81,6 @@ starting from a minimal NixOS 19.03 or 19.09 installation. #. Create a ``storageNNN-config.nix`` containing further configuration for the new host. #. Add an entry for the new host to ``grid.nix`` referencing the new files. -#. Deploy to the new host with ``morph deploy morph/grid.nix --on <identifier> boot --upload-secrets --reboot``. +#. Deploy to the new host with ``morph deploy morph/.../grid.nix --on <identifier> boot --upload-secrets --reboot``. .. _`morph`: https://github.com/DBCDK/morph diff --git a/morph/grid.config.json b/morph/grid/production/config.json similarity index 100% rename from morph/grid.config.json rename to morph/grid/production/config.json diff --git a/morph/grid.nix b/morph/grid/production/grid.nix similarity index 79% rename from morph/grid.nix rename to morph/grid/production/grid.nix index 0de7007d..a65b77bd 100644 --- a/morph/grid.nix +++ b/morph/grid/production/grid.nix @@ -1,9 +1,9 @@ # Load the helper function and call it with arguments tailored for the testing # grid. It will make the morph configuration for us. We share this function # with the testing grid and have one fewer possible point of divergence. -import ./make-grid.nix { +import ../../lib/make-grid.nix { name = "Production"; - config = ./grid.config.json; + config = ./config.json; nodes = cfg: { # Here are the hosts that are in this morph network. This is sort of like # a server manifest. We try to keep as many of the specific details as @@ -17,32 +17,32 @@ import ./make-grid.nix { # doesn't specify one. # # The names must be unique! - "payments.privatestorage.io" = import ./issuer.nix ({ - hardware = ./issuer-aws.nix; + "payments.privatestorage.io" = import ../../lib/issuer.nix ({ + hardware = ../../lib/issuer-aws.nix; stateVersion = "19.03"; } // cfg); - "storage001" = import ./make-storage.nix ({ + "storage001" = import ../../lib/make-storage.nix ({ cfg = import ./storage001-config.nix; hardware = ./storage001-hardware.nix; stateVersion = "19.09"; } // cfg); - "storage002" = import ./make-storage.nix ({ + "storage002" = import ../../lib/make-storage.nix ({ cfg = import ./storage002-config.nix; hardware = ./storage002-hardware.nix; stateVersion = "19.09"; } // cfg); - "storage003" = import ./make-storage.nix ({ + "storage003" = import ../../lib/make-storage.nix ({ cfg = import ./storage003-config.nix; hardware = ./storage003-hardware.nix; stateVersion = "19.09"; } // cfg); - "storage004" = import ./make-storage.nix ({ + "storage004" = import ../../lib/make-storage.nix ({ cfg = import ./storage004-config.nix; hardware = ./storage004-hardware.nix; stateVersion = "19.09"; } // cfg); - "storage005" = import ./make-storage.nix ({ + "storage005" = import ../../lib/make-storage.nix ({ cfg = import ./storage005-config.nix; hardware = ./storage005-hardware.nix; stateVersion = "19.03"; diff --git a/morph/storage000-config.nix b/morph/grid/production/storage000-config.nix similarity index 100% rename from morph/storage000-config.nix rename to morph/grid/production/storage000-config.nix diff --git a/morph/storage000-hardware.nix b/morph/grid/production/storage000-hardware.nix similarity index 100% rename from morph/storage000-hardware.nix rename to morph/grid/production/storage000-hardware.nix diff --git a/morph/storage001-config.nix b/morph/grid/production/storage001-config.nix similarity index 100% rename from morph/storage001-config.nix rename to morph/grid/production/storage001-config.nix diff --git a/morph/storage001-hardware.nix b/morph/grid/production/storage001-hardware.nix similarity index 100% rename from morph/storage001-hardware.nix rename to morph/grid/production/storage001-hardware.nix diff --git a/morph/storage002-config.nix b/morph/grid/production/storage002-config.nix similarity index 100% rename from morph/storage002-config.nix rename to morph/grid/production/storage002-config.nix diff --git a/morph/storage002-hardware.nix b/morph/grid/production/storage002-hardware.nix similarity index 100% rename from morph/storage002-hardware.nix rename to morph/grid/production/storage002-hardware.nix diff --git a/morph/storage003-config.nix b/morph/grid/production/storage003-config.nix similarity index 100% rename from morph/storage003-config.nix rename to morph/grid/production/storage003-config.nix diff --git a/morph/storage003-hardware.nix b/morph/grid/production/storage003-hardware.nix similarity index 100% rename from morph/storage003-hardware.nix rename to morph/grid/production/storage003-hardware.nix diff --git a/morph/storage004-config.nix b/morph/grid/production/storage004-config.nix similarity index 100% rename from morph/storage004-config.nix rename to morph/grid/production/storage004-config.nix diff --git a/morph/storage004-hardware.nix b/morph/grid/production/storage004-hardware.nix similarity index 100% rename from morph/storage004-hardware.nix rename to morph/grid/production/storage004-hardware.nix diff --git a/morph/storage005-config.nix b/morph/grid/production/storage005-config.nix similarity index 100% rename from morph/storage005-config.nix rename to morph/grid/production/storage005-config.nix diff --git a/morph/storage005-hardware.nix b/morph/grid/production/storage005-hardware.nix similarity index 100% rename from morph/storage005-hardware.nix rename to morph/grid/production/storage005-hardware.nix diff --git a/morph/testing-grid.config.json b/morph/grid/testing/config.json similarity index 100% rename from morph/testing-grid.config.json rename to morph/grid/testing/config.json diff --git a/morph/testing-grid.nix b/morph/grid/testing/grid.nix similarity index 64% rename from morph/testing-grid.nix rename to morph/grid/testing/grid.nix index 9ff17e51..4db91363 100644 --- a/morph/testing-grid.nix +++ b/morph/grid/testing/grid.nix @@ -1,16 +1,16 @@ # Load the helper function and call it with arguments tailored for the testing # grid. It will make the morph configuration for us. We share this function # with the production grid and have one fewer possible point of divergence. -import ./make-grid.nix { +import ../../lib/make-grid.nix { name = "Testing"; - config = ./testing-grid.config.json; + config = ./config.json; nodes = cfg: { - "payments.privatestorage-staging.com" = import ./issuer.nix ({ - hardware = ./issuer-aws.nix; + "payments.privatestorage-staging.com" = import ../../lib/issuer.nix ({ + hardware = ../../lib/issuer-aws.nix; stateVersion = "19.03"; } // cfg); - "3.120.26.190" = import ./make-testing.nix (cfg // { + "3.120.26.190" = import ../../lib/make-testing.nix (cfg // { publicIPv4 = "3.120.26.190"; hardware = ./testing001-hardware.nix; stateVersion = "19.03"; diff --git a/morph/testing001-hardware.nix b/morph/grid/testing/testing001-hardware.nix similarity index 100% rename from morph/testing001-hardware.nix rename to morph/grid/testing/testing001-hardware.nix diff --git a/morph/bootstrap-configuration.nix b/morph/lib/bootstrap-configuration.nix similarity index 100% rename from morph/bootstrap-configuration.nix rename to morph/lib/bootstrap-configuration.nix diff --git a/morph/issuer-aws.nix b/morph/lib/issuer-aws.nix similarity index 100% rename from morph/issuer-aws.nix rename to morph/lib/issuer-aws.nix diff --git a/morph/issuer.nix b/morph/lib/issuer.nix similarity index 83% rename from morph/issuer.nix rename to morph/lib/issuer.nix index 98d10d38..b2ef90c1 100644 --- a/morph/issuer.nix +++ b/morph/lib/issuer.nix @@ -22,14 +22,14 @@ imports = [ hardware - ../nixos/modules/issuer.nix + ../../nixos/modules/issuer.nix ]; services.private-storage-issuer = { enable = true; tls = true; - ristrettoSigningKeyPath = ./.. + ristrettoSigningKeyPath; - stripeSecretKeyPath = ./.. + stripeSecretKeyPath; + ristrettoSigningKeyPath = ./../.. + ristrettoSigningKeyPath; + stripeSecretKeyPath = ./../.. + stripeSecretKeyPath; database = "SQLite3"; databasePath = "/var/db/vouchers.sqlite3"; inherit letsEncryptAdminEmail; diff --git a/morph/make-grid.nix b/morph/lib/make-grid.nix similarity index 100% rename from morph/make-grid.nix rename to morph/lib/make-grid.nix diff --git a/morph/make-storage.nix b/morph/lib/make-storage.nix similarity index 97% rename from morph/make-storage.nix rename to morph/lib/make-storage.nix index 84a13be3..da206572 100644 --- a/morph/make-storage.nix +++ b/morph/lib/make-storage.nix @@ -32,10 +32,10 @@ # Include the results of the hardware scan. hardware # Configure it as a system operated by 100TB. - ../nixos/modules/100tb.nix + ../../nixos/modules/100tb.nix # Bring in our module for configuring the Tahoe-LAFS service and other # Private Storage-specific things. - ../nixos/modules/private-storage.nix + ../../nixos/modules/private-storage.nix ]; # Pass the configuration specific to this host to the 100TB module to be diff --git a/morph/make-testing.nix b/morph/lib/make-testing.nix similarity index 95% rename from morph/make-testing.nix rename to morph/lib/make-testing.nix index 77ba053a..24de7ea4 100644 --- a/morph/make-testing.nix +++ b/morph/lib/make-testing.nix @@ -18,7 +18,7 @@ imports = [ hardware - ../nixos/modules/private-storage.nix + ../../nixos/modules/private-storage.nix ]; services.private-storage = -- GitLab