type: install jpsVersion: '1.7.2' name: WordPress Cluster Kit v2 id: wordpress-cluster categories: - apps/clusters - apps/content-management description: text: WordPress Cluster Kit with highly available Load Balancer and Shared Storage with GlusterFS, database clustering, and scaling mode to create an optimal environment for highly-loaded projects. The package provides integrated autoscaling and high availability for development and production environments. Clustered topology ensures effective handling of heavy workload. short: WordPress Cluster with built-in kit v2 for choosing optimal servers, database clustering type, scaling mode and a set of advanced features for highly-loaded projects logo: /images/wp-cluster-kit.svg baseUrl: https://raw.githubusercontent.com/jelastic-jps/wordpress-cluster/v2.2.0 onBeforeInit: /scripts/beforeInit.js?_r=${fn.random} onBeforeInstall: /scripts/beforeInstall.js?_r=${fn.random} skipNodeEmails: true nodes: definedInOnBeforeInstall settings: fields: - caption: Scaling Strategy type: list name: loadGrowth default: slow required: true width: 225 tooltip: | Configure auto-scaling triggers, i.e. how fast the system responds to load spikes by adding or removing nodes.

Read more about Automatic Horizontal Scaling

values: - value: slow caption: Low Load tooltip:

Low load scaling strategy

add 1 new node when CPU > 70%

remove when CPU < 20%

- value: medium caption: Medium Load tooltip:

Medium load scaling strategy

add 1 new node when CPU > 50%

remove when CPU < 20%

- value: fast caption: High Load tooltip:

High load scaling strategy

add 2 new nodes when CPU > 30%

remove when CPU < 10%

- caption: Advanced Features type: displayfield name: displayfield markup: - caption: Install LiteSpeed High-Performance Web Server type: checkbox name: ls-addon value: true disabled: false tooltip: "If this option is disabled, the cluster will be installed using NGINX load balancer and application servers" showIf: true: - caption: WordPress Brute Force Attack Protection type: checkbox name: wp_protect value: true disabled: false tooltip: "Secure WordPress Admin Panel with LiteSpeed Brute Force Protection that limits failed login attempts. Default action is Throttle and number of allowed attempts is 100" - caption: Web Application Firewall type: checkbox name: waf value: true disabled: false tooltip: "Protect web sites with LiteSpeed built-in WAF based on Free ModSecurity Rules from Comodo" false: - caption: WordPress Brute Force Attack Protection type: checkbox name: wp_protect value: false disabled: true tooltip: "Secure WordPress Admin Panel with LiteSpeed Brute Force Protection that limits failed login attempts. Default action is Throttle and number of allowed attempts is 100" - caption: Web Application Firewall type: checkbox name: waf value: false disabled: true tooltip: "Protect web sites with LiteSpeed built-in WAF based on Free ModSecurity Rules from Comodo" - caption: Install MariaDB Galera Cluster type: checkbox name: galera value: true disabled: false tooltip: "

Requirements for All Tables:

* run on InnoDB storage engine

* have a primary key

Read more about limitations" - caption: Install Let's Encrypt SSL with Auto-Renewal type: checkbox name: le-addon value: true disabled: false tooltip: "Advanced integration with Let's Encrypt certificate authority that simplifies and automates the process of issuing, configuring and updating trusted custom SSL certificates." - caption: Install Lightning-Fast Premium CDN type: checkbox name: cdn-addon value: true disabled: false tooltip: "Jelastic CDN is an HTTP/3 premium content delivery network of 160+ Super PoPs (points of presence) with bandwidth capacity up to 115 Tbps, advanced caching and acceleration strategies based on best-in-class IP Anycast technology." - caption: 'Install GlusterFS Cluster' type: checkbox name: glusterfs value: false disabled: false tooltip: "Shared Storage auto-clustering is based on GlusterFS software that provides a fault-tolerant distributed file system with automatic data synchronization across the cluster nodes." - caption: Install WordPress Multisite Network type: checkbox name: mu-addon value: false disabled: false tooltip: "Multisite is a type of WordPress installation that allows you to create and manage a network of multiple websites from a single WordPress dashboard. This lets you easily make changes and keep all of your websites updated from one place." - caption: Install WooCommerce type: checkbox name: woocommerce value: false disabled: false tooltip: "WooCommerce is a free open-source e-commerce plugin designed specifically for WordPress. This is a great platform for a store of any size." - type: displayfield hideLabel: true hidden: true name: bl_count value: 2 markup: mixins: - https://raw.githubusercontent.com/jelastic-jps/wordpress-cluster/master/configs/vers.yaml globals: PATH: ${baseUrl} DB_USER: ${settings.DB_USER:user-[fn.random]} DB_PASS: ${settings.DB_PASS:[fn.password(10)]} DB_HOST: sqldb PROTOCOL: http WP_ADMIN_PASS: ${settings.WP_ADMIN_PASS:[fn.password(10)]} LS_ADMIN_PASS: ${settings.LS_ADMIN_PASS:[fn.password(10)]} SUCCESS: default onInstall: - limits - setProtocol - setDomain - initLEsettings - if (${settings.is_trigger:true}): setTriggers - optimization - setupCacheSync - storageHealthCheck - storageMount: NFS4 - if (/litespeed/.test("${nodes.cp.nodeType}")): setPassword - getRedisPswd - installWordpress - if ('${settings.mu-addon:false}' == 'true'): configureMultisite - if (${settings.woocommerce:false}): installWoocommerce - if (('${settings.le-addon:false}' == 'true') || ('${settings.cdn-addon:false}' == 'true')): - script: | var actions = []; if ('${settings.le-addon:false}' == 'true') actions.push({ jps: "https://github.com/jelastic-jps/lets-encrypt/blob/master/manifest.jps?_r=${fn.random}?_r=${fn.random}", nodeGroup: "bl", skipEmail: "true", settings: { customDomains: "${globals.DOMAIN}", fallbackToX1: "true", withExtIp: "${globals.isExtIP}" } }); if ('${settings.cdn-addon:false}' == 'true') actions.push({ jps: "https://raw.githubusercontent.com/edgeport/cdn/master/manifest.yml?_r=${fn.random}", nodeGroup: "bl", skipEmail: "true", settings: { note: "${settings.noteCDN:}" } }); return { result: 0, onAfterReturn: { install: actions } }; - if ('${settings.le-addon:false}' == 'true'): setupLEdomain - if ('${settings.cdn-addon:false}' == 'true'): setupCDN - install: - jps: /scripts/cacheClean.jps?_r=${fn.random} - jps: /scripts/addons.jps?_r=${fn.random} - jps: /scripts/events.jps?_r=${fn.random} - if ('${settings.success_email}' != 'false'): - return: type: success message: /success/text/success-${globals.SUCCESS}.md?_r=${fn.random} email: /success/email/success-${nodes.cp.master.nodeType}-${globals.SUCCESS}.md?_r=${fn.random} actions: limits: - env.control.ApplyNodeGroupData[bl,cp,sqldb,storage,nosqldb]: data: project: ${settings.project:default} projectScope: ${settings.projectScope:production} isRequired: true setProtocol: - script: | return { result:0, ssl: jelastic.billing.account.GetQuotas('environment.jelasticssl.enabled').array[0].value } - if (${response.ssl} || ${settings.le-addon:false}): setGlobals: PROTOCOL: https setDomain: - script: /scripts/idna.js domains: ${env.domain} - setGlobals: DOMAIN: ${response.domains} setTriggers: - log: Auto Scaling Triggers - script: /scripts/addTriggers.js nodeGroup: cp resourceType: CPU loadGrowth: ${settings.loadGrowth} cleanOldTriggers: true scaleDownLimit: ${nodes.cp.length} initLEsettings: - script: | return { result:0, extIP: Boolean(jelastic.billing.account.GetQuotas('environment.externalip.enabled').array[0].value) } - setGlobals: isExtIP: ${response.extIP} - cmd[cp, bl]: |- [ ! -d /var/lib/jelastic/keys/letsencrypt ] && mkdir -p /var/lib/jelastic/keys/letsencrypt; echo "webroot=false" > /var/lib/jelastic/keys/letsencrypt/settings-custom; echo "webrootPath=/var/www/webroot/ROOT" >> /var/lib/jelastic/keys/letsencrypt/settings-custom; echo "test=false" >> /var/lib/jelastic/keys/letsencrypt/settings-custom; echo "withExtIp=${globals.isExtIP}" >> /var/lib/jelastic/keys/letsencrypt/settings-custom; user: root setupLEdomain: - cmd[${nodes.bl.master.id}]: source /opt/letsencrypt/settings && echo $domain - cmd[${nodes.cp.master.id}]: bash ~/bin/setupWP.sh --url https://${response.out}; optimization: - log: Load Balancers and App servers optimization - install: - jps: https://raw.githubusercontent.com/jelastic/templates/master/config_v2.jps?_r=${fn.random} settings: targetGroup: bl targetNodes: bl optimization: wordpress - jps: https://raw.githubusercontent.com/jelastic/templates/master/config_v2.jps?_r=${fn.random} settings: targetGroup: cp targetNodes: cp optimization: wordpress - cmd[cp, bl]: if test -f /usr/local/sbin/optimization.sh; then bash /usr/local/sbin/optimization.sh &>> /var/log/run.log; fi setPassword: - cmd[cp, bl]: jem passwd set -p ${globals.LS_ADMIN_PASS} user: root storageMount: - log: Mount Storage - api: - method: jelastic.environment.file.AddMountPointByGroup params: nodeGroup: cp sourceNodeId: ${nodes.storage.master.id} sourcePath: /data path: /var/www/webroot/ROOT sourceAddressType: NODE_GROUP protocol: ${this} storageHealthCheck: - cmd[cp]: |- echo "" > /var/www/webroot/ROOT/index.php setupCDN: - script: return jelastic.dev.scripting.Eval("c05ffa5b45628a2a0c95467ebca8a0b4", session, "cdn.info", {partnerCode:1}) - setGlobals: CDN_URL: ${globals.PROTOCOL}://${env.envName}-${response.response.partnerCode}.cdn.jelastic.net/ CDN: ${env.envName}-${response.response.partnerCode}.cdn.jelastic.net SUCCESS: cdn - install: /scripts/setupCDN.jps configureMultisite: - install: /addons/multisite.jps getRedisPswd: - cmd[nosqldb]: cat /etc/redis.conf | tail -1 | awk '{print $2}'; - setGlobals: REDIS_PSWD: ${response.out} installWordpress: - install: /scripts/installWP.jps settings: db_host: ${globals.DB_HOST} db_user: ${globals.DB_USER} db_pass: ${globals.DB_PASS} redis_host: nosqldb redis_port: 6379 redis_user: admin redis_pswd: ${globals.REDIS_PSWD} wp_admin_pass: ${globals.WP_ADMIN_PASS} wp_title: "Hello World" wp_url: ${globals.PROTOCOL}://${globals.DOMAIN}/ version_wordpress: ${globals.version_wordpress} setupCacheSync: - if (/litespeed/.test("${nodes.bl.nodeType}")): - install: /scripts/setupHA4LB.jps?_r=${fn.random} updateTriggers: if (!${event.params.auto:true}): - log: update scaling trigger - script: /scripts/updateTriggers.js count: ${nodes.cp.length} installWoocommerce: cmd[${nodes.cp.master.id}]: |- wp plugin install woocommerce --version=${globals.version_woocommerce} --activate --path=${SERVER_WEBROOT} &>> /var/log/run.log;