Last active
August 29, 2015 14:11
-
-
Save DmZ/23def93e91eac5fc5b15 to your computer and use it in GitHub Desktop.
Version dependency example (platform v35)
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
| application: | |
| configuration: | |
| input.app1-initial: "1" | |
| interfaces: | |
| input: | |
| app1-initial: bind(app1-init#input.app1-initial) | |
| vms: | |
| ips: bind(internal-mux#vms.ips) | |
| init: | |
| get-version: bind(app1-init#actions.get-version) | |
| main: | |
| app1-version: bind(app1-main#version.app1-version) | |
| output: | |
| version: bind(app1-main#result.version) | |
| deploy: bind(app1-main#actions.deploy) | |
| # actions visible on UI | |
| actions: {} | |
| bindings: | |
| - [ internal-mux#result, app1-init#vms ] | |
| - [ internal-mux#result, app1-main#vms ] | |
| components: | |
| internal-mux: | |
| type: workflow.Instance | |
| interfaces: | |
| vms: | |
| ips: consume-signal(list<string>) | |
| result: | |
| ips: publish-signal(list<string>) | |
| required: [ vms ] | |
| configuration: | |
| configuration.propagateStatus: [ propagateIps ] | |
| configuration.triggers: | |
| vms.ips: propagateIps | |
| configuration.workflows: | |
| launch: &launch | |
| steps: | |
| - get-env: | |
| action: getSignals | |
| output: | |
| env: result | |
| return: | |
| ips: | |
| value: "{$.env.vms.ips}" | |
| propagateIps: *launch | |
| app1-init: | |
| type: workflow.Instance | |
| interfaces: | |
| input: | |
| app1-initial: configuration(string) | |
| vms: | |
| ips: consume-signal(list<string>) | |
| result: | |
| version: publish-signal(string) | |
| actions: | |
| get-version: receive-command( => string version) | |
| required: [ vms ] | |
| configuration: | |
| configuration.propagateStatus: [ get-version ] | |
| configuration.triggers: {} | |
| configuration.workflows: | |
| launch: | |
| steps: | |
| - get-env: | |
| action: getSignals | |
| output: | |
| env: result | |
| - provision: | |
| action: provisionVms | |
| precedingPhases: [ get-env ] | |
| parameters: | |
| hardwareId: "" | |
| staticIps: "{$.env.vms.ips}" | |
| - setversion: | |
| action: execrun | |
| precedingPhases: [ provision ] | |
| parameters: | |
| roles: [ default ] | |
| command: | |
| - echo -n "{$.app1-initial}" > /tmp/app1.version | |
| return: | |
| version: | |
| value: "{$.app1-initial}" | |
| get-version: | |
| steps: | |
| - get-version: | |
| action: execrun | |
| parameters: | |
| roles: [ default ] | |
| command: | |
| - cat /tmp/app1.version | |
| output: | |
| stdout: stdout | |
| return: | |
| version: | |
| value: "{$.stdout['*'][0]}" | |
| app1-main: | |
| type: workflow.Instance | |
| interfaces: | |
| input: {} | |
| vms: | |
| ips: consume-signal(list<string>) | |
| version: | |
| app1-version: consume-signal(string) | |
| result: | |
| version: publish-signal(string) | |
| actions: | |
| deploy: receive-command(string version => string version) | |
| required: [ vms, version ] | |
| configuration: | |
| configuration.propagateStatus: [ update ] | |
| configuration.triggers: | |
| version.app1-version: update | |
| configuration.workflows: | |
| update: &update | |
| steps: | |
| - get-env: | |
| action: getSignals | |
| output: | |
| env: result | |
| - provision: | |
| action: provisionVms | |
| precedingPhases: [ get-env ] | |
| parameters: | |
| hardwareId: "" | |
| staticIps: "{$.env.vms.ips}" | |
| - setversion: | |
| action: execrun | |
| precedingPhases: [ provision ] | |
| parameters: | |
| roles: [ default ] | |
| command: | |
| - | | |
| [ "{$.env.version.app1-version}" != "default" ] && echo -n "{$.env.version.app1-version}" > /tmp/app1.version | |
| cat /tmp/app1.version | |
| output: | |
| stdout: stdout | |
| return: | |
| version: | |
| value: "{$.stdout['*'][0]}" | |
| launch: *update | |
| deploy: | |
| steps: | |
| - setversion: | |
| action: execrun | |
| parameters: | |
| roles: [ default ] | |
| command: | |
| - | | |
| [ "{$.version}" != "default" ] && echo -n "{$.version}" > /tmp/app1.version | |
| cat /tmp/app1.version | |
| output: | |
| stdout: stdout | |
| return: | |
| version: | |
| value: "{$.stdout['*'][0]}" |
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
| application: | |
| configuration: | |
| input.app2-initial: "1" | |
| interfaces: | |
| input: | |
| app2-initial: bind(app2-init#input.app2-initial) | |
| vms: | |
| ips: bind(internal-mux#vms.ips) | |
| init: | |
| get-version: bind(app2-init#actions.get-version) | |
| main: | |
| app2-version: bind(app2-main#version.app2-version) | |
| output: | |
| version: bind(app2-main#result.version) | |
| deploy: bind(app2-main#actions.deploy) | |
| # actions visible on UI | |
| actions: {} | |
| bindings: | |
| - [ internal-mux#result, app2-init#vms ] | |
| - [ internal-mux#result, app2-main#vms ] | |
| components: | |
| internal-mux: | |
| type: workflow.Instance | |
| interfaces: | |
| vms: | |
| ips: consume-signal(list<string>) | |
| result: | |
| ips: publish-signal(list<string>) | |
| required: [ vms ] | |
| configuration: | |
| configuration.propagateStatus: [ propagateIps ] | |
| configuration.triggers: | |
| vms.ips: propagateIps | |
| configuration.workflows: | |
| launch: &launch | |
| steps: | |
| - get-env: | |
| action: getSignals | |
| output: | |
| env: result | |
| return: | |
| ips: | |
| value: "{$.env.vms.ips}" | |
| propagateIps: *launch | |
| app2-init: | |
| type: workflow.Instance | |
| interfaces: | |
| input: | |
| app2-initial: configuration(string) | |
| vms: | |
| ips: consume-signal(list<string>) | |
| result: | |
| version: publish-signal(string) | |
| actions: | |
| get-version: receive-command( => string version) | |
| required: [ vms ] | |
| configuration: | |
| configuration.propagateStatus: [ get-version ] | |
| configuration.triggers: {} | |
| configuration.workflows: | |
| launch: | |
| steps: | |
| - get-env: | |
| action: getSignals | |
| output: | |
| env: result | |
| - provision: | |
| action: provisionVms | |
| precedingPhases: [ get-env ] | |
| parameters: | |
| hardwareId: "" | |
| staticIps: "{$.env.vms.ips}" | |
| - setversion: | |
| action: execrun | |
| precedingPhases: [ provision ] | |
| parameters: | |
| roles: [ default ] | |
| command: | |
| - echo -n "{$.app2-initial}" > /tmp/app2.version | |
| return: | |
| version: | |
| value: "{$.app2-initial}" | |
| get-version: | |
| steps: | |
| - get-version: | |
| action: execrun | |
| parameters: | |
| roles: [ default ] | |
| command: | |
| - cat /tmp/app2.version | |
| output: | |
| stdout: stdout | |
| return: | |
| version: | |
| value: "{$.stdout['*'][0]}" | |
| app2-main: | |
| type: workflow.Instance | |
| interfaces: | |
| input: {} | |
| vms: | |
| ips: consume-signal(list<string>) | |
| version: | |
| app2-version: consume-signal(string) | |
| result: | |
| version: publish-signal(string) | |
| actions: | |
| deploy: receive-command(string version => string version) | |
| required: [ vms, version ] | |
| configuration: | |
| configuration.propagateStatus: [ update ] | |
| configuration.triggers: | |
| version.app2-version: update | |
| configuration.workflows: | |
| update: &update | |
| steps: | |
| - get-env: | |
| action: getSignals | |
| output: | |
| env: result | |
| - provision: | |
| action: provisionVms | |
| precedingPhases: [ get-env ] | |
| parameters: | |
| hardwareId: "" | |
| staticIps: "{$.env.vms.ips}" | |
| - setversion: | |
| action: execrun | |
| precedingPhases: [ provision ] | |
| parameters: | |
| roles: [ default ] | |
| command: | |
| - | | |
| [ "{$.env.version.app2-version}" != "default" ] && echo -n "{$.env.version.app2-version}" > /tmp/app2.version | |
| cat /tmp/app2.version | |
| output: | |
| stdout: stdout | |
| return: | |
| version: | |
| value: "{$.stdout['*'][0]}" | |
| launch: *update | |
| deploy: | |
| steps: | |
| - setversion: | |
| action: execrun | |
| parameters: | |
| roles: [ default ] | |
| command: | |
| - | | |
| [ "{$.version}" != "default" ] && echo -n "{$.version}" > /tmp/app2.version | |
| cat /tmp/app2.version | |
| output: | |
| stdout: stdout | |
| return: | |
| version: | |
| value: "{$.stdout['*'][0]}" |
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
| application: | |
| configuration: | |
| input.versionmap: | |
| app1-1: [ app2-1, app2-2 ] | |
| app1-2: [ app2-2, app2-3 ] | |
| app1-3: [ app2-3 ] | |
| input.app1-version: default | |
| input.app2-version: default | |
| input.block: "false" | |
| interfaces: | |
| input: | |
| versionmap: bind(versions#input.versionmap) | |
| app1-version: bind(versions#input.app1-version) | |
| app2-version: bind(versions#input.app2-version) | |
| block: bind(block#input.block) | |
| output: | |
| notice: bind(versions#result.notice) | |
| app1-version: bind(app1#output.version) | |
| app2-version: bind(app2#output.version) | |
| app1-deploy: bind(app1#output.deploy) | |
| app2-deploy: bind(app2#output.deploy) | |
| actions: {} | |
| bindings: | |
| - [ vms, versions ] | |
| - [ vms, app1#vms ] | |
| - [ vms, app2#vms ] | |
| - [ vms, block ] | |
| - [ block, versions ] | |
| - [ versions#app1, app1#init ] | |
| - [ block#result, app1#main ] | |
| - [ versions#app2, app2#init ] | |
| - [ block#result, app2#main ] | |
| components: | |
| ########### | |
| # App1 | |
| ########### | |
| app1: | |
| type: reference.Submodule | |
| configuration: | |
| __locator.application-id: "Versions app1" | |
| required: [ vms, main ] | |
| interfaces: | |
| vms: | |
| ips: consume-signal(list<string>) | |
| init: | |
| get-version: receive-command( => string version) | |
| main: | |
| app1-version: consume-signal(string) | |
| output: | |
| version: publish-signal(string) | |
| deploy: receive-command(string version => string version) | |
| ########### | |
| # App2 | |
| ########### | |
| app2: | |
| type: reference.Submodule | |
| configuration: | |
| __locator.application-id: "Versions app2" | |
| required: [ vms, main ] | |
| interfaces: | |
| vms: | |
| ips: consume-signal(list<string>) | |
| init: | |
| get-version: receive-command( => string version) | |
| main: | |
| app2-version: consume-signal(string) | |
| output: | |
| version: publish-signal(string) | |
| deploy: receive-command(string version => string version) | |
| ########### | |
| # Provisioner | |
| ########### | |
| vms: | |
| type: workflow.Instance | |
| interfaces: | |
| input: {} | |
| result: | |
| ips: publish-signal(list<string>) | |
| actions: {} | |
| required: [] | |
| configuration: | |
| configuration.propagateStatus: [] | |
| configuration.triggers: {} | |
| configuration.workflows: | |
| launch: | |
| steps: | |
| - provision-node: | |
| action: provisionAmazonVm | |
| parameters: | |
| roleName: "default" | |
| imageId: "us-east-1/ami-ee698586" | |
| hardwareId: m1.small | |
| vmIdentity: root | |
| targetQuantity: 1 | |
| output: | |
| ips: ips | |
| return: | |
| ips: | |
| value: "{$.ips}" | |
| ########### | |
| # Version control | |
| ########### | |
| versions: | |
| type: workflow.Instance | |
| interfaces: | |
| input: | |
| versionmap: configuration(map<string, object>) | |
| app1-version: configuration(string) | |
| app2-version: configuration(string) | |
| app1: | |
| get-version: send-command( => string version) | |
| app2: | |
| get-version: send-command( => string version) | |
| vms: | |
| ips: consume-signal(list<string>) | |
| result: | |
| notice: publish-signal(string) | |
| app1-version: publish-signal(string) | |
| app2-version: publish-signal(string) | |
| actions: {} | |
| required: [ vms, app1, app2 ] | |
| configuration: | |
| configuration.propagateStatus: [ update ] | |
| configuration.triggers: | |
| input.app1-version: update | |
| input.app2-version: update | |
| configuration.workflows: | |
| launch: &launch | |
| steps: | |
| - get-env: | |
| action: getSignals | |
| output: | |
| env: result | |
| - get-app1-version: | |
| action: app1.get-version | |
| phase: get-version | |
| output: | |
| app1-real-version: version | |
| - get-app2-version: | |
| action: app2.get-version | |
| phase: get-version | |
| output: | |
| app2-real-version: version | |
| - provision: | |
| action: provisionVms | |
| precedingPhases: [ get-env ] | |
| parameters: | |
| hardwareId: "" | |
| staticIps: "{$.env.vms.ips}" | |
| - serialize1: | |
| action: serialize | |
| phase: serialize | |
| precedingPhases: [ provision ] | |
| parameters: | |
| format: CSV | |
| input: "{$.versionmap}" | |
| output: | |
| s1: serialized | |
| - serialize2: | |
| action: serialize | |
| phase: serialize | |
| precedingPhases: [ provision ] | |
| parameters: | |
| format: CSV | |
| input: | |
| app1: "{$.app1-version}" | |
| app2: "{$.app2-version}" | |
| output: | |
| s2: serialized | |
| - run-script: | |
| action: execrun | |
| precedingPhases: [ serialize, get-version ] | |
| parameters: | |
| roles: [ default ] | |
| command: | |
| - | | |
| REGEXP=`echo '{$.s2}' | sed -e 's/,/-/;s/"//g;s/app1-default/app1-{$.app1-real-version}/;s/app2-default/app1-{$.app2-real-version}/'` | |
| VERSIONS=`echo '{$.s1}' | tr -d '"'` | |
| for r in $$REGEXP; do | |
| VERSIONS=`echo "$$VERSIONS" | grep "$$r"` | |
| done | |
| if [ `echo -n "$$VERSIONS" | wc -c` -ne 0 ]; then | |
| echo "Versions seems compatible"; | |
| else | |
| echo "WARNING: component versions are incompatible!"; | |
| fi | |
| output: | |
| stdout: stdout | |
| return: | |
| notice: | |
| value: "{$.stdout['*'][0]}" | |
| app1-version: | |
| value: "{$.app1-version}" | |
| app2-version: | |
| value: "{$.app2-version}" | |
| update: *launch | |
| block: | |
| type: workflow.Instance | |
| interfaces: | |
| input: | |
| block: configuration(string) | |
| vms: | |
| ips: consume-signal(list<string>) | |
| versions: | |
| notice: consume-signal(string) | |
| app1-version: consume-signal(string) | |
| app2-version: consume-signal(string) | |
| result: | |
| app1-version: publish-signal(string) | |
| app2-version: publish-signal(string) | |
| required: [ versions, vms ] | |
| configuration: | |
| configuration.propagateStatus: [ block ] | |
| configuration.triggers: | |
| versions.notice: block | |
| versions.app1-version: block | |
| versions.app2-version: block | |
| configuration.workflows: | |
| launch: &launch | |
| steps: | |
| - get-env: | |
| action: getSignals | |
| output: | |
| env: result | |
| - provision: | |
| action: provisionVms | |
| precedingPhases: [ get-env ] | |
| parameters: | |
| roleName: default | |
| hardwareId: "" | |
| staticIps: "{$.env.vms.ips}" | |
| - check: | |
| action: execrun | |
| precedingPhases: [ provision ] | |
| parameters: | |
| roles: [ default ] | |
| command: | |
| - | | |
| if [ "{$.block}" == "true" ]; then | |
| exit `echo "{$.env.versions.notice}" | grep -c WARNING` | |
| fi | |
| exit 0 | |
| return: | |
| app1-version: | |
| value: "{$.env.versions.app1-version}" | |
| app2-version: | |
| value: "{$.env.versions.app2-version}" | |
| block: *launch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment