From f9c0f469ddc1c82dfc9faa1c873725cbc8bf83ac Mon Sep 17 00:00:00 2001 From: Laura Herzog Date: Mon, 10 May 2021 07:08:35 +0200 Subject: [PATCH] #46 Implemented autoinstall --- src/lib/instances/create/create.sh | 10 ++++ src/tpl/stack/config/master.cnf | 3 ++ .../autoinstall/autoinstall/ilias-config.json | 48 ++++++++++++++++++ .../states/autoinstall/autoinstall/init.sls | 43 ++++++++++++++++ src/tpl/stack/states/autoinstall/top.sls | 3 ++ .../stack/states/composer2/composer/init.sls | 2 +- .../states/ilias/ilias/ilias-config.json | 50 ------------------- src/tpl/stack/states/ilias/ilias/init.sls | 42 ++++++---------- 8 files changed, 122 insertions(+), 79 deletions(-) create mode 100644 src/tpl/stack/states/autoinstall/autoinstall/ilias-config.json create mode 100644 src/tpl/stack/states/autoinstall/autoinstall/init.sls create mode 100644 src/tpl/stack/states/autoinstall/top.sls delete mode 100644 src/tpl/stack/states/ilias/ilias/ilias-config.json diff --git a/src/lib/instances/create/create.sh b/src/lib/instances/create/create.sh index 0910b869..656d076a 100755 --- a/src/lib/instances/create/create.sh +++ b/src/lib/instances/create/create.sh @@ -381,6 +381,16 @@ then docker exec -t -i ${DCMAINHASH} /bin/bash -c "salt '${NAME}.local' state.highstate saltenv=composer54 --state-output=terse" fi +################### +# try autoinstaller +if (( ${ILIAS_VERSION} > 6 )) +then + NOW=$(date +'%d.%m.%Y %I:%M:%S') + echo "[${NOW}] Trying autoinstaller" + + docker exec -t -i ${DCMAINHASH} /bin/bash -c "salt '${NAME}.local' state.highstate saltenv=autoinstall --state-output=terse" +fi + ######################### # finalizing docker image NOW=$(date +'%d.%m.%Y %I:%M:%S') diff --git a/src/tpl/stack/config/master.cnf b/src/tpl/stack/config/master.cnf index dc053343..45445373 100644 --- a/src/tpl/stack/config/master.cnf +++ b/src/tpl/stack/config/master.cnf @@ -670,6 +670,9 @@ file_roots: - /srv/salt/states/composer2 composer54: - /srv/salt/states/composer54 + autoinstall: + - /srv/salt/states/autoinstall + # The master_roots setting configures a master-only copy of the file_roots dictionary, # used by the state compiler. diff --git a/src/tpl/stack/states/autoinstall/autoinstall/ilias-config.json b/src/tpl/stack/states/autoinstall/autoinstall/ilias-config.json new file mode 100644 index 00000000..a2347007 --- /dev/null +++ b/src/tpl/stack/states/autoinstall/autoinstall/ilias-config.json @@ -0,0 +1,48 @@ +{ + "common" : { + "client_id" : "{{ client_id }}", + "master_password" : "{{ master_password }}", + "server_timezone" : "{{ server_timezone }}" + }, + "database" : { + "user" : "{{ db_user }}", + "database" : "{{ db_name }}", + "type" : "{{ db_type }}", + "create_database" : {{ db_create }}, + "password" : "{{ db_pass }}" + }, + "filesystem" : { + "data_dir" : "{{ data_dir }}/" + }, + "systemfolder" : { + "client" : { + "name" : "{{ client_id }}", + "description" : "ILIAS", + "institution" : "{{ contact_firstname }}" + }, + "contact" : { + "firstname" : "{{ contact_firstname }}", + "lastname" : "{{ contact_lastname }}", + "email" : "{{ contact_mail }}" + } + }, + "language" : { + "default_language" : "{{ language }}" + }, + "http" : { + "path" : "{{ http_path }}" + }, + "logging" : { + "enable" : true, + "path_to_logfile" : "{{ log_dir }}/ilias.log", + "errorlog_dir" : "{{ log_dir }}" + }, + "utilities" : { + "path_to_convert" : "/usr/bin/convert", + "path_to_zip" : "/usr/bin/zip", + "path_to_unzip" : "/usr/bin/unzip" + }, + "virusscanner" : { + "virusscanner" : "none" + } +} diff --git a/src/tpl/stack/states/autoinstall/autoinstall/init.sls b/src/tpl/stack/states/autoinstall/autoinstall/init.sls new file mode 100644 index 00000000..9633bd47 --- /dev/null +++ b/src/tpl/stack/states/autoinstall/autoinstall/init.sls @@ -0,0 +1,43 @@ +/var/ilias/data/ilias-config.json: + file.managed: + - source: salt://autoinstall/ilias-config.json + - template: jinja + - context: + client_id: ilias + master_password: ilias + server_timezone: 'Europe/Berlin' + db_user: ilias + db_name: ilias + db_type: 'innodb' + db_create: 'true' + db_pass: ilias + data_dir: /var/ilias/data + contact_firstname: 'CaT' + contact_lastname: 'Concepts and Training GmbH' + contact_mail: 'noreply@concepts-and-training.de' + language: 'de' + log_dir: /var/ilias/logs + http_path: http://ilias.local + - user: www-data + - group: www-data + - mode: 640 + +ilias-setup: + cmd.run: + - name: "php /var/www/html/setup/setup.php install -y /var/ilias/data/ilias-config.json" + +/var/www/html/: + file.directory: + - user: www-data + - group: www-data + - recurse: + - user + - group + +/var/ilias/: + file.directory: + - user: www-data + - group: www-data + - recurse: + - user + - group \ No newline at end of file diff --git a/src/tpl/stack/states/autoinstall/top.sls b/src/tpl/stack/states/autoinstall/top.sls new file mode 100644 index 00000000..3c4794f6 --- /dev/null +++ b/src/tpl/stack/states/autoinstall/top.sls @@ -0,0 +1,3 @@ +autoinstall: + '*': + - autoinstall diff --git a/src/tpl/stack/states/composer2/composer/init.sls b/src/tpl/stack/states/composer2/composer/init.sls index 4e43069d..3cc5aebd 100644 --- a/src/tpl/stack/states/composer2/composer/init.sls +++ b/src/tpl/stack/states/composer2/composer/init.sls @@ -6,7 +6,7 @@ get-composer: install-composer: cmd.wait: - - name: php composer-setup.php --version=2 + - name: php composer-setup.php - cwd: /root/ - watch: - cmd: get-composer diff --git a/src/tpl/stack/states/ilias/ilias/ilias-config.json b/src/tpl/stack/states/ilias/ilias/ilias-config.json deleted file mode 100644 index d1529929..00000000 --- a/src/tpl/stack/states/ilias/ilias/ilias-config.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "common" : { - "client_id" : "{{ client_id }}", - "master_password" : "{{ master_password }}", - "server_timezone" : "{{ server_timezone }}" - }, - "database" : { - "user" : "{{ db_user }}", - "database" : "{{ db_name }}", - "type" : "{{ db_type }}", - "create_database" : {{ db_create }}, - "password" : "{{ db_pass }}" - }, - "filesystem" : { - "data_dir" : "{{ data_dir }}/" - }, - "systemfolder" : { - "client" : { - "name" : "{{ client_id }}", - "description" : "ILIAS", - "institution" : "{{ contact_firstname }}" - }, - "contact" : { - "firstname" : "{{ contact_firstname }}", - "lastname" : "{{ contact_lastname }}", - "email" : "{{ contact_mail }}" - } - }, - "language" : { - "default_language" : "{{ language }}" - }, - "http" : { - "path" : "{{ http_path }}" - }, - "logging" : { - "enable" : true, - "path_to_logfile" : "{{ log_dir }}/ilias.log", - "errorlog_dir" : "{{ log_dir }}" - }, - "utilities" : { - "path_to_convert" : "/usr/bin/convert", - "path_to_zip" : "/usr/bin/zip", - "path_to_unzip" : "/usr/bin/unzip" - }, - "virusscanner" : { - "virusscanner" : "none" - } -} - - diff --git a/src/tpl/stack/states/ilias/ilias/init.sls b/src/tpl/stack/states/ilias/ilias/init.sls index 4cc5f638..8609725f 100644 --- a/src/tpl/stack/states/ilias/ilias/init.sls +++ b/src/tpl/stack/states/ilias/ilias/init.sls @@ -25,32 +25,18 @@ ilias_git_config: - value: false - repo: /var/www/html -#/var/ilias/data/ilias-config.json: -# file.managed: -# - source: salt://ilias/ilias-config.json -# - template: jinja -# - context: -# client_id: ilias -# master_password: ilias -# server_timezone: 'Europe/Berlin' -# db_user: ilias -# db_name: ilias -# db_type: 'innodb' -# db_create: 'true' -# db_pass: ilias -# data_dir: /var/ilias/data -# contact_firstname: 'CaT' -# contact_lastname: 'Concepts and Training GmbH' -# contact_mail: 'noreply@concepts-and-training.de' -# language: 'de' -# log_dir: /var/ilias/logs -# http_path: http://ilias.local -# - user: www-data -# - group: www-data -# - mode: 640 +/var/www/html/: + file.directory: + - user: www-data + - group: www-data + - recurse: + - user + - group -#ilias-setup: -# cmd.wait: -# - name: "php /var/www/html/setup/setup.php install -y /var/ilias/data/ilias-config.json" -# - watch: -# - cmd: ilias-composer-install \ No newline at end of file +/var/ilias/: + file.directory: + - user: www-data + - group: www-data + - recurse: + - user + - group \ No newline at end of file