[Nix-dev] Cannot run "hydra-create-user" ("no such table: Users")
Bjørn Forsman
bjorn.forsman at gmail.com
Sun Mar 5 01:21:14 CET 2017
Hi Bas,
On 5 March 2017 at 00:49, Bas van Dijk <v.dijk.bas at gmail.com> wrote:
> Hi Bjørn,
>
> At LumiGuide I use the following systemd service to setup hydra:
>
> # Create a hydra admin user named "xxxx" and copy the GitHub private SSH
> # key to hydra's home directory so that it can connect to GitHub to clone
> # our repo's.
> systemd.services.lumi-hydra-setup = {
> wantedBy = [ "multi-user.target" ];
> requires = [ "hydra-init.service" "postgresql.service" ];
> after = [ "hydra-init.service" "postgresql.service" ];
> environment = config.systemd.services.hydra-init.environment;
> path = [ config.services.hydra.package ];
> script =
> let hydraHome = config.users.users.hydra.home;
> hydraQueueRunnerHome = config.users.users.hydra-queue-runner.home;
> in ''
> hydra-create-user xxxx \
> --full-name 'XXXX' \
> --email-address 'xxxx at lumiguide.nl' \
> --password '${cfg.xxxxPassword}' \
> --role admin
>
> mkdir -p "${hydraHome}/.ssh"
> chmod 700 "${hydraHome}/.ssh"
> cp "*xxxx*" "${hydraHome}/.ssh/id_rsa"
> chown -R hydra:hydra "${hydraHome}/.ssh"
> chmod 600 "${hydraHome}/.ssh/id_rsa"
> mkdir -p "${hydraQueueRunnerHome}/.ssh"
> chmod 700 "${hydraQueueRunnerHome}/.ssh"
> cp "*xxxx*" "${hydraQueueRunnerHome}/.ssh/id_rsa"
> chown -R hydra-queue-runner:hydra "${hydraQueueRunnerHome}/.ssh"
> chmod 600 "${hydraQueueRunnerHome}/.ssh/id_rsa"
> '';
> serviceConfig = {
> Type = "oneshot";
> RemainAfterExit = true;
> };
> }; Note that I set the environment to be the hydra-init environment. With
> a bit of luck that's the solution for your problem.
>
Thanks for the tip and example code. Yes, it was a missing environment
variable! After looking at the environment for the hydra-init service
$ nixos-option systemd.services.hydra-init.environment
Value:
{ HYDRA_CONFIG = "/var/lib/hydra/hydra.conf"; [...snipped...]
and trying various combinations of those environment variables, I found
that I only needed HYDRA_CONFIG to make it work.
$ sudo -u hydra -E HYDRA_CONFIG="/var/lib/hydra/hydra.conf"
hydra-create-user alice --full-name 'Alice Q. User' --email-address '
alice at example.org' --password alice --role admin
creating new user `alice'
I find it strange that hydra-create-user gives such a misleading/useless
error message ("no such table: Users") just because it doesn't have access
to hydra.conf. It's not like hydra.conf deals with the database:
----8<---- (/var/lib/hydra/hydra.conf)
using_frontend_proxy 1
base_uri http://localhost:3000/
notification_sender hydra-noreply at bforsman.name
max_servers 25
gc_roots_dir /nix/var/nix/gcroots/hydra
---->8----
Best regards,
Bjørn Forsman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20170305/af6e2e96/attachment-0001.html>
More information about the nix-dev
mailing list