Created
May 20, 2021 11:53
-
-
Save SlavaKatiukha/6babcefcae557813fe11f994bc13599d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jpsType: install | |
| jpsVersion: '1.4' | |
| id: openmage-cluster | |
| homepage: https://github.com/proxiblue/openmage-cluster/tree/main | |
| description: | |
| text: Auto-scalable and highly-available OpenMage eCommerce cluster with out-of-box | |
| auto-scaling, even load and traffic distribution, master-master data replication, | |
| page caching and user session storage on certified Jelastic dockerized stack templates. | |
| short: Auto-scalable and highly-available OpenMage cluster with load balancing, data | |
| replication, content caching and user session storage. | |
| categories: | |
| - apps/clusters | |
| - apps/e-commerce | |
| logo: https://raw.githubusercontent.com/ProxiBlue/openmage-cluster/main/images/57708.png | |
| name: Auto-Scalable OpenMage Cluster | |
| globals: | |
| PATH: https://raw.githubusercontent.com/ProxiBlue/openmage-cluster/main/ | |
| MAGE_ROOT: "/var/www/webroot/ROOT" | |
| DB_USER: jelastic-${fn.random} | |
| DB_PASS: "${fn.password(20)}" | |
| DB_NAME: openmage | |
| RD_PASS: "${fn.password(10)}" | |
| ADMIN_PASSWD: "${fn.password(20)}" | |
| ROOT_PASSWD: "${fn.password(20)}" | |
| NGINX_PASSWD: "${fn.password(20)}" | |
| ADMIN_URL: admin_${fn.random} | |
| MG_ADMIN_USER: admin-${fn.random} | |
| settings: | |
| fields: | |
| - caption: "Select Locale" | |
| type: list | |
| required: true | |
| name: LOCALE | |
| - caption: "Select Timezone" | |
| type: list | |
| required: true | |
| name: TIMEZONE | |
| - caption: "Select Currency" | |
| type: list | |
| required: true | |
| name: CURRENCY | |
| - caption: Skip Install Let's Encrypt SSL with Auto-Renewal? | |
| type: checkbox | |
| name: le_addon | |
| value: true | |
| tooltip: "Advanced integration with Let's Encrypt certificate authority that simplifies and automates the process of issuing, configuring and renewing trusted SSL certificates." | |
| - caption: Install Sample Data? | |
| type: checkbox | |
| name: SAMPLE_DATA | |
| value: true | |
| - caption: "PHP Version" | |
| type: list | |
| values: | |
| 1.18.0-php-7.4.16 : 7.4 | |
| required: true | |
| name: PHP_VERSION | |
| value: 1.18.0-php-7.4.16 | |
| onBeforeInit: | | |
| var url = "https://raw.githubusercontent.com/ProxiBlue/openmage-cluster/main/settings/populate.txt"; | |
| var data = toNative( new org.json.JSONObject( new com.hivext.api.core.utils.Transport().get(url) ) ).data; | |
| jps.settings.fields[0].values = data.LOCALE; | |
| jps.settings.fields[1].values = data.TIMEZONE; | |
| jps.settings.fields[2].values = data.CURRENCY; | |
| return jps; | |
| success: | |
| text: | | |
| # Environment details. | |
| ## store this information!!!! | |
| * URL: https://${env.domain} | |
| * Admin panel URL: https://${env.domain}/${globals.ADMIN_URL} | |
| * Admin user: ${globals.MG_ADMIN_USER} | |
| * Admin password: ${globals.ADMIN_PASSWD} | |
| * ROOT Password on Web Nodes: ${globals.ROOT_PASSWD} | |
| * NGINX Password on web nodes: ${globals.NGINX_PASSWD} | |
| * DB USER: ${globals.DB_USER} | |
| * DB_NAME: openmage | |
| * DB_PASS: ${globals.DB_PASS} | |
| * RD_PASS: ${globals.RD_PASS} | |
| To add a custom domain name for your Magento Cluster installation, follow the steps described | |
| in our documentation: http://docs.jelastic.com/custom-domains | |
| ssl: false | |
| skipNodeEmails: true | |
| nodes: | |
| - nodeType: nginxphp-dockerized | |
| tag: ${settings.PHP_VERSION} | |
| count: 2 | |
| cloudlets: 16 | |
| nodeGroup: cp | |
| volumeMounts: | |
| "/var/www/webroot/ROOT": | |
| readOnly: false | |
| sourcePath: "/data" | |
| sourceNodeGroup: storage | |
| displayName: AppServer | |
| env: | |
| PHPFPM_MAX_CHILDREN: 3 | |
| - nodeType: mariadb-dockerized | |
| tag: 10.3.22 | |
| count: 2 | |
| cloudlets: 8 | |
| nodeGroup: sqldb | |
| displayName: Database | |
| env: | |
| ON_ENV_INSTALL: "" | |
| - nodeType: storage | |
| cloudlets: 8 | |
| nodeGroup: storage | |
| displayName: Storage | |
| - nodeType: varnish-dockerized | |
| tag: 5.2.1 | |
| cloudlets: 8 | |
| nodeGroup: bl | |
| displayName: Balancer | |
| - nodeType: redis | |
| count: 2 | |
| cloudlets: 8 | |
| nodeGroup: nosqldb | |
| onAfterScaleOut[nodeGroup:cp]: | |
| forEach(event.response.nodes): | |
| cmd [${@i.id}]: sudo service nginx reload | |
| setNodeDisplayName [${@i.id}]: AppServer | |
| onAfterScaleOut[nodeGroup:bl]: | |
| forEach(event.response.nodes): | |
| setNodeDisplayName [${@i.id}]: Load balancer | |
| onInstall: | |
| - setExtIpEnabled: | |
| - enabled: true | |
| nodeGroup: bl | |
| - setGlobals: | |
| protocol: https | |
| - log: Auto Scaling Triggers | |
| - script: https://raw.githubusercontent.com/ProxiBlue/openmage-cluster/main/scripts/addTriggers.js | |
| params: | |
| nodeGroup: cp | |
| resourceType: CPU | |
| scaleUpValue: 70 | |
| scaleUpLimit: 10 | |
| scaleUpLoadPeriod: 1 | |
| scaleDownValue: 20 | |
| scaleDownLimit: 2 | |
| scaleDownLoadPeriod: 10 | |
| cleanOldTriggers: true | |
| - log: Set Display Name | |
| setNodeDisplayName [cp]: AppServer | |
| setNodeDisplayName [bl]: Load balancer | |
| setNodeDisplayName[${nodes.nosqldb.first.id}]: Session Storage | |
| setNodeDisplayName[${nodes.nosqldb.last.id}]: Cache Storage | |
| - log: Load balancer Setup | |
| - setupBL: | |
| filter: bl | |
| - if ('${settings.le_addon:true}' == 'false'): | |
| - install: | |
| jps: https://github.com/jelastic-jps/lets-encrypt/blob/stage/manifest.jps | |
| envName: ${env.envName} | |
| nodeGroup: bl | |
| skipEmail: true | |
| settings: | |
| customDomains: "" | |
| - log: Envs Setup for CP layer | |
| - setEnvs: | |
| filter: cp | |
| - log: DB Cluster Setup | |
| - installJps: | |
| jps: https://raw.githubusercontent.com/jelastic-jps/mysql-cluster/master/scripts/ms-mm-configuration.jps | |
| settings: | |
| path: "https://raw.githubusercontent.com/jelastic-jps/mysql-cluster/master" | |
| db_user: "${globals.DB_USER}" | |
| db_pass: "${globals.DB_PASS}" | |
| scheme: "slave" | |
| custom_conf: "${globals.PATH}/configs/mysql/db.cnf" | |
| nodeGroup: sqldb | |
| - log: setup storage | |
| - cmd[storage]: | |
| - mkdir -p /data/ | |
| - chown 700:700 -Rh /data/ | |
| - log: Root Commands | |
| - forEach(nodes.cp): | |
| cmd[${@i.id}]: | |
| - yum install composer | |
| - composer self-update --1 | |
| - echo ${globals.NGINX_PASSWD}| passwd --stdin nginx &>> /var/log/run.log | |
| - echo ${globals.ROOT_PASSWD}| passwd --stdin root &>> /var/log/run.log | |
| - wget -q --no-verbose --no-check-certificate https://files.magerun.net/n98-magerun.phar -O /usr/bin/n98-magerun &>> /var/log/run.log | |
| - chmod +x /usr/bin/n98-magerun | |
| - curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" &>> /var/log/run.log | |
| - unzip awscliv2.zip &>> /var/log/run.log | |
| - ./aws/install &>> /var/log/run.log | |
| user: root | |
| - composerOpenMage | |
| - cmd[storage]: wget ${globals.PATH}/configs/openmage/local.xml.template -O /data/app/etc/local.xml.template | |
| - setupRDConnect: | |
| config: /data/app/etc/local.xml.template | |
| - setupCP | |
| - if ('${settings.SAMPLE_DATA:false}' == 'true'): | |
| - cmd[${nodes.cp.first.id}]: | |
| - wget ${globals.PATH}/sampledata/compressed-magento-sample-data-1.9.1.0.tgz -O /tmp/compressed-magento-sample-data-1.9.1.0.tgz | |
| - cmd[${nodes.cp.first.id}]: | |
| - wget ${globals.PATH}/configs/varnish/varnish-probe.php -O ${globals.MAGE_ROOT}/health_check.php | |
| - wget ${globals.PATH}/scripts/setupOpenMage.sh -O /tmp/setup.sh | |
| - bash -x /tmp/setup.sh ${globals.DB_USER} ${globals.DB_PASS} DB_MASTER ${globals.DB_NAME} ${globals.ADMIN_PASSWD} ${globals.MAGE_ROOT} ${env.url} ${user.email} "${globals.ADMIN_URL}" ${globals.MG_ADMIN_USER} ${settings.LOCALE} ${settings.TIMEZONE} ${settings.CURRENCY} ${env.envName} ${settings.le_addon:false} ${settings.SAMPLE_DATA:false} &>> /var/log/run.log | |
| actions: | |
| composerOpenMage: | |
| - log: OpenMage Setup | |
| - cmd[${nodes.cp.first.id}]: | |
| - cd /tmp | |
| - curl -O ${globals.PATH}scripts/composerOpenMage.sh | |
| - bash -x /tmp/composerOpenMage.sh ${globals.PATH} ${globals.MAGE_ROOT} &>> /var/log/run.log | |
| setupCP: | |
| - log: App Servers Setup | |
| - cmd[cp]: |- | |
| wget ${globals.PATH}/configs/nginx/site-default-openmage.conf -O /etc/nginx/conf.d/site-default.conf | |
| wget ${globals.PATH}/configs/nginx/nginx.conf -O /etc/nginx/nginx.conf | |
| wget ${globals.PATH}/configs/php/extensions.ini -O /etc/php.d/extensions.ini | |
| echo "client_max_body_size 20M;" >>/etc/nginx/conf.d/client_max_body_size.conf | |
| sudo /etc/init.d/nginx restart &>> /var/log/run.log | |
| setEnvs: | |
| - forEach(i:nodes.sqldb): | |
| - if (${@i.ismaster}): | |
| cmd [${this.filter}]: | |
| echo ${@i.intIP} DB_MASTER >> /etc/hosts | |
| user: root | |
| - if (!${@i.ismaster}): | |
| cmd [${this.filter}]: | |
| echo ${@i.intIP} DB_SLAVE >> /etc/hosts | |
| user: root | |
| - cmd [${this.filter}]: | |
| - echo ${nodes.nosqldb.first.intIP} RDS >> /etc/hosts | |
| - echo ${nodes.nosqldb.last.intIP} RDC >> /etc/hosts | |
| user: root | |
| setupBL: | |
| - cmd[bl]: | |
| - wget ${globals.PATH}/scripts/varnish/jem_overrides/varnish_balancer.lib -O /var/lib/jelastic/overrides/varnish_balancer.lib | |
| - wget ${globals.PATH}/configs/varnish/default.vcl -O /etc/varnish/default.vcl | |
| user: root | |
| - forEach(nodes.cp): | |
| cmd[${this.filter}]: | |
| - jem balancer addCommonHost -h ${@i.intIP} | |
| - sudo service varnish reload &>> /var/log/run.log | |
| user: root | |
| setupRDConnect: | |
| - setupRDconfig: | |
| id: ${nodes.nosqldb.first.id} | |
| passtype: RD_SESSION_PASS | |
| config: ${this.config} | |
| - setupRDconfig: | |
| id: ${nodes.nosqldb.last.id} | |
| passtype: RD_CACHE_PASS | |
| config: ${this.config} | |
| setupRDconfig: | |
| script: | | |
| var resp = jelastic.env.control.ExecCmdById(getParam('TARGET_APPID'), session, nodeid, toJSON([{ "command": "cat /etc/redis.conf | tail -1 | awk '{print $2}'"}]), false, "root"); | |
| var passwd = resp.responses[0].out; | |
| resp = {result: 0, onAfterReturn: []}; | |
| resp = jelastic.env.control.ExecCmdByGroup('${env.envName}', session, "storage", toJSON([{ "command": 'sed -ri \"s/${this.passtype}/' + passwd + '/g\" ${this.config}' }]), false, false, "root"); | |
| return resp; | |
| nodeid: ${this.id} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment