for automatic deployment with ansible I’d like to check whether the database is already initialized. The aim is to avoid running trytond-admin again which would update all modules and take quite some time.
I think you can just use the update modules option of trytond-admin to see if the module table have been initalized:
See:
$ createdb test
$ trytond-admin -d test -m
Traceback (most recent call last):
File "/home/pokoli/.virtualenvs/incoltec/bin/trytond-admin", line 31, in <module>
admin.run(options)
File "/home/pokoli/.virtualenvs/incoltec/lib/python3.11/site-packages/trytond/admin.py", line 38, in run
raise Exception('"%s" is not a Tryton database.' % db_name)
Exception: "test" is not a Tryton database.
$ trytond-admin -d test --all
$ trytond-admin -d test -m
There is no error no the second run after the datbase had been intialized.
Thanks. I checked it and it even works without -m:
$ createdb test
$ trytond-admin -d test
Traceback (most recent call last):
…
Exception: "test" is not a Tryton database.
$ trytond-admin -d test --all
$ trytond-admin -d test