From ff8cd29863bc32cbbab4fc5131e1d26a822c0612 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 10 Feb 2021 21:00:12 +0100 Subject: [PATCH] Update to 2021-02-10 21:00 --- roles/appsmith/defaults/main.yml | 5 +++++ roles/appsmith/tasks/directories.yml | 4 ++++ roles/appsmith/tasks/install.yml | 22 ++++++++++++++-------- .../appsmith/templates/appsmith-server.service.j2 | 2 ++ roles/appsmith/templates/env.j2 | 2 ++ roles/appsmith/templates/pre-start.sh.j2 | 19 +++++++++++++++++++ 6 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 roles/appsmith/templates/pre-start.sh.j2 diff --git a/roles/appsmith/defaults/main.yml b/roles/appsmith/defaults/main.yml index 69681e1..ec9e21c 100644 --- a/roles/appsmith/defaults/main.yml +++ b/roles/appsmith/defaults/main.yml @@ -38,3 +38,8 @@ appsmith_email_tls: "{{ (appsmith_email_port == 587) | ternary(True,False) }}" # Public URL used to access appsmith appsmith_public_url: http://{{ inventory_hostname }} + +# User signup can be disabled +appsmith_user_signup: True +# If signup is disabled, you can set a list of whitelisted email which will be allowed +appsmith_admin_emails: [] diff --git a/roles/appsmith/tasks/directories.yml b/roles/appsmith/tasks/directories.yml index 88d42c4..a838e8f 100644 --- a/roles/appsmith/tasks/directories.yml +++ b/roles/appsmith/tasks/directories.yml @@ -12,12 +12,16 @@ owner: "{{ appsmith_user }}" mode: 700 - dir: "{{ appsmith_root_dir }}/src" + owner: "{{ appsmith_user }}" - dir: "{{ appsmith_root_dir }}/server" + owner: "{{ appsmith_user }}" - dir: "{{ appsmith_root_dir }}/server/plugins" + owner: "{{ appsmith_user }}" - dir: "{{ appsmith_root_dir }}/client" - dir: "{{ appsmith_root_dir }}/meta" mode: 700 - dir: "{{ appsmith_root_dir }}/etc" group: "{{ appsmith_user }}" mode: 750 + - dir: "{{ appsmith_root_dir }}/bin" tags: appsmith diff --git a/roles/appsmith/tasks/install.yml b/roles/appsmith/tasks/install.yml index 428efac..1c8b4b1 100644 --- a/roles/appsmith/tasks/install.yml +++ b/roles/appsmith/tasks/install.yml @@ -5,6 +5,7 @@ name: - nodejs - java-11-openjdk + - java-11-openjdk-devel - mongodb-org-tools tags: appsmith @@ -96,18 +97,19 @@ chdir: "{{ appsmith_root_dir }}/src/app/client" - name: Build the client - command: ./node_modules/.bin/craco --max-old-space-size=4096 build --config craco.build.config.js + command: ./node_modules/.bin/craco --max-old-space-size=2048 build --config craco.build.config.js args: chdir: "{{ appsmith_root_dir }}/src/app/client" - - name: Move the client to its final dir - synchronize: - src: "{{ appsmith_root_dir }}/src/app/client/build/" - dest: "{{ appsmith_root_dir }}/client/" - compress: False - delete: True - delegate_to: "{{ inventory_hostname }}" +# - name: Move the client to its final dir +# synchronize: +# src: "{{ appsmith_root_dir }}/src/app/client/build/" +# dest: "{{ appsmith_root_dir }}/client/" +# compress: False +# delete: True +# delegate_to: "{{ inventory_hostname }}" + become_user: "{{ appsmith_user }}" tags: appsmith - name: Deploy systemd unit @@ -123,6 +125,10 @@ when: appsmith_units.results | selectattr('changed','equalto',True) | list | length > 0 tags: appsmith +- name: Install pre-start script + template: src=pre-start.sh.j2 dest={{ appsmith_root_dir }}/bin/pre-start mode=755 + tags: appsmith + - name: Install pre/post backup hoooks template: src={{ item }}-backup.sh.j2 dest=/etc/backup/{{ item }}.d/appsmith mode=700 loop: diff --git a/roles/appsmith/templates/appsmith-server.service.j2 b/roles/appsmith/templates/appsmith-server.service.j2 index bdcdf9b..9b03d1d 100644 --- a/roles/appsmith/templates/appsmith-server.service.j2 +++ b/roles/appsmith/templates/appsmith-server.service.j2 @@ -8,6 +8,8 @@ User={{ appsmith_user }} Group={{ appsmith_user }} EnvironmentFile={{ appsmith_root_dir }}/etc/env WorkingDirectory={{ appsmith_root_dir }}/server +PermissionsStartOnly=yes +ExecStartPre={{ appsmith_root_dir }}/bin/pre-start ExecStart=/bin/java -Djava.net.preferIPv4Stack=true -Dserver.port={{ appsmith_server_port }} -Djava.security.egd="file:/dev/./urandom" -jar server-1.0-SNAPSHOT.jar PrivateTmp=yes ProtectSystem=full diff --git a/roles/appsmith/templates/env.j2 b/roles/appsmith/templates/env.j2 index d752936..14a40d3 100644 --- a/roles/appsmith/templates/env.j2 +++ b/roles/appsmith/templates/env.j2 @@ -13,3 +13,5 @@ APPSMITH_MONGODB_URI={{ appsmith_mongo_url }} APPSMITH_DISABLE_TELEMETRY=true APPSMITH_ENCRYPTION_PASSWORD={{ appsmith_encryption_pass }} APPSMITH_ENCRYPTION_SALT={{ appsmith_encryption_salt }} +APPSMITH_SIGNUP_DISABLED={{ appsmith_user_signup | ternary('false','true') }} +APPSMITH_ADMIN_EMAILS={{ appsmith_admin_emails | join(',') }} diff --git a/roles/appsmith/templates/pre-start.sh.j2 b/roles/appsmith/templates/pre-start.sh.j2 new file mode 100644 index 0000000..e671c4e --- /dev/null +++ b/roles/appsmith/templates/pre-start.sh.j2 @@ -0,0 +1,19 @@ +#!/bin/bash -e + +# If the conf changed since the last client deployement, then re-deploy +if [ {{ appsmith_root_dir }}/etc/env -nt {{ appsmith_root_dir }}/client/ ]; then + rsync -a --delete {{ appsmith_root_dir }}/src/app/client/build/ {{ appsmith_root_dir }}/client/ + find {{ appsmith_root_dir }}/client/ -type f | xargs \ + sed -i \ +{% for var in [ + "APPSMITH_SENTRY_DSN","APPSMITH_SMART_LOOK_ID","APPSMITH_OAUTH2_GOOGLE_CLIENT_ID", + "APPSMITH_OAUTH2_GITHUB_CLIENT_ID","APPSMITH_MARKETPLACE_ENABLED", + "APPSMITH_SEGMENT_KEY","APPSMITH_OPTIMIZELY_KEY","APPSMITH_ALGOLIA_API_ID", + "APPSMITH_ALGOLIA_SEARCH_INDEX_NAME","APPSMITH_ALGOLIA_API_KEY","APPSMITH_CLIENT_LOG_LEVEL", + "APPSMITH_GOOGLE_MAPS_API_KEY","APPSMITH_TNC_PP","APPSMITH_VERSION_ID", + "APPSMITH_VERSION_RELEASE_DATE","APPSMITH_INTERCOM_APP_ID","APPSMITH_MAIL_ENABLED","APPSMITH_DISABLE_TELEMETRY"] %} + -e "s/__{{ var }}__/${{ '{' ~ var ~ '}' }}/g"{% if not loop.last %} \{% endif %} + +{% endfor %} + +fi