Noninteractive installation

Hi guys,

I’m curious about, is it possible to perform unattended installation with previously configured parameters?
Has anyone tried to create docker container with current RhodeCode version?

Hi,

Installer has an option to take an JSON input to set some parameters as default. For example:

        rccontrol install VCSServer '{"host":"127.0.0.1"}'
        rccontrol install Enterprise '{"password":"qweqwe", "email":"marcin@rhodecode.com", "username":"admin", "host":"0.0.0.0", "repo_dir":"/path/to/repos"}'
        rccontrol install Community '{"password":"qweqwe", "email":"marcin@rhodecode.com", "username":"admin", "host":"0.0.0.0", "repo_dir":"/path/to/repos"}'

However you still have to manually agree to license prompts.

Big thanks for the answer!

Agreement can be applied with ‘yes’ command

yes | rccontrol install VCSServer '{"host":"127.0.0.1", "port":"10001"}'

Are there any option for Database type ?
Database type - [s]qlite, [m]ysql, [p]ostresql:

Where can I get full option list?

Hmm, i just realized in case of database it would only support “database”:“sqlite” with automated mode, else it would trigger additional questions.

we’ll make an extension to the installer:

  • add --accept-licenses flag
  • allow to specify database: type/host/port/name/user/password

But I can change DB options later with config file and restart RhodeCode instance, am I right?

Yes, DB configuration is only to initially write to .ini file. So pickingin sqlite would be fully automatic.

I have made docker container, if somebody interested.
https://hub.docker.com/r/fragpit/rhodecodece/

2 Likes

Thanks for the docker image !

Ps, from version 1.9.0+ of Control here are full examples of automated installations

$ rccontrol install --accept-license VCSServer  '{"host":"127.0.0.1", "port":10202}'
$ rccontrol install --accept-license Enterprise '{"host":"127.0.0.1", "port":10101, "password":"qweqwe", "email":"support@rhodecode.com", "username":"admin", "repo_dir":"/tmp", "database": "sqlite"}'
$ rccontrol install --accept-license Community  '{"host":"127.0.0.1", "port":10101, "password":"qweqwe", "email":"support@rhodecode.com", "username":"admin", "repo_dir":"/tmp", "database": "postgresql://postgres:secret@localhost/rhodecode"}'
$ rccontrol install --accept-license Community  '{"host":"127.0.0.1", "port":10101, "password":"qweqwe", "email":"support@rhodecode.com", "username":"admin", "repo_dir":"/tmp", "database": "mysql://root:secret@localhost/rhodecode"}'

Hi everybody,

I’m jumping onto this because I’m currently trying to do an unattended installation with mysql/mariadb as DB backend.
As the last post above mentiones, one can pass a JSON String to the installer with all parameters, also for mysql. This can be found in the docs, too. But there is also this notice: “This currently works only with sqlite database type.” This seems to be correct, because even if I use the last line from above (with the “mysql://…” in the JSON String) I am asked which database type I want to use and the corresponding parameters during installation.
Also in the docs can be read: “After the installation the /home/user/.rccontrol/instance-id/rhodecode.ini can be changed to use different database type.”
But when I initally installed Community unattended with sqlite DB type (which works without problems) and change the DB Line to MySQL in rhodecode.ini, the community instance fails to start because of missing tables… it doesn’t seem to create the needed tables if it detects a new / empty DB, so changing the DB Config in rhodecode.ini will not work either.
Or is there any way to migrate the sqlite DB, which was created during install, to mysql?
Otherwise I acutally don’t see any valid way to do an unattanded installation when used another DB than sqlite…

Any hints?

Thx in advance!
Snoopy

Hi Snoopy,

The way to make it work for other databases is as follow:

rccontrol install --accept-license Community '{"password":"qweqwe", "email":"marcin@rhodecode.com", "username":"admin", "host":"0.0.0.0", "database":"sqlite", "repo_dir":"/home/ubuntu/repos", "port": 10020}'

replace the db1 to mysql/postgres in rhodecode.ini

pre-load the an existing database using

~/.rccontrol/community-1/profile/bin/rc-setup-app --force-yes ~/.rccontrol/community-1/rhodecode.ini --user=admin --email=marcin@rhodecode.com --password=qweqwe --repos=/home/ubuntu/repos

This should allow full non-interactive installation. Without validation of database, in other case this works too:

rccontrol install --accept-license Community  '{"host":"127.0.0.1", "port":10101, "password":"qweqwe", "email":"support@rhodecode.com", "username":"admin", "repo_dir":"/tmp", "database": "postgresql://postgres:qweqweqwe@localhost/rhodecode"}'

However one important difference is that the second way FORCES validation of database string and connection needs to be validated before.

Maybe your problem is that the connection isn’t valid and it asks for credentials

Hi Marcin,

thx a lot for the fast reply!

Your last sentence pushed me to the cause… when using this:
# ./rccontrol install --accept-license Community '{"host":"127.0.0.1", "port":"10020", "password":"***", "email":"mail@domain.com", "username":"admin", "repo_dir":"/data/rhodecode-repos", "database": "mysql://rhodecode:***@localhost/rhodecode"}'

I didn’t notice this error in the output:
Connection to DB failed with: '(_mysql_exceptions.OperationalError) (2002, "Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)")'

SIlly me :S
In the used distro (SLES 12) the MySQL socket can not be found under “/run/mysqld/mysqld.sock”, but under “/run/mysql/mysql.sock”…
So when using “localhost” as DB Host, rhodecode tries to connect via socket. When I use the hostname it will use TCP.

Where is the MySQL socket configured? It would be better to use the socket than TCP cause of TCP overhead…

Greetings!

Please try using 127.0.0.1 instead of localhost then, it should be fine

But this would lead also to a TCP Connection to the DB, not a socket one… with overhead I meant the TCP Protocol Overhead (TCP Handshake a.s.o.), not Network Overhead.
Isn’t the socket location configurable?

For installation there’s no option to use socket connection. It must be TCP.

Once it’s installed i believe you could modify the db1 parameter to something like this:

mysql:///dbname?unix_socket=/run/mysql/mysql.sock

RhodeCode doesn’t use the database a lot, TCP vs socket Overhead shouldn’t give any performance difference. There’s so much overhead with filesystem access of GIT/SVN/Mercurial objects that database shouldn’t be a bottleneck in any case.

RhodeCode doesn’t use the database a lot, TCP vs socket Overhead shouldn’t give any performance difference. There’s so much overhead with filesystem access of GIT/SVN/Mercurial objects that database shouldn’t be a bottleneck in any case.

OK I see… then I leave it using TCP to 127.0.0.1

Just for my personal interest:
When there is no option for socket connections during (unattended) installs, I don’t understand my mentioned error message above when using ‘{…“database”: “mysql://rhodecode:***@localhost/rhodecode”}’:

Connection to DB failed with: ‘(_mysql_exceptions.OperationalError) (2002, “Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ (2)”)’

Obviuosly the installer (or whatever it uses for DB Connections) tries to connect to mysql via socket when hostname is “localhost” and not “127.0.0.1”…