From c5c776421211e14b4b7e5ecd60cfa63c778adc92 Mon Sep 17 00:00:00 2001 From: Rajesh Rajendran Date: Tue, 25 May 2021 13:53:20 +0530 Subject: [PATCH] feat(installation): Enterprise license check --- scripts/helm/install.sh | 14 +++++++++++++ .../helm/roles/openreplay/defaults/main.yml | 1 - .../roles/openreplay/tasks/install-dbs.yaml | 4 ++-- .../roles/openreplay/tasks/pre-check.yaml | 20 +++++++++++++++++++ scripts/helm/vars.yaml | 4 ++++ 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/scripts/helm/install.sh b/scripts/helm/install.sh index d6585b9a8..0650af991 100755 --- a/scripts/helm/install.sh +++ b/scripts/helm/install.sh @@ -17,6 +17,20 @@ domain_name=`grep domain_name vars.yaml | grep -v "example" | cut -d " " -f2 | c } } +[[ $1 == "ee" ]] || { + [[ $2 == "" ]] || { + sed -i "s#enterprise_edition_license.*#enterprise_edition_license: ${2}#g" vars.yaml + } && { + echo """Enerprise key is missing. + Usage: ./install.sh ee XXXXXXXXXXXXX + """ + exit 1 + } +} + +# https://parrot.asayer.io/os/license +# payload: {"mid": "UUID of the machine", "license": ""} +# response {"data":{"valid": TRUE|FALSE, "expiration": expiration date in ms}} # Installing k3s curl -sL https://get.k3s.io | sudo K3S_KUBECONFIG_MODE="644" INSTALL_K3S_VERSION='v1.19.5+k3s2' INSTALL_K3S_EXEC="--no-deploy=traefik" sh - diff --git a/scripts/helm/roles/openreplay/defaults/main.yml b/scripts/helm/roles/openreplay/defaults/main.yml index f7948e53c..c750ced0e 100644 --- a/scripts/helm/roles/openreplay/defaults/main.yml +++ b/scripts/helm/roles/openreplay/defaults/main.yml @@ -6,4 +6,3 @@ db_list: - "nfs-server-provisioner" - "postgresql" - "redis" -enterprise_edition: false diff --git a/scripts/helm/roles/openreplay/tasks/install-dbs.yaml b/scripts/helm/roles/openreplay/tasks/install-dbs.yaml index fa2831cbb..5d22dbc30 100644 --- a/scripts/helm/roles/openreplay/tasks/install-dbs.yaml +++ b/scripts/helm/roles/openreplay/tasks/install-dbs.yaml @@ -24,7 +24,7 @@ delay: 60 register: result until: result.rc == 0 - when: enterprise_edition + when: enterprise_edition_license|length > 0 - name: Restoring postgres data shell: | file="{{ item|basename }}" @@ -53,7 +53,7 @@ delay: 60 register: result until: result.rc == 0 - when: enterprise_edition + when: enterprise_edition_license|length > 0 - name: Initializing Minio shell: | minio_pod=$(kubectl get po -n db -l app.kubernetes.io/name=minio -n db --output custom-columns=name:.metadata.name | tail -n+2) diff --git a/scripts/helm/roles/openreplay/tasks/pre-check.yaml b/scripts/helm/roles/openreplay/tasks/pre-check.yaml index 60801192f..f72f79139 100644 --- a/scripts/helm/roles/openreplay/tasks/pre-check.yaml +++ b/scripts/helm/roles/openreplay/tasks/pre-check.yaml @@ -108,3 +108,23 @@ - pre-check - nginx - all +- name: Checking Enterprise Licence + uri: + url: https://parrot.asayer.io/os/license + body: + mid: "UUID of the machine" + license: "{{ enterprise_edition_license }}" + body_format: json + creates: "{{ ansible_env.HOME }}/.config/openreplay.license" + follow_redirects: yes + force: false + http_agent: ansible-httpget + method: POST + return_content: true + status_code: [200] + timeout: 30 + unsafe_writes: false + validate_certs: true + when: enterprise_edition_license|length > 0 + register: enterprise_edition_license_check + failed_when: enterprise_edition_license_check.json.data.valid != true diff --git a/scripts/helm/vars.yaml b/scripts/helm/vars.yaml index 6c3e081ac..06f7f80de 100644 --- a/scripts/helm/vars.yaml +++ b/scripts/helm/vars.yaml @@ -57,3 +57,7 @@ enable_monitoring: "false" # `openssl rand -base64 30` minio_access_key: "" minio_secret_key: "" + +# If you're using enterprise edition. +# Insert the enterprise_edition_License key which you got. +enterprise_edition_license: ""