stack-kicker 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -94,7 +94,11 @@ This can be an array of strings, such that node X will be assigned :floating_ips
94
94
  These are used to construct a command to execute, which is executed locally where you executed stack-kicker. :post_install_args can contain %PUBLIC_IP%, which will be replaced by the public IP of the just created node. :post_install_script scripts are executed as soon the the instance returns a status='ACTIVE'. They can be used delay the creation of further nodes of the same role (for example, when creating a rabbitmq cluster, you need to wait for the rabbitmq process to be running before creating the next member of the cluster, or when you are creating a chef-server, you need to wait for the packages to install & daemons to start before attempting to create Chef users & retrieve keys)
95
95
 
96
96
  ## [ERB Templates](id:erbtemplates)
97
- Both the :cloud_config_yaml & :bootstrap role attributes can point to plain files, files with simple tokens (%HOSTNAME%, %CHEF_SERVER%, %CHEF_ENVIRONMENT%, %CHEF_VALIDATION_PEM%, %SERVER_NAME%, %ROLE% and %DATA_DIR%) or [Ruby ERB](http://www.ruby-doc.org/stdlib-2.0/libdoc/erb/rdoc/ERB.html) templates.
97
+ Both the :cloud_config_yaml & :bootstrap role attributes can point to plain files, files with simple tokens (%HOSTNAME%, %CHEF_SERVER%, %CHEF_SERVER_HOSTNAME%, %CHEF_ENVIRONMENT%, %CHEF_VALIDATION_PEM%, %SERVER_NAME%, %ROLE% and %DATA_DIR%) or [Ruby ERB](http://www.ruby-doc.org/stdlib-2.0/libdoc/erb/rdoc/ERB.html) templates.
98
+
99
+ %HOSTNAME% is the short name of the instance being built
100
+ %CHEF_SERVER% is the IP address of the Chef Server, private address if the chef server & current instance are in the same AZ, public IP if they are in different AZs
101
+ %CHEF_SERVER_HOSTNAME% name of the chef server, Fully Qualified if config[:domain] is set
98
102
 
99
103
  There are 3 key data sets exposed to the ERB templates:
100
104
 
@@ -0,0 +1,6 @@
1
+ ```
2
+ stack-kicker show-stacks
3
+ stack-kicker show-stack
4
+ stack-kicker show-running
5
+ stack-kicker build
6
+ ```
@@ -0,0 +1,40 @@
1
+ module StackConfig
2
+ Stacks = Hash.new
3
+
4
+ Stacks['apache-cloud-init'] = {
5
+ # (we can access environment variable via ENV['foo'] instead of hard coding u/p here)
6
+ 'REGION' => ENV['OS_REGION_NAME'],
7
+ 'USERNAME' => ENV['OS_USERNAME'],
8
+ 'PASSWORD' => ENV['OS_PASSWORD'],
9
+ 'AUTH_URL' => ENV['OS_AUTH_URL'],
10
+ 'TENANT_NAME' => ENV['OS_TENANT_NAME'],
11
+
12
+ # generic instance info
13
+ 'flavor_id' => 103,
14
+ 'image_id' => 78265, # CentOS 6.3 64bit
15
+ # per-az image_id's
16
+ 'az-2.region-a.geo-1' => { 'image_id' => 78265 },
17
+
18
+ # provisioning info
19
+ :key_pair => ENV['USER'],
20
+ :key_public => '~/.ssh/id_rsa.pub',
21
+
22
+ :name_template => '%s-%s-%s%04d', # service-site-role0001
23
+ :global_service_name => 'webci',
24
+ :site_template => '%s',
25
+
26
+ # role specification
27
+ # role names & chef roles should match
28
+ :roles => {
29
+ :web => { :count => 1,
30
+ # use the default security group
31
+ :security_group => 'default',
32
+ # don't use chef as the second-stage provisioner
33
+ :skip_chef_prereg => true,
34
+ :bootstrap => 'cloud-init.sh',
35
+ # use the yaml template that supports configuring the ephemeral space early in the boot process
36
+ :cloud_config_yaml => 'cloud-init.yaml',
37
+ }
38
+ }
39
+ }
40
+ end
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ cat > /tmp/index.html <<HEREDOC
4
+ <html><body><h1>Stack-Kicker was 'ere!</h1>
5
+ <p>This file is dropped in place by a shell script passed to the host via cloud-init</p>
6
+ <p>The web server software is running but no content has been added, yet.</p>
7
+ </body></html>
8
+ HEREDOC
@@ -0,0 +1,24 @@
1
+ #cloud-config
2
+
3
+ manage_etc_hosts: True
4
+
5
+ hostname: %HOSTNAME%
6
+ fqdn: %HOSTNAME%.mccartney.ie
7
+
8
+ output:
9
+ all: ">> /var/log/cloud-init.log"
10
+
11
+ # use the HPCS Ubuntu Mirror for security-updates too
12
+ #bootcmd:
13
+ # - echo 127.0.1.1 %HOSTNAME% >> /etc/hosts
14
+
15
+ # Run apt-get update
16
+ package_update: true
17
+
18
+ # Run apt-get update
19
+ package_upgrade: true
20
+
21
+ # Install some packages
22
+ packages:
23
+ - apache2
24
+ - php5
@@ -0,0 +1 @@
1
+ {"web":["15.185.111.243"]}
@@ -1,5 +1,5 @@
1
1
  module Stack
2
2
  module Kicker
3
- VERSION = "0.0.22"
3
+ VERSION = "0.0.23"
4
4
  end
5
5
  end
data/lib/stack.rb CHANGED
@@ -248,20 +248,6 @@ module Stack
248
248
  def Stack.generate_knife_rb(config)
249
249
  # generate a project/.chef/knife.rb from our config
250
250
 
251
- Stack.check_config(config)
252
-
253
- # find the chef server, if we need to
254
- if config[:chef_server_hostname].nil? || config[:chef_server_private].nil? || config[:chef_server_public]
255
- Logger.debug { "Attempting to discover the chef server details" }
256
- ours = Stack.get_our_instances(config)
257
- ours.each do |node, node_details|
258
- if node_details[:role] == :chef
259
- Logger.debug { "Found the Chef server: #{node} #{node_details}" }
260
- Stack.set_chef_server(config, node)
261
- end
262
- end
263
- end
264
-
265
251
  # CWD shoud be chef-repo/bootstrap, so the project .chef directory should be
266
252
  dot_chef_abs = File.absolute_path(File.join(config[:stackhome],config[:dot_chef]))
267
253
 
@@ -636,23 +622,29 @@ cookbook_path [ '<%=config[:stackhome]%>/cookbooks' ]
636
622
  # called either after we create the Chef Server, or skip over it
637
623
  Logger.debug "Setting :chef_server_hostname, chef_server_private & chef_server_public details (using #{chef_server})"
638
624
 
625
+ Stack.check_config(config)
626
+ Stack.get_our_instances(config)
627
+
639
628
  config[:chef_server_hostname] = chef_server
629
+
640
630
  # get the internal IP of this instance....which we should have stored in config[:all_instances]
641
631
  if config[:all_instances][chef_server] && config[:all_instances][chef_server][:addresses]
642
632
  config[:all_instances][chef_server][:addresses].each do |address|
643
633
  # find the private IP, any old private IP will do...
644
634
  if (address.label == 'private')
645
- config[:chef_server_private] = "http://#{address.address}:4000/"
635
+ config[:chef_server_private] = "#{address.address}"
646
636
  Logger.info "Setting the internal Chef URL to #{config[:chef_server_private]}"
647
637
  end
648
638
 
649
639
  # only set the public url if it hasn't been set in the config
650
640
  if ((config[:chef_server_public].nil? || config[:chef_server_public].empty?) && address.label == 'public')
651
- config[:chef_server_public] = "http://#{address.address}:4000/"
641
+ config[:chef_server_public] = "#{address.address}"
652
642
  Logger.info "Setting the public Chef URL to #{config[:chef_server_public]}"
653
643
  end
654
644
  end
655
645
  end
646
+
647
+
656
648
  end
657
649
 
658
650
  def Stack.secgroup_sync(config)
@@ -774,12 +766,13 @@ cookbook_path [ '<%=config[:stackhome]%>/cookbooks' ]
774
766
  # 2) replace the tokens (CHEF_SERVER, CHEF_ENVIRONMENT, SERVER_NAME, ROLE)
775
767
  Logger.debug { "Replacing %HOSTNAME% with #{hostname} in multipart" }
776
768
  multipart.gsub!(%q!%HOSTNAME%!, hostname)
769
+ Logger.debug { "Replaced %HOSTNAME% with #{hostname} in multipart" }
777
770
 
778
771
  if config[:chef_server_hostname].nil?
779
772
  Logger.info "config[:chef_server_hostname] is nil, skipping chef server substitution"
780
773
  elsif (role_details[:chef_server])
781
774
  Logger.info "This is the Chef Server - setting up to talk to ourselves"
782
- multipart.gsub!(%q!%CHEF_SERVER%!, 'http://127.0.0.1:4000/')
775
+ multipart.gsub!(%q!%CHEF_SERVER%!, '127.0.0.1')
783
776
  multipart.gsub!(%q!%CHEF_ENVIRONMENT%!, config[:chef_environment])
784
777
  else
785
778
  Logger.info "Chef server is #{config[:chef_server_hostname]}, which is in #{config[:node_details][config[:chef_server_hostname]][:region]}"
@@ -794,6 +787,12 @@ cookbook_path [ '<%=config[:stackhome]%>/cookbooks' ]
794
787
  Logger.warn { "Not setting the chef url for #{hostname} as neither chef_server_private or chef_server_public are valid yet" }
795
788
  end
796
789
 
790
+ if config[:domain].nil?
791
+ multipart.gsub!(%q!%CHEF_SERVER_HOSTNAME%!, config[:chef_server_hostname])
792
+ else
793
+ multipart.gsub!(%q!%CHEF_SERVER_HOSTNAME%!, config[:chef_server_hostname] + '.' + config[:domain])
794
+ end
795
+
797
796
  multipart.gsub!(%q!%CHEF_ENVIRONMENT%!, config[:chef_environment])
798
797
 
799
798
  if File.exists?(config[:chef_validation_pem])
@@ -867,7 +866,7 @@ cookbook_path [ '<%=config[:stackhome]%>/cookbooks' ]
867
866
  # refresh the chef_server details..we should have IPs now
868
867
  if role_details[:chef_server]
869
868
  Stack.set_chef_server(config, hostname)
870
- Stack.generate_knife_rb(config)
869
+ #Stack.generate_knife_rb(config)
871
870
  end
872
871
 
873
872
  # attach a floating IP to this if we have one
@@ -915,15 +914,18 @@ cookbook_path [ '<%=config[:stackhome]%>/cookbooks' ]
915
914
  raise ArgumentError
916
915
  end
917
916
 
917
+ filename_fqp = ''
918
+
919
+ # Relative path, to somewhere!
918
920
  dirs = [ '.' ] # current directory
919
921
  dirs.push(config[:stackhome])
920
922
  config[:find_file_paths].each { |fp| dirs.push(File.join(config[:stackhome], fp)) }
921
923
  dirs.push(File.join(@@gemhome, 'lib'))
924
+ dirs.push(ENV['HOME'])
922
925
  dirs.push('') # find absolute paths
923
926
  dirs.flatten!
924
927
 
925
928
  Logger.debug "find_file, looking for #{filename} in #{dirs}"
926
- filename_fqp = ''
927
929
  dirs.each do |dir|
928
930
  fqp = File.join(dir, filename)
929
931
  Logger.debug "find_file: checking #{fqp}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stack-kicker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-20 00:00:00.000000000 Z
12
+ date: 2013-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -143,6 +143,11 @@ files:
143
143
  - doc/examples/.rvmrc
144
144
  - doc/examples/Gemfile
145
145
  - doc/examples/apache-via-chef-server/Stackfile
146
+ - doc/examples/apache-via-cloud-init-centos/README.md
147
+ - doc/examples/apache-via-cloud-init-centos/Stackfile
148
+ - doc/examples/apache-via-cloud-init-centos/cloud-init.sh
149
+ - doc/examples/apache-via-cloud-init-centos/cloud-init.yaml
150
+ - doc/examples/apache-via-cloud-init-centos/secgroup_ips.json
146
151
  - doc/examples/apache-via-cloud-init/README.md
147
152
  - doc/examples/apache-via-cloud-init/Stackfile
148
153
  - doc/examples/apache-via-cloud-init/cloud-init.sh