diff --git a/Create_Staging_With_Addon b/Create_Staging_With_Addon new file mode 100644 index 0000000..28a170f --- /dev/null +++ b/Create_Staging_With_Addon @@ -0,0 +1,135 @@ +type: install +name: Staging Environment +description: Create staging environment from selected live environment +logo: https://d33v4339jhl8k0.cloudfront.net/docs/assets/629d6154f38bfd3f4a4c3046/images/62ce4ffaeabe9a7235b3d220/white-300.png +skipNodeEmails: false + +settings: + fields: + - caption: Target Environment + editable: true + type: envlist + name: sourceEnv + valueField: shortdomain + tooltip: Select the Target Environment + - type: string + name: nodeGroup + caption: Node Group + default: cp + hideLabel: true + hidden: true + - caption: Display Name + editable: true + type: string + name: displayName + default: My Environment + tooltip: Enter the desired display name for the environment + - caption: Environment Name + type: envname + name: stagingEnv + randomName: true + showFullDomain: true + hidden: false + dependsOn: regionFieldName + displayName: ${settings.displayName} + + + +onInstall: + - initNodes: + envName: ${settings.sourceEnv} + namespace: sourceEnv + - cloneSource + - remoteOperations: + envName: ${settings.sourceEnv} + nodeGroup: ${settings.nodeGroup} + cmd: |- + + mkdir /var/www/webroot/ROOT/dbexport + touch /var/www/webroot/ROOT/dbexport/dbexport.sql + wp db export /var/www/webroot/ROOT/dbexport/dbexport.sql --path=/var/www/webroot/ROOT/ --quiet + user: root + sayYes: true + - initNodes: + envName: ${settings.stagingEnv} + namespace: stagingEnv + + - mountLive: NFS4 + - installSyncAddon + + + +actions: + initNodes: + envName: ${this.envName} + namespace: ${this.namespace} + script: | + let nodes = {}, resp = api.env.control.GetEnvInfo(envName, session) + if (resp.result != 0) return resp + resp.nodes.sort((node1, node2) => node1.id - node2.id) + for (let node of resp.nodes) { + nodes[node.nodeGroup] = nodes[node.nodeGroup] || [] + nodes[node.nodeGroup].push(node) + } + let globals = {} + globals[namespace] = nodes + return { result: 0, onAfterReturn: { setGlobals: globals } } + + cloneSource: + - env.control.CloneEnv: + envName: ${settings.sourceEnv} + srcEnvName: ${settings.sourceEnv} + dstEnvName: ${settings.stagingEnv} + useExternalMounts: false + + remoteOperations: + env.control.ExecCmdByGroup: + envName: ${settings.sourceEnv} + nodeGroup: ${this.nodeGroup} + commandList: + - command: ${this.cmd} + + + + mountLive: + - log: Mount Storage + - env.file.AddMountPointById: + envName: ${settings.stagingEnv} + nodeId: ${globals.stagingEnv.cp[0].id} + path: /var/www/webroot/sourcefiles + protocol: nfs4 + sourcePath: /var/www/webroot/ROOT + sourceNodeId: ${globals.sourceEnv.cp[0].id} + name: LiveFilesMount + readOnly: false + + installSyncAddon: + + install: + envName: ${settings.stagingEnv} + nodeGroup: cp + jps: + type: update + name: Sync From Live + description: Sync from live website + + actions: + LiveSync: + - env.control.ExecCmdByGroup: + envName: ${settings.sourceEnv} + nodeGroup: cp + commandList: + - command: |- + date >> /home/jelastic/date.log + - cmd [cp] : |- + date >> /home/jelastic/date2.log + + + + + buttons: + - caption: Sync From Live + action: LiveSync + confirmText: Do you want to initiate sync process? + loadingText: Syching from live... + successText: The syching process has been finished successfully. \ No newline at end of file