Re: [Nix-dev] Cannot run "hydra-create-user" ("no such table: Users")

2017-03-06 Thread Domen Kožar
https://github.com/peti/hydra-tutorial/blob/master/hydra-master.nix#L51-L73

On Sun, Mar 5, 2017 at 12:49 AM, Bas van Dijk  wrote:

> Hi Bjørn,
>
> At LumiGuide I use the following systemd service to setup hydra:
>
> # Create a hydra admin user named "" 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  \
> --full-name '' \
> --email-address 'x...@lumiguide.nl' \
> --password '${cfg.Password}' \
> --role admin
>
> mkdir -p "${hydraHome}/.ssh"
> chmod 700 "${hydraHome}/.ssh"
> cp "**" "${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 "**" "${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.
>
> Bas
>
> On 4 March 2017 at 11:59, Bjørn Forsman  wrote:
>
>> Hi all Hydra + Nixpkgs users,
>>
>> How did you manage to run "hydra-create-user"? It fails for me:
>>
>>   $ sudo -u hydra hydra-create-user alice --full-name 'Alice Q. User'
>> --email-address 'al...@example.org' --password alice --role admin
>>   DBIx::Class::Storage::DBI::_prepare_sth(): DBI Exception:
>> DBD::SQLite::db prepare_cached failed: no such table: Users at
>> /nix/store/2jy4y3nml6qljayqjlrf8mx6rrgj8g4l-hydra-2017-02-
>> 03/bin/.hydra-create-user-wrapped
>> line 56
>>
>> This is on NixOS 17.03, using the hydra module provided by nixpkgs.
>> I've set "services.hydra.enable = true" in configuration.nix,
>> activated the configuration and verified that the hydra webUI is up. I
>> even have the 'Users' table that "hydra-create-user" says does not
>> exist:
>>
>>   $ sudo psql -U hydra
>>   psql (9.5.6)
>>   Type "help" for help.
>>
>>   hydra=> select * from Users;
>>username | fullname | emailaddress | password | emailonerror | type
>> | publicdashboard
>>   --+--+--+--+
>> --+--+-
>>   (0 rows)
>>
>> Any suggestions?
>>
>> Best regards,
>> Bjørn Forsman
>> ___
>> nix-dev mailing list
>> nix-dev@lists.science.uu.nl
>> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>>
>
>
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cannot run "hydra-create-user" ("no such table: Users")

2017-03-06 Thread Bjørn Forsman
On 5 March 2017 at 01:21, Bjørn Forsman  wrote:

> Hi Bas,
>
> On 5 March 2017 at 00:49, Bas van Dijk  wrote:
>
>> Hi Bjørn,
>>
>> At LumiGuide I use the following systemd service to setup hydra:
>>
>> # Create a hydra admin user named "" 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  \
>> --full-name '' \
>> --email-address 'x...@lumiguide.nl' \
>> --password '${cfg.Password}' \
>> --role admin
>>
>> mkdir -p "${hydraHome}/.ssh"
>> chmod 700 "${hydraHome}/.ssh"
>> cp "**" "${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 "**" "${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 '
> al...@example.org' --password alice --role admin
>   creating new user `alice'
>

Since the nixpkgs hydra module defines all HYDRA_* environment variables to
be global environment variables (set in NixOS environment.variables
option), I guess what blocked me the first time was that sudo restricts the
environment. I guess the the better/easier way would be "sudo -E
hydra-create-user ..." (unless using a systemd service that is).

  $ sudo -E hydra-create-user bfo --full-name 'Bjørn Forsman' --password
bfo --role admin
  updating existing user `bfo'

Best regards,
Bjørn Forsman
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cannot run "hydra-create-user" ("no such table: Users")

2017-03-06 Thread Bjørn Forsman
On 5 March 2017 at 01:21, Bjørn Forsman  wrote:

> Hi Bas,
>
> On 5 March 2017 at 00:49, Bas van Dijk  wrote:
>
>> Hi Bjørn,
>>
>> At LumiGuide I use the following systemd service to setup hydra:
>>
>> # Create a hydra admin user named "" 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  \
>> --full-name '' \
>> --email-address 'x...@lumiguide.nl' \
>> --password '${cfg.Password}' \
>> --role admin
>>
>> mkdir -p "${hydraHome}/.ssh"
>> chmod 700 "${hydraHome}/.ssh"
>> cp "**" "${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 "**" "${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 '
> al...@example.org' --password alice --role admin
>   creating new user `alice'
>

What I wrote above is wrong. It's "sudo -E" (pass along existing
environment variables) that makes it work, not only HYDRA_CONFIG=...

Best regards,
Bjørn Forsman
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cannot run "hydra-create-user" ("no such table: Users")

2017-03-06 Thread Bjørn Forsman
Hi Bas,

On 5 March 2017 at 00:49, Bas van Dijk  wrote:

> Hi Bjørn,
>
> At LumiGuide I use the following systemd service to setup hydra:
>
> # Create a hydra admin user named "" 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  \
> --full-name '' \
> --email-address 'x...@lumiguide.nl' \
> --password '${cfg.Password}' \
> --role admin
>
> mkdir -p "${hydraHome}/.ssh"
> chmod 700 "${hydraHome}/.ssh"
> cp "**" "${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 "**" "${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 '
al...@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-nore...@bforsman.name
  max_servers 25

  gc_roots_dir /nix/var/nix/gcroots/hydra
  >8

Best regards,
Bjørn Forsman
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cannot run "hydra-create-user" ("no such table: Users")

2017-03-04 Thread Bas van Dijk
Hi Bjørn,

At LumiGuide I use the following systemd service to setup hydra:

# Create a hydra admin user named "" 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  \
--full-name '' \
--email-address 'x...@lumiguide.nl' \
--password '${cfg.Password}' \
--role admin

mkdir -p "${hydraHome}/.ssh"
chmod 700 "${hydraHome}/.ssh"
cp "**" "${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 "**" "${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.

Bas

On 4 March 2017 at 11:59, Bjørn Forsman  wrote:

> Hi all Hydra + Nixpkgs users,
>
> How did you manage to run "hydra-create-user"? It fails for me:
>
>   $ sudo -u hydra hydra-create-user alice --full-name 'Alice Q. User'
> --email-address 'al...@example.org' --password alice --role admin
>   DBIx::Class::Storage::DBI::_prepare_sth(): DBI Exception:
> DBD::SQLite::db prepare_cached failed: no such table: Users at
> /nix/store/2jy4y3nml6qljayqjlrf8mx6rrgj8g4l-hydra-2017-02-03/bin/.
> hydra-create-user-wrapped
> line 56
>
> This is on NixOS 17.03, using the hydra module provided by nixpkgs.
> I've set "services.hydra.enable = true" in configuration.nix,
> activated the configuration and verified that the hydra webUI is up. I
> even have the 'Users' table that "hydra-create-user" says does not
> exist:
>
>   $ sudo psql -U hydra
>   psql (9.5.6)
>   Type "help" for help.
>
>   hydra=> select * from Users;
>username | fullname | emailaddress | password | emailonerror | type
> | publicdashboard
>   --+--+--+--+
> --+--+-
>   (0 rows)
>
> Any suggestions?
>
> Best regards,
> Bjørn Forsman
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] Cannot run "hydra-create-user" ("no such table: Users")

2017-03-04 Thread Bjørn Forsman
Hi all Hydra + Nixpkgs users,

How did you manage to run "hydra-create-user"? It fails for me:

  $ sudo -u hydra hydra-create-user alice --full-name 'Alice Q. User'
--email-address 'al...@example.org' --password alice --role admin
  DBIx::Class::Storage::DBI::_prepare_sth(): DBI Exception:
DBD::SQLite::db prepare_cached failed: no such table: Users at
/nix/store/2jy4y3nml6qljayqjlrf8mx6rrgj8g4l-hydra-2017-02-03/bin/.hydra-create-user-wrapped
line 56

This is on NixOS 17.03, using the hydra module provided by nixpkgs.
I've set "services.hydra.enable = true" in configuration.nix,
activated the configuration and verified that the hydra webUI is up. I
even have the 'Users' table that "hydra-create-user" says does not
exist:

  $ sudo psql -U hydra
  psql (9.5.6)
  Type "help" for help.

  hydra=> select * from Users;
   username | fullname | emailaddress | password | emailonerror | type
| publicdashboard
  
--+--+--+--+--+--+-
  (0 rows)

Any suggestions?

Best regards,
Bjørn Forsman
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev