CORD-807
prep for removal of gradle from platform-install
reorder and fix path
fix gradle ordering issues
run ansible locally on head node
syntax/bugfixes
bugfix
various fixes
chown /opt/cord from gradle
Change-Id: I7b8cb9019a783715ee07b609bce7ade74825af58
diff --git a/ansible/prod-inv b/ansible/prod-inv
new file mode 100644
index 0000000..4fe6f8d
--- /dev/null
+++ b/ansible/prod-inv
@@ -0,0 +1,6 @@
+[head]
+${prod}
+
+[compute]
+
+
diff --git a/build.gradle b/build.gradle
index b07e1d7..aa0c3a6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,6 +16,7 @@
import org.opencord.gradle.rules.*
import org.yaml.snakeyaml.Yaml
+import org.yaml.snakeyaml.DumperOptions
buildscript {
repositories {
@@ -31,7 +32,6 @@
apply plugin: "com.dorongold.task-tree"
evaluationDependsOn(':maas')
-evaluationDependsOn(':platform-install')
evaluationDependsOn(':onos-apps')
allprojects {
@@ -144,11 +144,44 @@
// ---------------- Useful tasks ----------------
+task copyAnsibleInventory(type: Copy) {
+ from 'platform-install/inventory/templates/single-prod'
+ into 'platform-install/inventory'
+ expand([
+ prod: config.seedServer.ip,
+ ])
+}
+
+task writeYamlConfig {
+ def outvar = config.seedServer
+ def outfilename = "genconfig/config.yml"
+
+ DumperOptions options = new DumperOptions()
+
+ options.setExplicitStart(true);
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK)
+ options.setPrettyFlow(true);
+ options.setIndent(2);
+
+ def yaml = new Yaml(options)
+ Writer outfile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfilename), "utf-8"))
+
+ yaml.dump(outvar, outfile)
+ outfile.close()
+}
+
+task writeProdInventory(type: Copy) {
+ from 'ansible/prod-inv'
+ into 'genconfig'
+ expand([
+ prod: config.seedServer.ip,
+ ])
+}
+
task fetchUpstreamImages {
comps.each { name, spec -> if (spec.type == 'image') { dependsOn "fetch" + name } }
}
-
task fetch {
dependsOn fetchUpstreamImages
}
@@ -172,13 +205,95 @@
tasks.addRule(new DockerPublishRule(project, project(':maas').prime))
tasks.addRule(new DockerTagRule(project))
-project('platform-install').deployPlatform.dependsOn project(':maas').deployBase
+task CopyCord(type: Exec) {
+ dependsOn writeYamlConfig
+ dependsOn writeProdInventory
+
+ executable = "ansible"
+ args = [ "-i", "genconfig/prod-inv", "-b", "-m", "synchronize", "-a", "src='../../' dest='/opt/cord'", "head" ]
+}
+
+task ChownCord(type: Exec) {
+ dependsOn CopyCord
+
+ executable = "ansible"
+ args = [ "-i", "genconfig/prod-inv", "-b", "-m", "file", "-a", "state='directory' dest='/opt/cord' recurse='yes' owner='$config.seedServer.ansible_user'", "head" ]
+}
+
+task PIprepPlatform(type: Exec) {
+ dependsOn CopyCord
+ dependsOn ChownCord
+
+ def ansible_cmd = "cd /opt/cord/build/platform-install; ansible-playbook -i inventory/head-localhost --extra-vars @/opt/cord/build/genconfig/config.yml cord-prep-platform.yml"
+
+ executable = "ssh"
+ args = ["$config.seedServer.ansible_user@$config.seedServer.ip", ansible_cmd ]
+}
+
+task PIdeployOpenStack (type: Exec) {
+ def ansible_cmd = "cd /opt/cord/build/platform-install; ansible-playbook -i inventory/head-localhost --extra-vars @/opt/cord/build/genconfig/config.yml cord-deploy-openstack.yml"
+
+ executable = "ssh"
+ args = ["$config.seedServer.ansible_user@$config.seedServer.ip", ansible_cmd ]
+}
+
+task PIdeployONOS (type: Exec) {
+ def ansible_cmd = "cd /opt/cord/build/platform-install; ansible-playbook -i inventory/head-localhost --extra-vars @/opt/cord/build/genconfig/config.yml cord-deploy-onos.yml"
+
+ executable = "ssh"
+ args = ["$config.seedServer.ansible_user@$config.seedServer.ip", ansible_cmd ]
+}
+
+task PIdeployXOS (type: Exec) {
+ def ansible_cmd = "cd /opt/cord/build/platform-install; ansible-playbook -i inventory/head-localhost --extra-vars @/opt/cord/build/genconfig/config.yml cord-deploy-xos.yml"
+
+ executable = "ssh"
+ args = ["$config.seedServer.ansible_user@$config.seedServer.ip", ansible_cmd ]
+}
+
+task PIsetupAutomation (type: Exec) {
+ def ansible_cmd = "cd /opt/cord/build/platform-install; ansible-playbook -i inventory/head-localhost --extra-vars @/opt/cord/build/genconfig/config.yml cord-automation.yml"
+
+ executable = "ssh"
+ args = ["$config.seedServer.ansible_user@$config.seedServer.ip", ansible_cmd ]
+}
+
+task postDeployTests (type: Exec) {
+
+ def ansible_cmd = "cd /opt/cord/build/platform-install; ansible-playbook -i inventory/head-localhost --extra-vars @/opt/cord/build/genconfig/config.yml cord-post-deploy-playbook.yml"
+
+ executable = "ssh"
+ args = ["$config.seedServer.ansible_user@$config.seedServer.ip", ansible_cmd ]
+}
+
project('onos-apps').publishMavenRepoImage.dependsOn project(':maas').prime
-project('platform-install').deployPlatform.dependsOn project(':onos-apps').deploy
project(':onos-apps').deploy.dependsOn project(':maas').deployBase
+project('onos-apps').publishMavenRepoImage.dependsOn project(':maas').prime
+project(':onos-apps').deploy.dependsOn project(':maas').deployBase
+
+task PIdeployPlatform {
+ dependsOn CopyCord
+ dependsOn ChownCord
+ dependsOn project(':onos-apps').deploy
+ dependsOn project(':maas').deployBase
+ dependsOn PIprepPlatform
+ dependsOn PIdeployOpenStack
+ dependsOn PIdeployONOS
+ dependsOn PIdeployXOS
+ dependsOn PIsetupAutomation
+}
+
+ChownCord.mustRunAfter CopyCord
+PIprepPlatform.mustRunAfter ChownCord
+PIdeployOpenStack.mustRunAfter PIprepPlatform
+PIdeployONOS.mustRunAfter PIdeployOpenStack
+PIdeployXOS.mustRunAfter PIdeployONOS
+PIsetupAutomation.mustRunAfter PIdeployXOS
+PIdeployPlatform.mustRunAfter project(':onos-apps').deploy
+PIdeployPlatform.mustRunAfter project(':maas').deployBase
task deploy {
- dependsOn << project(':platform-install').deployPlatform
+ dependsOn PIdeployPlatform
}