sambot 0.1.158 → 0.1.159

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sambot.rb +1 -0
  3. data/lib/sambot/base_command.rb +1 -24
  4. data/lib/sambot/chef/cookbook.rb +32 -54
  5. data/lib/sambot/chef/generator.rb +28 -38
  6. data/lib/sambot/chef/hooks.rb +4 -2
  7. data/lib/sambot/chef/kitchen.rb +33 -42
  8. data/lib/sambot/chef/metadata.rb +14 -14
  9. data/lib/sambot/cli.rb +22 -19
  10. data/lib/sambot/config.rb +59 -4
  11. data/lib/sambot/docs/bump.txt +1 -0
  12. data/lib/sambot/docs/{generate.txt → create.txt} +0 -0
  13. data/lib/sambot/fs.rb +33 -0
  14. data/lib/sambot/runtime.rb +13 -29
  15. data/lib/sambot/template.rb +22 -1
  16. data/lib/sambot/templates/.config.yml.erb +7 -7
  17. data/lib/sambot/{docs/configure.txt → templates/.consul.yml} +0 -0
  18. data/lib/sambot/templates/.vault.yml +0 -0
  19. data/lib/sambot/templates/README.md +0 -0
  20. data/lib/sambot/templates/Vagrantfile.erb +7 -5
  21. data/lib/sambot/templates/attributes/default.rb +0 -0
  22. data/lib/sambot/templates/{gcp_bootstrap.ps1.erb → bootstrap_scripts/google/bootstrap.ps1.erb} +0 -0
  23. data/lib/sambot/templates/{gcp_bootstrap.sh.erb → bootstrap_scripts/google/bootstrap.sh.erb} +0 -1
  24. data/lib/sambot/templates/bootstrap_scripts/local/sidecar_vault/bootstrap.ps1.erb +33 -0
  25. data/lib/sambot/templates/bootstrap_scripts/local/sidecar_vault/bootstrap.sh.erb +34 -0
  26. data/lib/sambot/templates/{local_bootstrap.ps1 → bootstrap_scripts/local/standalone_vault/bootstrap.ps1.erb} +0 -0
  27. data/lib/sambot/templates/{local_bootstrap.sh → bootstrap_scripts/local/standalone_vault/bootstrap.sh.erb} +0 -0
  28. data/lib/sambot/templates/{pre-commit → git_hooks/pre-commit} +0 -0
  29. data/lib/sambot/templates/{pre-push → git_hooks/pre-push} +0 -0
  30. data/lib/sambot/templates/local/vault/helper.rb +11 -0
  31. data/lib/sambot/templates/recipes/configure.rb.erb +0 -0
  32. data/lib/sambot/templates/recipes/default.rb.erb +0 -0
  33. data/lib/sambot/templates/recipes/install.rb.erb +0 -0
  34. data/lib/sambot/templates/spec/spec_helper.rb +2 -0
  35. data/lib/sambot/templates/test/default_test.rb +0 -0
  36. data/lib/sambot/templates/{.kitchen.gcp.yml.erb → test_kitchen/google.yml.erb} +0 -0
  37. data/lib/sambot/templates/{.kitchen.yml.erb → test_kitchen/local.yml.erb} +2 -2
  38. data/lib/sambot/templates/{.kitchen.rackspace.yml.erb → test_kitchen/rackspace.yml.erb} +5 -5
  39. data/lib/sambot/ui.rb +12 -6
  40. data/lib/sambot/version.rb +1 -1
  41. metadata +26 -17
  42. data/lib/sambot/commands/cookbook_cmd.rb +0 -44
  43. data/lib/sambot/docs/start.txt +0 -21
  44. data/lib/sambot/docs/stop.txt +0 -7
  45. data/lib/sambot/workflow/dns.rb +0 -43
data/lib/sambot/ui.rb CHANGED
@@ -3,32 +3,38 @@
3
3
  module Sambot
4
4
  module UI
5
5
 
6
+ @@silent = false
7
+
8
+ def self.silent=(value)
9
+ @@silent = value
10
+ end
11
+
6
12
  def self.ask(msg)
7
- Thor.new.ask(msg)
13
+ Thor.new.ask(msg) unless @@silent
8
14
  end
9
15
 
10
16
  def self.ask_password(msg)
11
- Thor.new.ask(msg, :echo => false)
17
+ Thor.new.ask(msg, :echo => false) unless @@silent
12
18
  end
13
19
 
14
20
  def self.warn(msg)
15
21
  date_format = DateTime.now.strftime("%Y-%m-%d %H:%M:%S")
16
- Thor.new.say("#{date_format} [W] #{msg}", :yellow)
22
+ Thor.new.say("#{date_format} [W] #{msg}", :yellow) unless @@silent
17
23
  end
18
24
 
19
25
  def self.debug(msg)
20
26
  date_format = DateTime.now.strftime("%Y-%m-%d %H:%M:%S")
21
- Thor.new.say("#{date_format} [D] #{msg}", :gray)
27
+ Thor.new.say("#{date_format} [D] #{msg}", :gray) unless @@silent
22
28
  end
23
29
 
24
30
  def self.info(msg)
25
31
  date_format = DateTime.now.strftime("%Y-%m-%d %H:%M:%S")
26
- Thor.new.say("#{date_format} [I] #{msg}", :green)
32
+ Thor.new.say("#{date_format} [I] #{msg}", :green) unless @@silent
27
33
  end
28
34
 
29
35
  def self.error(msg)
30
36
  date_format = DateTime.now.strftime("%Y-%m-%d %H:%M:%S")
31
- Thor.new.say("#{date_format} [E] #{msg}", :red)
37
+ Thor.new.say("#{date_format} [E] #{msg}", :red) unless @@silent
32
38
  end
33
39
 
34
40
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sambot
4
- VERSION = '0.1.158'.freeze
4
+ VERSION = '0.1.159'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sambot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.158
4
+ version: 0.1.159
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier Kouame
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-14 00:00:00.000000000 Z
11
+ date: 2017-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor-hollaback
@@ -423,15 +423,13 @@ files:
423
423
  - lib/sambot/chef/metadata.rb
424
424
  - lib/sambot/chef/server.rb
425
425
  - lib/sambot/cli.rb
426
- - lib/sambot/commands/cookbook_cmd.rb
427
426
  - lib/sambot/config.rb
428
427
  - lib/sambot/docs/build.txt
428
+ - lib/sambot/docs/bump.txt
429
429
  - lib/sambot/docs/clean.txt
430
- - lib/sambot/docs/configure.txt
431
- - lib/sambot/docs/generate.txt
432
- - lib/sambot/docs/start.txt
433
- - lib/sambot/docs/stop.txt
430
+ - lib/sambot/docs/create.txt
434
431
  - lib/sambot/docs/version.txt
432
+ - lib/sambot/fs.rb
435
433
  - lib/sambot/rackspace/client.rb
436
434
  - lib/sambot/rackspace/flavors.rb
437
435
  - lib/sambot/rackspace/images.rb
@@ -445,27 +443,38 @@ files:
445
443
  - lib/sambot/slack/work_item.rb
446
444
  - lib/sambot/template.rb
447
445
  - lib/sambot/templates/.config.yml.erb
446
+ - lib/sambot/templates/.consul.yml
448
447
  - lib/sambot/templates/.gitignore.sample
449
- - lib/sambot/templates/.kitchen.gcp.yml.erb
450
- - lib/sambot/templates/.kitchen.rackspace.yml.erb
451
- - lib/sambot/templates/.kitchen.yml.erb
452
448
  - lib/sambot/templates/.rubocop.yml
449
+ - lib/sambot/templates/.vault.yml
453
450
  - lib/sambot/templates/Berksfile
451
+ - lib/sambot/templates/README.md
454
452
  - lib/sambot/templates/Vagrantfile.erb
453
+ - lib/sambot/templates/attributes/default.rb
454
+ - lib/sambot/templates/bootstrap_scripts/google/bootstrap.ps1.erb
455
+ - lib/sambot/templates/bootstrap_scripts/google/bootstrap.sh.erb
456
+ - lib/sambot/templates/bootstrap_scripts/local/sidecar_vault/bootstrap.ps1.erb
457
+ - lib/sambot/templates/bootstrap_scripts/local/sidecar_vault/bootstrap.sh.erb
458
+ - lib/sambot/templates/bootstrap_scripts/local/standalone_vault/bootstrap.ps1.erb
459
+ - lib/sambot/templates/bootstrap_scripts/local/standalone_vault/bootstrap.sh.erb
455
460
  - lib/sambot/templates/chefignore
456
- - lib/sambot/templates/gcp_bootstrap.ps1.erb
457
- - lib/sambot/templates/gcp_bootstrap.sh.erb
458
- - lib/sambot/templates/local_bootstrap.ps1
459
- - lib/sambot/templates/local_bootstrap.sh
461
+ - lib/sambot/templates/git_hooks/pre-commit
462
+ - lib/sambot/templates/git_hooks/pre-push
463
+ - lib/sambot/templates/local/vault/helper.rb
460
464
  - lib/sambot/templates/metadata.rb.erb
461
- - lib/sambot/templates/pre-commit
462
- - lib/sambot/templates/pre-push
465
+ - lib/sambot/templates/recipes/configure.rb.erb
466
+ - lib/sambot/templates/recipes/default.rb.erb
467
+ - lib/sambot/templates/recipes/install.rb.erb
468
+ - lib/sambot/templates/spec/spec_helper.rb
463
469
  - lib/sambot/templates/teamcity.sh.erb
470
+ - lib/sambot/templates/test/default_test.rb
471
+ - lib/sambot/templates/test_kitchen/google.yml.erb
472
+ - lib/sambot/templates/test_kitchen/local.yml.erb
473
+ - lib/sambot/templates/test_kitchen/rackspace.yml.erb
464
474
  - lib/sambot/templates/winrm_config
465
475
  - lib/sambot/ui.rb
466
476
  - lib/sambot/version.rb
467
477
  - lib/sambot/workflow/brew.rb
468
- - lib/sambot/workflow/dns.rb
469
478
  - lib/sambot/workflow/vault.rb
470
479
  - lib/sambot/workflow/workstation.rb
471
480
  - sambot.gemspec
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../chef/cookbook'
4
-
5
- module Sambot
6
- module Commands
7
-
8
- class CookbookCmd < BaseCommand
9
-
10
- namespace 'cookbook'
11
-
12
- desc 'clean', 'Remove all generated build files from a cookbook'
13
- def clean
14
- execute { Chef::Cookbook.clean() }
15
- end
16
-
17
- desc 'build', 'Builds a cookbook from its configuration file'
18
- def build
19
- execute { Chef::Cookbook.build(config) }
20
- end
21
-
22
- desc 'generate', 'Creates a new cookbook'
23
- def generate
24
- execute do
25
- config = {
26
- name: ask(' What is the name of this cookbook?'),
27
- type: ask(' What type of cookbook will this be?', :limited_to => ['wrapper', 'role']),
28
- platforms: ask(' What operating system will this cookbook run on?', :limited_to => ['windows', 'centos', 'both']),
29
- description: ask(' What does this cookbook do?')
30
- }
31
- config[:identifier] = ask(' What will be the unique machiner identifier for this role cookbook?') if config[:type] == 'role'
32
- config[:platforms] = config[:platforms] == 'both' ? ['centos', 'windows'] : [config[:platforms]]
33
- Chef::Cookbook.generate(config)
34
- end
35
- end
36
-
37
- desc 'version', 'Gives the cookbook version as a TeamCity service message'
38
- def version
39
- execute { puts "##teamcity[buildNumber '#{config['version'].to_s}']" }
40
- end
41
-
42
- end
43
- end
44
- end
@@ -1,21 +0,0 @@
1
- This command will start a new 'Sambot' session.
2
-
3
- A session is a period of time during which you want to interact with services inside
4
- our Rackspace DEV environment. To do so several things need to take place:
5
-
6
- * A set of SSH tunnels will be created to the bastion host in Rackspace, allowing you
7
- to seamlessly access resources.
8
-
9
- * Your /etc/hosts will be updated with the most commonly used services to point to your
10
- local machine. This will allow you to transparently connect to a service .i.e https://chef.brighter.io
11
- as if you were connecting directly - in fact, you'll be going through a local tunnel!
12
-
13
- * You will be logged into Vault allowing you to start using the Vault CLI without further
14
- authentication required.
15
-
16
- * An HAProxy instance will be started locally in order to correctly route ports. This is required
17
- to transparently used the correct ports on a single IP.
18
-
19
- You can run `sambot session` over and over again without any problems. Once your session is complete
20
- and you want to close the session, simply run `sambot stop` and this will remove the tunnels, stop
21
- HAProxy and reset your /etc/hosts file to its original contents.
@@ -1,7 +0,0 @@
1
- This command will stop a 'Sambot' session. It will do the following:
2
-
3
- * Close any open tunnels to the bastion host.
4
-
5
- * Reset your /etc/hosts file to its original content.
6
-
7
- * Stop the local HAProxy instance.
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'hosts'
4
-
5
- module Sambot
6
- module Workflow
7
- class DNS
8
-
9
- def self.update_hosts(forwards, src = '/etc/hosts', dest = nil)
10
- UI.info('Updating your hosts file to allow access to Advertising Studio services through local SSH tunnels')
11
- modify_hosts(forwards, src, dest) do |entries, key, value|
12
- UI.debug("Adding hosts entry #{key} 127.0.0.1")
13
- entries << Hosts::Entry.new("127.0.0.1", key)
14
- end
15
- end
16
-
17
- def self.reset_hosts(forwards, src = '/etc/hosts', dest = nil)
18
- UI.info('Removing extra entries in hosts file')
19
- modify_hosts(forwards, src, dest)
20
- end
21
-
22
- private
23
-
24
- def self.modify_hosts(forwards, src, dest)
25
- hosts = Hosts::File.read(src)
26
- entries = hosts.elements
27
- forwards.each do |key, value|
28
- entries.delete_if { |entry| entry.is_a?(Aef::Hosts::Entry) && entry.name == key.to_s}
29
- yield(entries, key, value) if block_given?
30
- end
31
- if dest
32
- hosts.write(:path => dest)
33
- else
34
- tempfile = Tempfile.new
35
- hosts.write(:path => tempfile.path)
36
- Runtime.sudo("cp #{tempfile.path} /etc/hosts")
37
- end
38
-
39
- end
40
-
41
- end
42
- end
43
- end