summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rwxr-xr-xlava-master/scripts/setup.sh7
-rwxr-xr-xlavalab-gen.py12
3 files changed, 19 insertions, 1 deletions
diff --git a/README.md b/README.md
index 279fe25..3fdb938 100644
--- a/README.md
+++ b/README.md
@@ -215,6 +215,7 @@ masters:
- name: lava-master name of the master
host: name name of the host running lava-master (default to "local")
webadmin_https: Does the LAVA webadmin is accessed via https
+ persistent_db: True/False (default False) Is the postgres DB is persistent over reboot
users:
- name: LAVA username
token: The token of this user
diff --git a/lava-master/scripts/setup.sh b/lava-master/scripts/setup.sh
index 585499e..c00cb02 100755
--- a/lava-master/scripts/setup.sh
+++ b/lava-master/scripts/setup.sh
@@ -1,5 +1,12 @@
#!/bin/bash
+# always reset the lavaserver user, since its password could have been reseted in a "docker build --nocache"
+if [ ! -e /root/pg_lava_password ];then
+ < /dev/urandom tr -dc A-Za-z0-9 | head -c16 > /root/pg_lava_password
+fi
+sudo -u postgres psql -c "ALTER USER lavaserver WITH PASSWORD '$(cat /root/pg_lava_password)';" || exit $?
+sed -i "s,^LAVA_DB_PASSWORD=.*,LAVA_DB_PASSWORD='$(cat /root/pg_lava_password)'," /etc/lava-server/instance.conf || exit $?
+
if [ -e /root/lava-users ];then
for ut in $(ls /root/lava-users)
do
diff --git a/lavalab-gen.py b/lavalab-gen.py
index 35b10c7..e0c1c16 100755
--- a/lavalab-gen.py
+++ b/lavalab-gen.py
@@ -85,7 +85,7 @@ def main():
sys.exit(1)
masters = workers["masters"]
for master in masters:
- keywords_master = [ "name", "type", "host", "users", "tokens", "webadmin_https" ]
+ keywords_master = [ "name", "type", "host", "users", "tokens", "webadmin_https", "persistent_db" ]
for keyword in master:
if not keyword in keywords_master:
print("WARNING: unknown keyword %s" % keyword)
@@ -108,6 +108,16 @@ def main():
dockcomp["services"][name]["volumes"] = [ "/boot:/boot", "/lib/modules:/lib/modules" ]
dockcomp["services"][name]["build"] = {}
dockcomp["services"][name]["build"]["context"] = name
+ persistent_db = False
+ if "persistent_db" in master:
+ persistent_db = master["persistent_db"]
+ if persistent_db:
+ pg_volume_name = "pgdata_" + name
+ dockcomp["services"][name]["volumes"].append(pg_volume_name + ":/var/lib/postgresql")
+ dockcomp["services"][name]["volumes"].append("lava_job_output:/var/lib/lava-server/default/media/job-output/")
+ dockcomp["volumes"] = {}
+ dockcomp["volumes"][pg_volume_name] = {}
+ dockcomp["volumes"]["lava_job_output"] = {}
with open(dockcomposeymlpath, 'w') as f:
yaml.dump(dockcomp, f)