Add create_staging
Clone selected live environment, create a database backup and mount the /var/www/webroot/ROOT of the live environment in the /var/www/webroot/sourcefiles folder of the clone.main
commit
658aefb7b7
|
@ -0,0 +1,137 @@
|
|||
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
|
||||
|
||||
|
||||
|
||||
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
|
||||
addons:
|
||||
- id: LiveSync
|
||||
targetNodes:
|
||||
envName: ${settings.sourceEnv}
|
||||
nodeGroup: ${settings.nodeGroup}
|
||||
|
||||
onInstall:
|
||||
|
||||
writeFile:
|
||||
- nodeGroup: ${settings.nodeGroup}
|
||||
path: /var/www/webroot/ROOT/sycfromlive.sh
|
||||
body: '#!/bin/bash
|
||||
|
||||
cp -R -u /var/www/webroot/sourcefiles/* /var/www/webroot/ROOT
|
||||
|
||||
wp db import /var/www/webroot/sourcefiles/dbexport/dbexport.sql --path=/var/www/webroot/ROOT/ --quiet
|
||||
'
|
||||
cmd [cp]:
|
||||
- chmod 701 /var/www/webroot/ROOT/sycfromlive.sh
|
||||
|
||||
actions:
|
||||
liveSync:
|
||||
cmd [cp]:
|
||||
|
||||
- /var/www/webroot/ROOT/sycfromlive.sh
|
||||
|
||||
user: root
|
||||
sayYes: true
|
||||
buttons:
|
||||
- caption: Sync From Live
|
||||
action: liveSync
|
||||
loadingText: Syching from live...
|
||||
confirmText: Do you want to initiate sync process?
|
||||
successText: The syching process has been finished successfully.
|
Loading…
Reference in New Issue