sambot 0.1.69 → 0.1.83

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sambot/cli.rb +16 -18
  3. data/lib/sambot/commands/cookbook.rb +56 -38
  4. data/lib/sambot/commands/packer.rb +21 -0
  5. data/lib/sambot/commands/session.rb +15 -5
  6. data/lib/sambot/commands/workstation.rb +8 -10
  7. data/lib/sambot/domain/bastion_host.rb +59 -0
  8. data/lib/sambot/domain/chef/kitchen.rb +39 -0
  9. data/lib/sambot/domain/{cookbooks → chef}/metadata.rb +6 -5
  10. data/lib/sambot/domain/common/{application_exception.rb → application_error.rb} +1 -1
  11. data/lib/sambot/domain/common/config.rb +13 -6
  12. data/lib/sambot/domain/common/file_checker.rb +3 -2
  13. data/lib/sambot/domain/common/runtime.rb +5 -5
  14. data/lib/sambot/domain/common/template_provider.rb +1 -1
  15. data/lib/sambot/domain/cookbook.rb +103 -0
  16. data/lib/sambot/domain/dns.rb +24 -0
  17. data/lib/sambot/domain/packer.rb +26 -0
  18. data/lib/sambot/domain/session.rb +25 -0
  19. data/lib/sambot/domain/{workstations/ssh_config_file.rb → ssh/config_file.rb} +7 -7
  20. data/lib/sambot/domain/{workstations/ssh_config_section.rb → ssh/config_section.rb} +2 -2
  21. data/lib/sambot/domain/{workstations/ssh_parser.rb → ssh/parser.rb} +8 -7
  22. data/lib/sambot/domain/ui.rb +19 -0
  23. data/lib/sambot/domain/vault.rb +32 -0
  24. data/lib/sambot/domain/workstation.rb +25 -0
  25. data/lib/sambot/templates/{.kitchen.gcp.windows.yml → .kitchen.gcp.yml.erb} +33 -5
  26. data/lib/sambot/templates/.kitchen.rackspace.yml.erb +49 -0
  27. data/lib/sambot/templates/{.kitchen.centos.yml → .kitchen.yml.erb} +6 -1
  28. data/lib/sambot/templates/metadata.rb.erb +9 -2
  29. data/lib/sambot/templates/packer.linux.json +22 -0
  30. data/lib/sambot/templates/packer.windows.json.erb +18 -0
  31. data/lib/sambot/templates/teamcity.sh.erb +7 -7
  32. data/lib/sambot/version.rb +1 -1
  33. data/sambot.gemspec +7 -1
  34. metadata +120 -36
  35. data/lib/sambot/commands/secret.rb +0 -32
  36. data/lib/sambot/commands/teamcity.rb +0 -15
  37. data/lib/sambot/domain/common/ui.rb +0 -21
  38. data/lib/sambot/domain/cookbooks/assistant_chef.rb +0 -103
  39. data/lib/sambot/domain/cookbooks/kitchen.rb +0 -30
  40. data/lib/sambot/domain/secrets/vault.rb +0 -28
  41. data/lib/sambot/domain/workstations/env.rb +0 -0
  42. data/lib/sambot/domain/workstations/hosts.rb +0 -0
  43. data/lib/sambot/domain/workstations/install.sh +0 -1
  44. data/lib/sambot/templates/.kitchen.gcp.centos.yml +0 -39
  45. data/lib/sambot/templates/.kitchen.rackspace.centos.yml +0 -27
  46. data/lib/sambot/templates/.kitchen.rackspace.windows.yml +0 -34
  47. data/lib/sambot/templates/.kitchen.windows.yml +0 -16
@@ -1,21 +0,0 @@
1
- module Sambot
2
- module Domain
3
- module Common
4
- module UI
5
-
6
- def debug(msg)
7
- say("debug: #{msg}", :yellow)
8
- end
9
-
10
- def info(msg)
11
- say(" info: #{msg}", :green)
12
- end
13
-
14
- def error(msg)
15
- say("error: #{msg}", :red)
16
- end
17
-
18
- end
19
- end
20
- end
21
- end
@@ -1,103 +0,0 @@
1
- require 'yaml'
2
- require 'git'
3
-
4
- module Sambot
5
- module Domain
6
- module Cookbooks
7
- class AssistantChef
8
-
9
- def initialize
10
- @modified_files = []
11
- end
12
-
13
- def build_cookbook(essential_files, generated_files)
14
- config = Common::Config.new.read
15
- validate_cookbook_structure(config['platform'], essential_files, generated_files)
16
- setup_test_kitchen(config)
17
- build_metadata(config)
18
- copy_git_hooks()
19
- @modified_files
20
- end
21
-
22
- def clean_cookbook(generated_files)
23
- delete_file('metadata.rb')
24
- delete_file('winrm_config')
25
- generated_files.each { |file| delete_file(file) }
26
- Dir.glob('\.kitchen*\.yml').each { |file| delete_file(file)}
27
- @modified_files
28
- end
29
-
30
- def generate_cookbook(name, platform, type, description, essential_files, generated_files)
31
- Git.init(name)
32
- Dir.chdir(name) do
33
- FileUtils.mkdir('test')
34
- FileUtils.mkdir('spec')
35
- FileUtils.mkdir('recipes')
36
- FileUtils.touch('README.md')
37
- write_config(name, description, platform, type)
38
- build_cookbook(essential_files, generated_files)
39
- end
40
- end
41
-
42
- private
43
-
44
- def write_config(name, description, platform, type)
45
- contents = {
46
- 'name' => name,
47
- 'version' => '0.0.1',
48
- 'platform' => platform,
49
- 'suites' => [{
50
- 'name' => 'default',
51
- 'run_list' => [
52
- "recipe[#{name}]"
53
- ],
54
- 'verifier' => {
55
- 'inspec_tests' => ['./test']
56
- }
57
- }],
58
- 'description' => description,
59
- }.to_yaml
60
- File.write('.config.yml', contents)
61
- end
62
-
63
- def copy_git_hooks
64
- working_path = '.git/hooks/pre-push'
65
- template_path = Common::TemplateProvider.new.get_path('pre-push')
66
- File.delete(working_path) if File.exist?(working_path)
67
- FileUtils.cp(template_path, working_path)
68
- end
69
-
70
- def delete_file(filename)
71
- return unless File.exist?(filename)
72
- File.delete(filename)
73
- @modified_files << filename
74
- end
75
-
76
- def validate_cookbook_structure(platform, essential_files, generated_files)
77
- essential_files.each { |path| Common::FileChecker.new.verify(path) }
78
- if platform == 'windows'
79
- Common::FileChecker.new.update(['winrm_config'])
80
- @modified_files << 'winrm_config'
81
- end
82
- Common::FileChecker.new.update(generated_files)
83
- @modified_files = @modified_files + generated_files
84
- end
85
-
86
- def setup_test_kitchen(config)
87
- files = Kitchen.new.generate_yml(config['name'], config['platform'], config['suites'])
88
- files.each do |filename, contents|
89
- File.write(filename, contents)
90
- @modified_files << filename
91
- end
92
- end
93
-
94
- def build_metadata(config)
95
- result = Metadata.new.generate(config['name'], config['platform'], config['version'], config['description'], config['dependencies'])
96
- File.write('metadata.rb', result)
97
- @modified_files << 'metadata.rb'
98
- end
99
-
100
- end
101
- end
102
- end
103
- end
@@ -1,30 +0,0 @@
1
- module Sambot
2
- module Domain
3
- module Cookbooks
4
- class Kitchen
5
-
6
- def generate_yml(name, platform, suites = nil)
7
- raise ApplicationException, 'Missing platform when trying to generate Test-Kitchen YAML.' unless platform
8
- raise ApplicationException, 'Missing cookbook name when trying to generate Test-Kitchen YAML.' unless name
9
- result = {}
10
- ['', '.gcp', '.rackspace'].map do |type|
11
- yaml = load_yaml(type, platform, name)
12
- yaml['suites'] = suites if suites
13
- result[".kitchen#{type}.yml"] = yaml.to_yaml
14
- end
15
- result
16
- end
17
-
18
- private
19
-
20
- def load_yaml(type, platform, name)
21
- filename = File.join(File.dirname(__FILE__), '../../templates', ".kitchen#{type}.#{platform}.yml")
22
- contents = File.read(filename)
23
- contents = contents.gsub(/@@cookbook_name@@/, name)
24
- YAML.load(contents)
25
- end
26
-
27
- end
28
- end
29
- end
30
- end
@@ -1,28 +0,0 @@
1
- module Sambot
2
- module Domain
3
- module Secrets
4
- class Vault
5
-
6
- def initialize
7
- if Gem.win_platform?
8
- @tool_dir = 'C:/Program Files/vault'
9
- @tool_exe = 'as-vault-tool.exe'
10
- else
11
- @tool_dir = '/opt/vault-tool'
12
- @tool_exe = 'as-vault-tool'
13
- end
14
- @tool_version = '1.0.2'
15
- end
16
-
17
- def read(path)
18
- `#{@tool_dir}/#{@tool_version}/#{@tool_exe} read -p #{path}`
19
- end
20
-
21
- def write(path)
22
- raise 'Not yet implemented'
23
- end
24
-
25
- end
26
- end
27
- end
28
- end
File without changes
File without changes
@@ -1 +0,0 @@
1
- brew install vault
@@ -1,39 +0,0 @@
1
- ---
2
- provisioner:
3
- name: chef_zero
4
- log_level: <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
5
- deprecations_as_errors: true
6
- cookbooks_path:
7
- - .
8
-
9
- platforms:
10
- - name: centos
11
- driver:
12
- name: sfmc_google
13
- region: <%= ENV['GCP_REGION'] %>
14
- project: <%= ENV['GCP_PROJECT'] %>
15
- image_project: <%= ENV['GCP_CENTOS_IMAGE_PROJECT'] %>
16
- image_family: <%= ENV['GCP_CENTOS_IMAGE_FAMILY'] %>
17
- network: <%= ENV['GCP_NETWORK'] %>
18
- subnet: <%= ENV['GCP_SUBNETWORK'] %>
19
- use_private_ip: false
20
- preemptible: true
21
- service_account_name: <%= ENV['GCP_SERVICE_ACCOUNT_NAME'] %>
22
- service_account_scopes:
23
- - userinfo-email
24
- - logging-write
25
- - monitoring-write
26
- tags:
27
- - "test-kitchen"
28
- - "consul-agent"
29
- - "vault-client"
30
-
31
- transport:
32
- username: chefuser
33
- ssh_key:
34
- - <%= ENV['GCP_SSH_KEY'] || "" %>
35
-
36
- verifier:
37
- name: inspec
38
- format: junit
39
- output: inspec_results.xml
@@ -1,27 +0,0 @@
1
- ---
2
- provisioner:
3
- name: chef_zero
4
- log_level: <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
5
- deprecations_as_errors: true
6
- cookbooks_path:
7
- - .
8
-
9
- platforms:
10
- - name: centos
11
- transport:
12
- ssh_key: ./id_rsa
13
- driver:
14
- name: rackspace
15
- rackconnect_wait: true
16
- servicenet: true
17
- require_chef_omnibus: true
18
- no_ssh_tcp_check: true
19
- no_ssh_tcp_check_sleep: 240
20
- image_id: 398c5f65-23e2-44da-97d8-d28ff5ec583b
21
- flavor_id: 6
22
- public_key_path: ./id_rsa.pub
23
- rackspace_region: 'lon'
24
- server_name: @@cookbook_name@@-<%= Time.now.to_i %>
25
-
26
- verifier:
27
- name: inspec
@@ -1,34 +0,0 @@
1
- ---
2
- provisioner:
3
- name: chef_zero
4
- log_level: <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
5
- deprecations_as_errors: true
6
- cookbooks_path:
7
- - .
8
-
9
- transport:
10
- name: winrm
11
- elevated: true
12
- username: Administrator
13
-
14
- platforms:
15
- - name: windows
16
- driver:
17
- name: rax
18
- log_level: info
19
- wait_for: 3600
20
- use_private_ip: <%= ENV['IN_CI_PIPELINE'] %>
21
- rackspace_username: <%= ENV['RACKSPACE_USERNAME'] %>
22
- rackspace_api_key: <%= ENV['RACKSPACE_API_KEY'] %>
23
- network: <%= ENV['NETWORK'] || 'public' %>
24
- image_id: 8bfada8f-9917-46dd-aa82-be533d5279fa
25
- flavor_id: general1-4
26
- rackspace_region: LON
27
- rackconnect_wait: true
28
- platform: windows
29
- user_data: winrm_config
30
-
31
- verifier:
32
- name: inspec
33
- format: junit
34
- output: inspec_results.xml
@@ -1,16 +0,0 @@
1
- ---
2
- driver:
3
- name: "vagrant"
4
-
5
- provisioner:
6
- name: chef_zero
7
- log_level: info
8
- deprecations_as_errors: true
9
- cookbooks_path:
10
- - .
11
-
12
- platforms:
13
- - name: "centos-7.2"
14
-
15
- verifier:
16
- name: inspec