Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • privatestorage/PrivateStorageio
  • tomprince/PrivateStorageio
2 results
Select Git revision
Show changes
Commits on Source (45)
Showing
with 120 additions and 57 deletions
......@@ -23,6 +23,7 @@ unit-tests:
vulnerability-scan:
stage: "test"
script:
- "sed -i 's/undefined/\"unundefined\"/' morph/grid/local/secrets/users.nix"
- "ci-tools/vulnerability-scan security-report.json"
- "ci-tools/count-vulnerabilities <security-report.json"
artifacts:
......
......@@ -21,7 +21,7 @@ OUTPUT=$1
[ -e scan-target ] && rm -v scan-target
nix-shell --run '
set -x
if morph_result=$(morph build morph/grid/testing/grid.nix 2>&1); then
if morph_result=$(morph build morph/grid/local/grid.nix 2>&1); then
object=$(echo "$morph_result" | tail -n 1)
ln -s "$object" scan-target
else
......
......@@ -42,6 +42,23 @@ grid
Specific grid definitions live in subdirectories beneath this directory.
secrets
~~~~~~~
This must be created and populated before the grid can be built or deployed.
This directory contains all of the secrets necessary to deploy the grid.
Secrets beneath this directory are referenced by ``config.json`` and ``grid.nix``
(and possibly elsewhere).
Some of the paths are configurable and some are just convention.
This path is **ignored** by git.
The intended workflow is that the secrets will be maintained on secure storage and a symlink to the correct location created here.
This keeps the secrets themselves out of the git working tree as an extra protection against unintentionally committing them.
An exception is the ``secrets`` directory in the ``local`` morph grid:
That directory is fully populated, provided as an example, and mostly: not very secret.
Do not deploy these keys to machines reachable via the internet.
config.json
~~~~~~~~~~~
......
.vagrant
Set up and use a network of local development VMs
-------------------------------------------------
... using `Vagrant <https://www.vagrantup.com/>`_ to manage VirtualBox VMs [#]_.
To get started, first install Vagrant and make sure it works.
One possible way to do it in NixOS:
... using `Vagrant <https://www.vagrantup.com/>`_ to manage VirtualBox VMs.
(The author of this documentation wasted a lot of time trying to get Vagrant to work with KVM/libvirt.
Issues with networking that looked like guest misconfigurations vanished after changing to the better-tested combination of Vagrant and VirtualBox.)
1. Install Vagrant, by adding the packages:
- ``vagrant`` (orchestrating virtual machines on the command line)
- Only use when version >= 2.2.16 has become available. Else see below.
- Optional: ``packer`` (for creating your own VM images)
2. Add configuration to install and enable VirtualBox:
- ``virtualisation.virtualbox.host.enable = true;``
3. Add your user to the ``vboxusers`` group, for example:
- ``users.extraGroups.vboxusers.members = [ "flo" "jp" ];``
.. [#] The author of this documentation wasted a lot of time trying to get Vagrant to work with KVM/libvirt. Issues with networking that looked like guest misconfigurations vanished after changing to the better-tested combination of Vagrant and VirtualBox.
Use the local development environment
`````````````````````````````````````
Pre-Vagrant 2.2.16: Get Vagrant with the required fixes for NixOS guests
````````````````````````````````````````````````````````````````````````
1. Enter the morph local grid directory::
The Vagrant nixos-guest template `received a critical update on 2021-03-08 <https://github.com/hashicorp/vagrant/commit/990d94ed9d0b3092e855bc1bb9deeeb7aa7792cf>`_ which came out with Vagrant version 2.2.16.
cd morph/grid/local
If you run an older Nixpkgs, retrieve and use the latest Vagrant development version like so::
2. Enter the project's nix-shell::
NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/master.tar.gz nix-shell -p vagrant
nix-shell ../../../shell.nix
Use the local development environment
`````````````````````````````````````
1. Build and start the VMs::
3. Build and start the VMs::
VAGRANT_DEFAULT_PROVIDER=virtualbox vagrant up
2. Then, once::
4. Then, add the Vagrant SSH configuration to your user's ``~/.ssh/config`` file::
vagrant ssh-config > ./vagrant-ssh-config
install -d ~/.ssh ; vagrant ssh-config >> ~/.ssh/config
3. Edit the output: Add the IPs from ``grid.nix`` to the ``vagrant-ssh-config`` **Host match blocks** so the config reads like::
5. Edit the generated configuration: Add the ``publicIP`` addresses from ``grid.nix`` to ssh config **Host** match blocks (**not** HostName) so the ``Host`` lines all read like::
Host payments1 192.168.67.21
HostName 192.168.67.21
HostName 127.0.0.1
User vagrant
Port 22
[...]
4. Then, make morph use this ssh config either - with newer morph [#]_ - by pointing it to it::
export SSH_CONFIG_FILE=./vagrant-ssh-config
Latest Morph honors the ``SSH_CONFIG_FILE`` environment variable (`since 3f90aa88 (March 2020, v 1.5.0) <https://github.com/DBCDK/morph/commit/3f90aa885fac1c29fce9242452fa7c0c505744ef#diff-d155ad793bd62e6ea4c44ba985049ecb13a4f4f32f799791b2bce695a16c0101>`_), so in the future this should get a bit more convenient.
Or, with older morph, adding the config to your user's ``~/.ssh/config`` file.
6. Add your SSH key to ``users.nix`` so you'll be able to log in after deploying the new configuration::
.. [#] Morph honors the ``SSH_CONFIG_FILE`` environment variable `since 3f90aa88 (March 2020, v 1.5.0) <https://github.com/DBCDK/morph/commit/3f90aa885fac1c29fce9242452fa7c0c505744ef#diff-d155ad793bd62e6ea4c44ba985049ecb13a4f4f32f799791b2bce695a16c0101>`_.
$EDITOR secrets/users.nix
5. Then, build and deploy our software to the Vagrant VMs::
7. Then, build and deploy our software to the Vagrant VMs::
morph build grid.nix
morph push grid.nix
morph deploy grid.nix boot
vagrant halt
vagrant up
morph upload-secrets grid.nix
morph deploy grid.nix switch
You will now be able to log in with the users and keys you set in your ``localdev-users.nix`` file.
You should now be able to log in with the users and keys you set in your ``users.nix`` file.
......@@ -14,6 +14,10 @@ Vagrant.configure("2") do |config|
config.vm.box_version = "20.09"
config.vm.box_check_update = false
config.vm.network "private_network", ip: "192.168.67.21"
# Add self signed SSL key for zkap-issuer:
config.vm.provision "file", source: "secrets/payments-localdev-ssl", destination: "/tmp/payments-localdev-ssl"
config.vm.provision "shell", inline: "sudo mkdir -p /var/lib/letsencrypt/live/payments.localdev/"
config.vm.provision "shell", inline: "sudo mv /tmp/payments-localdev-ssl/* /var/lib/letsencrypt/live/payments.localdev/"
end
config.vm.define "storage1" do |config|
......
{ "publicStoragePort": 8898
, "ristrettoSigningKeyPath": "../../PrivateStorageSecrets/ristretto.signing-key"
, "stripeSecretKeyPath": "../../PrivateStorageSecrets/privatestorageio-testing-stripe.secret"
, "monitoringvpnKeyDir": "../../PrivateStorageSecrets/monitoringvpn"
, "ristrettoSigningKeyPath": "./secrets/ristretto.signing-key"
, "stripeSecretKeyPath": "./secrets/stripe.secret"
, "monitoringvpnKeyDir": "./secrets/monitoringvpn"
, "monitoringvpnEndpoint": "192.168.67.24:51820"
, "passValue": 1000000
, "issuerDomain": "payments.localdev"
, "issuerDomains": ["payments.localdev"]
, "letsEncryptAdminEmail": "florian@privatestorage.io"
, "allowedChargeOrigins": [
"http://localhost:5000"
......
......@@ -6,40 +6,46 @@ import ../../lib/make-grid.nix {
config = ./config.json;
nodes = cfg:
let
sshUsers = import ../../../../PrivateStorageSecrets/localdev-users.nix;
sshUsers = import ./secrets/users.nix;
vpnClientIPs = [ "172.23.23.11" "172.23.23.12" "172.23.23.13" ]; # TBD: derive automatically
# Get absolute vpn key directory path, as a string:
monitoringvpnKeyDir = toString ./. + "/${cfg.monitoringvpnKeyDir}";
in {
"payments1" = import ../../lib/make-issuer.nix (rec {
"payments1" = import ../../lib/make-issuer.nix (cfg // rec {
publicIPv4 = "192.168.67.21";
monitoringvpnIPv4 = "172.23.23.11";
inherit monitoringvpnKeyDir;
inherit sshUsers;
hardware = import ./virtual-hardware.nix ({ inherit publicIPv4; });
stateVersion = "19.03";
} // cfg);
});
"storage1" = import ../../lib/make-testing.nix (rec {
"storage1" = import ../../lib/make-testing.nix (cfg // rec {
publicIPv4 = "192.168.67.22";
monitoringvpnIPv4 = "172.23.23.12";
inherit monitoringvpnKeyDir;
inherit sshUsers;
hardware = import ./virtual-hardware.nix ({ inherit publicIPv4; });
stateVersion = "19.09";
} // cfg);
});
"storage2" = import ../../lib/make-testing.nix (rec {
"storage2" = import ../../lib/make-testing.nix (cfg // rec {
publicIPv4 = "192.168.67.23";
monitoringvpnIPv4 = "172.23.23.13";
inherit monitoringvpnKeyDir;
inherit sshUsers;
hardware = import ./virtual-hardware.nix ({ inherit publicIPv4; });
stateVersion = "19.09";
} // cfg);
});
"monitoring1" = import ../../lib/make-monitoring.nix (rec {
"monitoring1" = import ../../lib/make-monitoring.nix (cfg // rec {
publicIPv4 = "192.168.67.24";
monitoringvpnIPv4 = "172.23.23.1";
inherit vpnClientIPs;
inherit sshUsers;
inherit monitoringvpnKeyDir;
hardware = import ./virtual-hardware.nix ({ inherit publicIPv4; });
stateVersion = "19.09";
} // cfg);
});
};
}
cLP62YAYoA7FY+OhSLR64DIHekOjGGQlfJAWp5cYP00=
GYNjLkoyQ1d3OMymYbgq40WAHIUzrSEGBWXvxqceF00=
qFjBtvJKBchzl2HwFvEDoe3zFzyc10osiRlP8HOk2n0=
veio/0E0sJYOjwp3E8EccCyME1pqjkZr4R6whFMdrhs=
8HlKTvxZBAZeww6JaNk9kBPjSfT0pVMbDJbzV67yUGE=
4VlUMl9FubrLWaN0pRvfdNjjRBQzfCVLMA2lU7OwPzA=
E7KTLVnWMmP/mIEkU8WX2DBZJaeMS2+sYArRZuGT1o4=
iOp2pk2HWyNgRnke7nJgFwodkTWMyHRIKwe8pk+bN3M=
ojo+p9ZE03GN66ewoIlrHmyV7ICt+2LV32Prs66JsA4=
-----BEGIN CERTIFICATE-----
MIIDGTCCAgGgAwIBAgIUM9YnOMe2yYQuCLpYiI2TpZg21AMwDQYJKoZIhvcNAQEL
BQAwHDEaMBgGA1UEAwwRcGF5bWVudHMubG9jYWxkZXYwHhcNMjEwNjA5MTQzNzU4
WhcNMzEwNjA3MTQzNzU4WjAcMRowGAYDVQQDDBFwYXltZW50cy5sb2NhbGRldjCC
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOBCvkMprdRjD8ECeweMVTFT
pILu5VA8HC8XK15Y4iE8G48cSYE3m/e6w5g4JvfXgED9eY+1/ZazQXVI6sojnfHL
Vj9XqsUww3IVtq2Zn+0B8YTrbNxcDH77mUx0mUziAm1bglmoNbd4+q0Fe8FhK/EN
Jj7UppRjD2ziV9Mw7UT1JjMbfSo7/7ZOV2cWk+hezOywsE+3BM6mju1aHbbYryAd
EzRwfQKcI/9PC84Bck9e+tEiWQImBf8DguQ+ChuSOmGtP1rI+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