haas 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e8a464110c902c14ef830dc3a2171248f3aa258
4
- data.tar.gz: 760ca88c7ee422e94b7be779b258d142f1381730
3
+ metadata.gz: ee3233c4653204b2dd02276bb560df79ee96bb79
4
+ data.tar.gz: 70f99df4a7b12194e9385913b6df379485ce20f1
5
5
  SHA512:
6
- metadata.gz: 35e900d38e69ca79d7a20c66e27fb2d598b6abe001396bbaa29b85eea601f1165012bcfd10d340f8bc96a2d344480e712e049350af71393d9c0e883bc3269864
7
- data.tar.gz: 671575fd90a0a218452f868e580d2f164364eb8baa53ce156b3ce07d4d1ad521faf8e9215f438dd8f4926318adfbcce432994bb51acd30d7b31eeffb2167cf24
6
+ metadata.gz: 6a93748184eb48c0f7dc2d9f5d1aba8517e6b3a824db71697ea9a653ee374b066d4dc3e5fa6a7fc5be8d388412a8a51311572b6f00eb14ca6063f0273617da0e
7
+ data.tar.gz: a12e34aa46fc992f8030b20504e4e18a554fda6de4156809abe484d5282bf63eb8dc2a499f7cc747a5251e348fc0c90d1893a3b086d36b870be4c57b664510b9
data/lib/haas.rb CHANGED
@@ -13,7 +13,8 @@ class Haas
13
13
  Haas::Aws.connect
14
14
  @cluster=Haas::Cluster.create(
15
15
  :aws_region => Haas::Aws.region,
16
- :ssh_user => "root"
16
+ :ssh_user => Haas::Aws.ssh_user,
17
+ :distro => "ubuntu12"
17
18
  )
18
19
  if Haas::Aws.nb_instance_available >= Haas::Config.options[:nb_instances].to_i
19
20
  Haas::Aws.create_key_pair
data/lib/haas/aws.rb CHANGED
@@ -4,6 +4,10 @@ class Haas
4
4
  class Aws
5
5
  CENTOS_IMAGES = {
6
6
  "6.5" => {
7
+ "config" => {
8
+ "ssh_user" => "root",
9
+ "root_device" => "/dev/sda"
10
+ },
7
11
  "us-east-1"=>"ami-8997afe0",
8
12
  "us-west-2"=>"ami-b6bdde86",
9
13
  "us-west-1"=>"ami-1a013c5f",
@@ -14,6 +18,10 @@ class Haas
14
18
  "sa-east-1"=>"ami-7d02a260"
15
19
  },
16
20
  "7" => {
21
+ "config" => {
22
+ "ssh_user" => "root",
23
+ "root_device" => "/dev/sda"
24
+ },
17
25
  "us-east-1"=>"ami-96a818fe",
18
26
  "us-west-2"=>"ami-c7d092f7",
19
27
  "us-west-1"=>"ami-6bcfc42e",
@@ -25,6 +33,24 @@ class Haas
25
33
  }
26
34
  }
27
35
 
36
+ UBUNTU_IMAGES = {
37
+ "12.04" => {
38
+ "config" => {
39
+ "ssh_user" => "ubuntu",
40
+ "root_device" => "/dev/sda1"
41
+ },
42
+ "ap-northeast-1" => "ami-f96b40f8",
43
+ "ap-southeast-1" => "ami-da1e3988",
44
+ "eu-central-1" => "ami-643c0a79",
45
+ "eu-west-1" => "ami-6ca1011b",
46
+ "sa-east-1" => "ami-11d4610c",
47
+ "us-east-1" => "ami-34cc7a5c",
48
+ "us-west-1" => "ami-b7515af2",
49
+ "ap-southeast-2" => "ami-9f0e6ca5",
50
+ "us-west-2" => "ami-0f47053f"
51
+ }
52
+ }
53
+
28
54
  def self.connect
29
55
  @region = Haas::Config.options[:aws_region] || 'us-east-1'
30
56
  AWS.config(
@@ -43,6 +69,10 @@ class Haas
43
69
  @region
44
70
  end
45
71
 
72
+ def self.ssh_user
73
+ UBUNTU_IMAGES["12.04"]["config"]["ssh_user"]
74
+ end
75
+
46
76
  def self.nb_instance_available
47
77
  account_attributes = ec2.client.describe_account_attributes\
48
78
  .data[:account_attribute_set]\
@@ -65,7 +95,7 @@ class Haas
65
95
  end
66
96
 
67
97
  def self.launch_instances
68
- image_id = CENTOS_IMAGES["6.5"][region]
98
+ image_id = UBUNTU_IMAGES["12.04"][region]
69
99
 
70
100
  if !ec2.security_groups.filter('group-name', 'haas-security-group').first
71
101
  security_group = ec2.security_groups.create('haas-security-group')
@@ -85,7 +115,7 @@ class Haas
85
115
  :security_groups => ['haas-security-group'],
86
116
  :block_device_mappings => [
87
117
  {
88
- :device_name => "/dev/sda",
118
+ :device_name => "/dev/sda1",
89
119
  :ebs => {
90
120
  :volume_size => 8, # 8 GiB
91
121
  :delete_on_termination => true
@@ -28,17 +28,22 @@ class Haas
28
28
 
29
29
  def self.get_blueprint
30
30
  {
31
+ "configurations" => [
32
+ {
33
+ "hive-site"=> {
34
+ "javax.jdo.option.ConnectionPassword"=> "hive"
35
+ }
36
+ },
37
+ {
38
+ "nagios-env" => {
39
+ "nagios_contact" => "admin@localhost"
40
+ }
41
+ }
42
+ ],
31
43
  "host_groups" => [
32
44
  {
33
45
  "name" => "master",
34
- "configurations" => [
35
- {
36
- "global" => {
37
- "nagios_contact" => "me@my-awesome-domain.example"
38
- }
39
- }
40
- ],
41
- "components" => [
46
+ "components" => [
42
47
  {
43
48
  "name" => "NAMENODE"
44
49
  },
@@ -62,6 +67,9 @@ class Haas
62
67
  },
63
68
  {
64
69
  "name" => "GANGLIA_MONITOR"
70
+ },
71
+ {
72
+ "name" => "APP_TIMELINE_SERVER"
65
73
  }
66
74
  ],
67
75
  "cardinality" => "1"
@@ -96,7 +104,7 @@ class Haas
96
104
  ],
97
105
  "Blueprints" => {
98
106
  "stack_name" => "HDP",
99
- "stack_version" => "2.1"
107
+ "stack_version" => "2.2"
100
108
  }
101
109
  }
102
110
  end
data/lib/haas/chef.rb CHANGED
@@ -6,7 +6,10 @@ class Haas
6
6
  def self.setup_cluster
7
7
  install_chef_server
8
8
  write_knife_config_file
9
- cookbooks=[{'name' => 'ambari','url' => "https://supermarket.getchef.com/cookbooks/ambari/download" }]
9
+ cookbooks=[
10
+ {'name' => 'ambari', 'url' => "https://supermarket.getchef.com/cookbooks/ambari/download" },
11
+ {'name' => 'apt', 'url' => "https://supermarket.getchef.com/cookbooks/apt/download" }
12
+ ]
10
13
  cookbooks.each do |cb|
11
14
  download_cookbook cb['name'], cb['url']
12
15
  end
@@ -19,16 +22,20 @@ class Haas
19
22
  threads.each { |thr| thr.join }
20
23
  end
21
24
 
25
+ def self.chef_install_cmd
26
+ install_cmd = {
27
+ 'centos6' => 'curl https://packagecloud.io/install/repositories/chef/stable/script.rpm | sudo bash && sudo yum install chef-server-core-12.0.0-1.el6.x86_6',
28
+ 'ubuntu12' => 'curl https://packagecloud.io/install/repositories/chef/stable/script.deb | sudo bash && sudo apt-get install chef-server-core=12.0.0-1'
29
+ }
30
+ install_cmd[Haas.cluster.distro]
31
+ end
32
+
22
33
  def self.install_chef_server
23
34
  require 'net/ssh'
24
35
  chef_server = Haas.cluster.get_chef_server
25
- user = Haas.cluster.ssh_user
26
- chef_server_file = "chef-server-core-12.0.0_rc.5-1.el5.x86_64.rpm"
27
- chef_server_url = "https://packagecloud.io/chef/stable/download?distro=6&filename=#{chef_server_file}"
28
- chef_server_local_path = "/tmp/#{chef_server_file}"
29
36
 
30
37
  Net::SSH.start(
31
- chef_server.public_dns_name, user,
38
+ chef_server.public_dns_name, Haas.cluster.ssh_user,
32
39
  :host_key => "ssh-rsa",
33
40
  :encryption => "blowfish-cbc",
34
41
  :keys => [ Haas.cluster.identity_file_path ],
@@ -36,26 +43,21 @@ class Haas
36
43
  ) do |ssh|
37
44
  puts "Entering chef server installation on the node #{chef_server.public_dns_name}. This may take a while."
38
45
  puts "Disable iptables"
39
- ssh.exec!("service iptables stop")
46
+ ssh.exec!("sudo service iptables stop")
40
47
  puts "Downloading and installing the chef server."
41
- ssh.exec!(%{
42
- until curl -L '#{chef_server_url}' -o #{chef_server_local_path} && rpm -ivh #{chef_server_local_path}; do
43
- echo "installing chef server";
44
- done
45
- })
46
- ssh.exec!("rpm -ivh #{chef_server_local_path}")
48
+ ssh.exec!(self.chef_install_cmd)
47
49
  puts "Configuring chef server."
48
- ssh.exec!("mkdir -p /etc/opscode/")
49
- ssh.exec!(%{echo "nginx['non_ssl_port'] = false" >> /etc/opscode/chef-server.rb})
50
- ssh.exec!("chef-server-ctl reconfigure")
50
+ ssh.exec!("sudo mkdir -p /etc/opscode/")
51
+ ssh.exec!(%{sudo bash -c "echo \\"nginx['non_ssl_port'] = false\\" >> /etc/opscode/chef-server.rb"})
52
+ ssh.exec!("sudo chef-server-ctl reconfigure")
51
53
 
52
54
  client_key = ""
53
55
  while !client_key.include?("BEGIN RSA PRIVATE KEY") do
54
- client_key = ssh.exec!("chef-server-ctl user-create haas-api HAAS Api haas@ossom.io abc123")
56
+ client_key = ssh.exec!("sudo chef-server-ctl user-create haas-api HAAS Api haas@ossom.io abc123")
55
57
  end
56
58
  File.write(Haas.cluster.chef_client_pem_path, client_key)
57
59
 
58
- org_validator_key = ssh.exec!("chef-server-ctl org-create haas Hadoop as a Service --association_user haas-api")
60
+ org_validator_key = ssh.exec!("sudo chef-server-ctl org-create haas Hadoop as a Service --association_user haas-api")
59
61
  File.write(Haas.cluster.chef_validator_pem_path, org_validator_key)
60
62
  end
61
63
  end
@@ -90,13 +92,12 @@ class Haas
90
92
 
91
93
  puts "Bootstrapping node #{node.public_dns_name}"
92
94
 
93
- user = Haas.cluster.ssh_user
94
95
  run_list = ["recipe[ambari::agent]"]
95
96
  run_list << "recipe[ambari::server]" if node.ambari_server
96
97
 
97
98
  Chef::Config.from_file(Haas.cluster.knife_config_path)
98
99
  kb = Chef::Knife::Bootstrap.new
99
- kb.config[:ssh_user] = user
100
+ kb.config[:ssh_user] = Haas.cluster.ssh_user
100
101
  kb.config[:run_list] = run_list
101
102
  kb.config[:use_sudo] = true
102
103
  kb.config[:identity_file] = Haas.cluster.identity_file_path
data/lib/haas/config.rb CHANGED
@@ -36,6 +36,7 @@ class Haas
36
36
  table.column :name, :string
37
37
  table.column :aws_region, :string
38
38
  table.column :ssh_user, :string
39
+ table.column :distro, :string
39
40
  end
40
41
  add_index :clusters, :name, unique: true
41
42
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Pellet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-22 00:00:00.000000000 Z
11
+ date: 2014-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.1'
19
+ version: 4.1.8
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.1'
26
+ version: 4.1.8
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement