Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PrivateStorageio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PrivateStorage
PrivateStorageio
Commits
bfa6cb90
Commit
bfa6cb90
authored
3 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
Generate a local root authz key so the deployment user can morph
parent
134776d2
No related branches found
Branches containing commit
No related tags found
3 merge requests
!140
Merge staging into production
,
!122
Merge develop into staging
,
!115
Continuous deployment for the grid systems
Pipeline
#818
passed
3 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nixos/modules/deployment.nix
+40
-1
40 additions, 1 deletion
nixos/modules/deployment.nix
with
40 additions
and
1 deletion
nixos/modules/deployment.nix
+
40
−
1
View file @
bfa6cb90
# A NixOS module which enables remotely-triggered deployment updates.
{
config
,
lib
,
...
}:
{
config
,
lib
,
pkgs
,
...
}:
let
# A handy alias for our part of the configuration.
cfg
=
config
.
services
.
private-storage
.
deployment
;
...
...
@@ -44,6 +44,45 @@ in {
];
};
# Create a one-time service that will set up an ssh key that allows the
# deployment user to authorize as root to perform the system update with
# `morph deploy`.
systemd
.
services
.
authorize-morph-as-root
=
{
enable
=
true
;
serviceConfig
=
{
# Tell systemd that the service is a process that runs and then exits.
# By being "oneshot" instead of "simple" any dependencies are not
# started until after the process exits. We have no dependencies yet
# but if we did it would be more correct for them to wait until we are
# done.
#
# It is not clear that "oneshot" means "run once" though (maybe it
# does, I can't tell) so the script is robust in the face of repeated
# runs even though it should only ever need to be run once.
Type
=
"oneshot"
;
};
wantedBy
=
[
# Run this to reach the multi-user target, a good target that is
# reached in the typical course of system startup.
"multi-user.target"
];
# Here's the program to run for this unit. It's a shell script that
# creates an ssh key that authorized root access via ssh and give it to
# the deployment user. If such a key appears to exist already, do
# nothing.
script
=
''
KEY=~deployment/.ssh/morph_key
TMP="$KEY"_tmp
if [ ! -e "$KEY" ]; then
mkdir -p ~deployment/.ssh ~root/.ssh
${
pkgs
.
openssh
}
/bin/ssh-keygen -f "$TMP"
cat "$TMP".pub >> ~root/.ssh/authorized_keys
mv "$TMP".pub "$KEY".pub
mv "$TMP" "$KEY"
fi
''
;
};
# Raise the hard-limit on the size of $XDG_RUNTIME_DIR (ie
# /run/user/<uid>). The default of 10% is too small on some systems for
# the temporary state morph creates to do the self-update.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment