Skip to content

Commit 43c211b

Browse files
committed
infra: Migrate jobs/scripts to new staging host
1 parent b7a2d77 commit 43c211b

File tree

9 files changed

+51
-57
lines changed

9 files changed

+51
-57
lines changed

.github/workflows/bump.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: cachix/install-nix-action@v29
2121
- uses: DeterminateSystems/magic-nix-cache-action@main
2222
- run: |
23-
nix-shell default.nix -A ci --run "npins -d ./staging/npins update"
23+
nix-shell default.nix -A ci --run "npins -d ./infra/npins update"
2424
- uses: actions/create-github-app-token@v1
2525
id: generate-token
2626
with:

.github/workflows/database-dumps.yaml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/deployments.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ jobs:
2323
with:
2424
ssh-private-key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
2525
- name: Trust staging server public SSH host keys
26-
run: cat ./staging/staging_host_keys >> ~/.ssh/known_hosts
26+
run: cat ./infra/host_keys >> ~/.ssh/known_hosts
2727
- run: nix-shell default.nix -A ci --run deploy

.github/workflows/dry-activations.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@ jobs:
1414
staging:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- name: Setup WARP to gain IPv6
18-
uses: fscarmen/warp-on-actions@v1.1
19-
with:
20-
stack: dual
2117
- uses: actions/checkout@v4
2218
- uses: cachix/install-nix-action@v29
2319
- uses: DeterminateSystems/magic-nix-cache-action@main
2420
- uses: webfactory/ssh-agent@v0.9.0
2521
with:
2622
ssh-private-key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
2723
- name: Trust staging server public SSH host keys
28-
run: cat ./staging/staging_host_keys >> ~/.ssh/known_hosts
24+
run: cat ./infra/host_keys >> ~/.ssh/known_hosts
2925
- run: nix-shell default.nix -A ci --run "deploy dry-activate"

CONTRIBUTING.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,12 @@ Not passing `--subset N` will take about an hour and produce ~500 MB of data.
279279
If you have your SSH keys set up on the staging environment (and can connect through IPv6), you can deploy the service with:
280280
281281
```console
282-
./staging/deploy.sh
282+
./infra/deploy.sh
283283
```
284284
285285
### Adding SSH keys
286286
287-
Add your SSH keys to `./staging/configuration.nix` and let existing owners deploy them.
287+
Add your SSH keys to `./infra/configuration.nix` and let existing owners deploy them.
288288
289289
## Operators guidance
290290
@@ -295,5 +295,3 @@ Sentry-like collectors are endpoints where we ship error information from the Py
295295
Collectors are configured using [a DSN, i.e. a data source name.](https://docs.sentry.io/concepts/key-terms/dsn-explainer/) in Sentry parlance, this is where events are sent to.
296296
297297
You can set `GLITCHTIP_DSN` as a credential secret with a DSN and this will connect to a Sentry-like endpoint via your DSN.
298-
299-
We don't use Sentry but we run GlitchTip on staging.

default.nix

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,30 +98,19 @@ rec {
9898
let
9999
deploy = pkgs.writeShellApplication {
100100
name = "deploy";
101-
text = builtins.readFile ./staging/deploy.sh;
101+
text = builtins.readFile ./infra/deploy.sh;
102102
runtimeInputs = with pkgs; [
103103
nixos-rebuild
104104
coreutils
105105
];
106106
# TODO: satisfy shellcheck
107107
checkPhase = "";
108108
};
109-
dump-database = pkgs.writeShellApplication {
110-
name = "dump-database";
111-
text = builtins.readFile ./staging/dump-database.sh;
112-
runtimeInputs = with pkgs; [
113-
awscli
114-
pv
115-
];
116-
# TODO: satisfy shellcheck
117-
checkPhase = "";
118-
};
119109
in
120110
pkgs.mkShellNoCC {
121111
packages = [
122112
pkgs.npins
123113
deploy
124-
dump-database
125114
];
126115
};
127116

@@ -130,7 +119,7 @@ rec {
130119
manage = pkgs.writeScriptBin "manage" ''
131120
${python3}/bin/python ${toString ./src/website/manage.py} $@
132121
'';
133-
deploymentSources = import ./staging/npins;
122+
deploymentSources = import ./infra/npins;
134123
in
135124
pkgs.mkShellNoCC {
136125
env = {

infra/deploy.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i bash -p nixos-rebuild coreutils
3+
4+
set -eo pipefail
5+
6+
DIR=$(git rev-parse --show-toplevel)
7+
VERB=${1:-switch}
8+
# make sure we're building with the version of Nixpkgs under our control
9+
# TODO: fix the build on the latest nixpkgs-unstable and use that one for deployment
10+
# export NIX_PATH=nixpkgs=$(nix-instantiate --eval -E '(import ./infra/npins).nixpkgs.outPath' | tr -d '"')
11+
export NIX_PATH=nixpkgs=$(nix-instantiate --eval -A pkgs.path)
12+
13+
# Note: we could refactor the conditional here.
14+
# But `nixos-rebuild build --target-host ...` requiring network operations is an unexpected bug.
15+
# Therefore, we keep the two conditionals separated for the day when we will
16+
# replace `nixos-rebuild` by a tool that does not have this bug but similar
17+
# semantics.
18+
# Example: `colmena apply dry-activate` then `colmena build` does have these
19+
# properties and would make the second conditional disappear.
20+
21+
if [[ "$VERB" != "build" ]]; then
22+
# Perform a dry-activation first.
23+
echo "dry-activating the configuration first..."
24+
nixos-rebuild dry-activate -I nixos-config=$DIR/infra/configuration.nix --target-host root@tracker.security.nixos.org
25+
else
26+
echo "skipping the dry-activation as we are using an offline verb."
27+
fi
28+
29+
30+
if [[ "$VERB" != "build" ]]; then
31+
echo "$VERB-ing the configuration now."
32+
nixos-rebuild $VERB -I nixos-config=$DIR/infra/configuration.nix --target-host root@tracker.security.nixos.org
33+
else
34+
echo "building the configuration now."
35+
nixos-rebuild build -I nixos-config=$DIR/infra/configuration.nix
36+
fi

infra/host_keys

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# tracker.security.nixos.org:22 SSH-2.0-OpenSSH_9.8
2+
# tracker.security.nixos.org:22 SSH-2.0-OpenSSH_9.8
3+
# tracker.security.nixos.org:22 SSH-2.0-OpenSSH_9.8
4+
tracker.security.nixos.org ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQClYYPyUzZa686OZUspMsuhyPLgKKV/4IE6ygmx9DfduKkXj21LvvuxO7m+xxnfcd3YLP/NckObF+wyR4BdQSDJw+G140YzkHWEDeAgPVgXAs4+wlLhAzsHmJ+bEwDCVKcOhjRYDV4J0WbBel5EgVf1f3BsDFAxDrgFM8K8ZkJcLScOPbCYfJWhqCsjKzeMwfZKJfWivIO7lW44reX+GhwzmmBfWXyWX6ueMrjA8fUDagT8mGrEFa0nXwn/pFAchkQSzEozrMa6HyoNjzN1y8ddTxz+nMaRsf4uIbInZAb+h4RI8cD+sAzNDtNuVQZld9s8Q9M/HNQVC6c4qwyVSg6SysdHZgErpwVEmg07fvZbS67WfeOQi1K3ECgdpS5jfCOtu6eM/MjSPz64EHQesR1PzxmufOaq6kE3vg9CyixVaZ54jQlqu3Hw/a+QlW1ZwReJ87onrjRWTU69oEyGWoZinLqZRzV9fO7iQFwQO7zdTLQZ7aXeX9x9NDS66vOMVCL+LuwhP6HTb2QvAOZdfLMEbyiK1MUa/GmHdzQStCxPyi0SxtEZGPK0Pdf91Rjhf0PzeBSwEXUKTPyhk9XYE220ibCy8lc0SQdyaBOHANguonVETIAmHI9bd2yj/6qFe/ZTtRXraIEou5ZxPl7oO81tNQ4txZTqVH0rqxvrouM3tw==
5+
# tracker.security.nixos.org:22 SSH-2.0-OpenSSH_9.8
6+
tracker.security.nixos.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEHib5Kk39PzPEheOf8fwIyeVbVgSzUiqUN2vSIXHO7N
7+
# tracker.security.nixos.org:22 SSH-2.0-OpenSSH_9.8

infra/terraform.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ provider "hcloud" {
2929
resource "hcloud_server" "stfmaster" {
3030
name = "security-tracker-1"
3131
image = "debian-12"
32-
server_type = "cx32"
32+
server_type = "cpx41"
3333
public_net {
3434
ipv4_enabled = true
3535
ipv6_enabled = true

0 commit comments

Comments
 (0)