forked from Netflix-Skunkworks/zerotocloud
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
84 lines (70 loc) · 2.45 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.netflix.nebula:gradle-ospackage-plugin:1.12.+'
classpath 'com.netflix.nebula:nebula-ospackage-plugin:1.12.+'
classpath 'com.google.guava:guava:17.0'
classpath 'com.netflix.nebula:gradle-info-plugin:1.12.+'
classpath 'com.netflix.nebula:nebula-core:1.12.+' // For Download
classpath 'de.undercouch:gradle-download-task:1.0'
}
}
import nebula.plugin.info.reporting.*
subprojects {
apply plugin: 'info'
apply plugin: 'os-package'
// Ensure at least one file is included in package, always
tasks.withType(InfoPropertiesFile) { propTask ->
ospackage {
from(propTask) {
into('/etc')
}
}
}
task bake(type: Exec) {
String baseami = System.getProperty("baseami", "ubuntu-base-ami-ebs");
executable "sudo"
args "aminate", "-e", "ec2_aptitude_linux", "-b", baseami, \
"build/distributions/${project.name}_1.0.0_all.deb"
}
bake.dependsOn = [buildDeb]
}
def region = project.hasProperty('region') ? property.region : 'us-west-2'
def home = new File(System.getenv('HOME'))
task writeConfig << {
def csvFile = new File(home, 'credentials.csv')
def line = csvFile.text.split('\n')[1]
def parts = line.split(',')
def cfgFile = new File(home, '.boto')
cfgFile.withWriter { out ->
out << """
[Credentials]
aws_access_key_id = ${parts[1]}
aws_secret_access_key = ${parts[2]}
""".stripIndent()
}
def awsFile = new File(home, '.aws')
awsFile.mkdir()
def configFile = new File(awsFile, 'config')
configFile.withWriter { out ->
out << """
[default]
aws_access_key_id = ${parts[1]}
aws_secret_access_key = ${parts[2]}
region = us-west-2
""".stripIndent()
}
def asgardHome = new File(home, '.asgard')
asgardHome.mkdir()
def asgardConfig = new File(asgardHome, 'Config.groovy')
def accountNumber = System.getenv('EC2_OWNER_ID')
asgardConfig.withWriter { out ->
out << project('asgard').file('root/usr/share/tomcat7/.asgard/Config.groovy').text.replace("@ACCOUNT_NUMBER@", accountNumber)
out << """
secret {
accessId="${parts[1]}"
secretKey="${parts[2]}"
}
""".stripIndent()
}
}