-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision
executable file
·33 lines (27 loc) · 1.15 KB
/
provision
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
#!/usr/bin/env ruby
__DIR__ = File.expand_path(File.dirname(__FILE__) + "/../ops")
target = ARGV[0]
unless ["tomcat", "web"].include?(target)
raise "Please specify $ ./bin/provision tomcat (create|update) (staging|production) or $ ./bin/provision web (create|update) (staging|production)"
end
action = ARGV[1]
unless ["create", "update"].include?(action)
raise "Please specify $ ./bin/provision (tomcat|web) create (staging|production )or $ ./bin/provision (tomcat|web) update (staging|production)"
end
environment = ARGV[2]
unless ["staging", "production"].include?(environment)
raise "Please specify $ ./bin/provision (tomcat|web) (create|update) staging or $ ./bin/provision (tomcat|web) (create|update) production"
end
tag = []
extras = ""
if action == "create"
action = "create_ec2.yml"
extras = "--extra-vars \"hosts=#{target} aws_tag=#{environment}\""
tag << "-l \"localhost,tag_Compound_#{target}_#{environment}\""
else
action = "configure.yml"
tag << "-l tag_Compound_#{target}_#{environment}"
end
command = "cd #{__DIR__} && ansible-playbook -i ec2.py #{tag.join(' ')} --private-key ./keys/hydra.pem #{action} #{extras}"
puts command
exec command