sambot 0.1.171 → 0.1.172

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecbe0a3db2399c37336a17169ab9c860dbf99786
4
- data.tar.gz: 50d1391592f310d8045de5ef6c97ef6e538e9133
3
+ metadata.gz: 628d48236e3e996ef6f94921ad3757df406bceb4
4
+ data.tar.gz: 1fbf9c147b85d8678cef0eb7502850db091cb6cc
5
5
  SHA512:
6
- metadata.gz: dad5bdc3cf3cc9978729fdc8a8bca632741ec3e5e9a9ba47541f218280affc6556e57269452c17aa57533cdb28301404ccc807f9b0b59d15506042f79adbf395
7
- data.tar.gz: 6e2f307c140ba88bcf67d971677287903afe08514236a020e4829d52ffad984ed5c0dc218f3d5f5df8519bf7c93a20b2f87ee63209fad910369a226c229722a5
6
+ metadata.gz: 1b37a2a22495762bd5358ca30136aa467e1d40cdec9220ee43dc2a0dbc99a38d50709352a5d8fdb328d0561526210f81d1d14fcd2ecddd7a3aeaf0d76f3de754
7
+ data.tar.gz: 859afcc95326d0576b678bb024ec68e3bdda8d17e414ffad89fec4a8fe8a16038d310198a648b4fa281ec352c85426c1865bc1b2a271bae1fc2ce75ee02b2dc8
data/lib/sambot.rb CHANGED
@@ -8,6 +8,9 @@ require_relative 'sambot/version'
8
8
  require_relative 'sambot/template'
9
9
  require_relative 'sambot/fs'
10
10
 
11
+ require_relative 'sambot/testing/consul_helper'
12
+ require_relative 'sambot/testing/vault_helper'
13
+
11
14
  require_relative 'sambot/chef/kitchen'
12
15
  require_relative 'sambot/chef/metadata'
13
16
  require_relative 'sambot/chef/hooks'
@@ -56,17 +56,12 @@ module Sambot
56
56
 
57
57
  def create_files(config)
58
58
  ['.vault.yml', '.consul.yml', 'README.md'].each { |resource| FS.copy(resource) unless FS.exist?(resource) }
59
- ['spec', 'test', 'attributes', 'local'].each { |resource| FS.mkdir(resource) unless FS.exist?(resource) }
59
+ ['spec', 'test', 'attributes', 'vault'].each { |resource| FS.mkdir(resource) unless FS.exist?(resource) }
60
60
  Dir.chdir('attributes') { FileUtils.touch('default.rb') }
61
61
  Dir.chdir('spec') { FS.copy('spec_helper.rb') unless FS.exist?('spec_helper.rb') }
62
- Dir.chdir('local') do
63
- FS.mkdir('vault') unless FS.exist?('vault')
64
- Dir.chdir('vault') { FS.copy('vault_helper.rb') }
65
- FS.mkdir('consul') unless FS.exist?('consul')
66
- Dir.chdir('consul') { FS.copy('consul_helper.rb')}
67
- end
68
62
  ['recipes', 'libraries', 'resources', 'files', 'templates'].each { |target| FS.mkdir(target) unless FS.exist?(target) }
69
63
  Dir.chdir('recipes') do
64
+ # Need to correctly generate default.rb
70
65
  FileUtils.touch('install.rb') unless FS.exist?('install.rb')
71
66
  FileUtils.touch('configure.rb') unless FS.exist?('configure.rb')
72
67
  FileUtils.touch('default.rb') unless FS.exist?('default.rb')
data/lib/sambot/cli.rb CHANGED
@@ -10,6 +10,20 @@ module Sambot
10
10
  execute { Chef::Cookbook.clean() }
11
11
  end
12
12
 
13
+ desc 'populate', 'Populates either Vault or Consul with seed data'
14
+ option :vault, :type => :boolean
15
+ option :consul, :type => :boolean
16
+ def populate
17
+ execute do
18
+ unless options[:vault] || options[:consul]
19
+ UI.error('Please select the datastore you are populating from the following: --vault or --consul')
20
+ exit
21
+ end
22
+ Sambot::Testing::VaultHelper.load_secrets if options[:vault]
23
+ Sambot::Testing::ConsulHelper.load_values if options[:consul]
24
+ end
25
+ end
26
+
13
27
  desc 'bump', 'Bump the patch version of a cookbook'
14
28
  def bump
15
29
  execute { Chef::Cookbook.bump() }
@@ -1,17 +1,30 @@
1
1
  #!/bin/bash -e
2
2
 
3
- ## Download and install Hashicorp Vault
3
+ cd /tmp
4
+
5
+ ## Install required tools
4
6
  sudo yum install -y unzip wget
7
+
8
+ ## Download and install Hashicorp Vault
5
9
  wget "https://releases.hashicorp.com/vault/0.6.5/vault_0.6.5_linux_amd64.zip"
6
10
  unzip vault_0.6.5_linux_amd64.zip -d /usr/bin
7
11
  sudo mkdir /etc/vault
8
12
 
13
+ ## Download and install Hashicorp Consul
14
+ wget "https://releases.hashicorp.com/consul/0.8.5/consul_0.8.5_linux_amd64.zip"
15
+ unzip consul_0.8.5_linux_amd64.zip -d /usr/bin
16
+ sudo mkdir /etc/consul
17
+
18
+ ## Launch the Consul Agent in Development mode
19
+ consul -dev -server -bootstrap
20
+
9
21
  ## Launch the Vault Server in Development mode
10
22
  export VAULT_ADDR="http://127.0.0.1:8200"
11
23
  export VAULT_TOKEN="root"
12
24
  vault server -dev -dev-root-token-id=${VAULT_TOKEN} -dev-listen-address=0.0.0.0:8200 < /dev/null &> /dev/null &
25
+ vault mount -path=dev generic
13
26
 
14
- ## Create the addressing file so that Chef and other applicatons can access the Vault server
27
+ ## Create the addressing file so that Chef and other applications can access the Vault server
15
28
  cat << EOF > /etc/vault/tokens.json
16
29
  {
17
30
  "vault-addr": "${VAULT_ADDR}",
@@ -24,8 +37,9 @@ EOF
24
37
  ## Install Ruby
25
38
  sudo yum install -y ruby
26
39
 
27
- ## Install Ruby gems
28
- gem install vault
40
+ ## Install Sambot
41
+ gem install sambot
29
42
 
30
43
  ## Populate Vault
31
- ruby /vagrant/local/vault/vault_helper.rb
44
+ cd /vagrant
45
+ sambot populate --vault
@@ -0,0 +1,15 @@
1
+
2
+ module Sambot
3
+ module Testing
4
+ class ConsulHelper
5
+
6
+ class << self
7
+
8
+ def load_values(filename)
9
+ end
10
+
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,62 @@
1
+ require 'yaml'
2
+ require 'vault'
3
+
4
+ module Sambot
5
+ module Testing
6
+ class VaultHelper
7
+
8
+ class << self
9
+
10
+ def load_secrets(filename = '.vault.yml', src = 'vault')
11
+ if File.exist?(filename)
12
+ read_secrets(filename, src)
13
+ else
14
+ UI.info("No secrets configuration file is available so Vault was not populated with any secrets")
15
+ return 0
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def read_secrets(filename, src)
22
+ UI.info("Reading the secrets configuration file")
23
+ contents = File.read(filename)
24
+ if contents.empty?
25
+ UI.info("No secrets were found in the secrets configuration file")
26
+ return 0
27
+ else
28
+ store_secrets(contents, src)
29
+ end
30
+ end
31
+
32
+ def store_secrets(contents, src)
33
+ secrets = YAML.load(contents)
34
+ counter = 0
35
+ secrets.each do |secret|
36
+ secret['keys'].each do |item|
37
+ store_secret(src, secret['path'], item.keys[0], item.values[0])
38
+ counter = counter + 1
39
+ end
40
+ end
41
+ counter
42
+ end
43
+
44
+ def store_secret(src, path, key, value)
45
+ if value.start_with?('file::')
46
+ filename = value.gsub(/file::/, '')
47
+ location = File.expand_path(File.join(src, filename))
48
+ value = File.read(location)
49
+ end
50
+ write_to_vault(path, key, value)
51
+ UI.info("Updated the secret with key '#{key}' located at '#{path}'")
52
+ end
53
+
54
+ def write_to_vault(path, key, value)
55
+ Vault.logical.write(path, "#{key}".to_sym => value)
56
+ end
57
+
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sambot
4
- VERSION = '0.1.171'.freeze
4
+ VERSION = '0.1.172'.freeze
5
5
  end
data/sambot.gemspec CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency 'net-ssh'
31
31
  spec.add_dependency 'titan'
32
32
  spec.add_dependency 'open4'
33
+ spec.add_dependency 'diplomat'
33
34
  spec.add_dependency 'semantic'
34
35
  spec.add_dependency 'chef', '~> 12.18'
35
36
  spec.add_dependency 'thor', '~> 0.19'
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.171
4
+ version: 0.1.172
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-18 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor-hollaback
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: diplomat
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: semantic
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -468,6 +482,8 @@ files:
468
482
  - lib/sambot/templates/test_kitchen/rackspace.yml.erb
469
483
  - lib/sambot/templates/vault_helper.rb
470
484
  - lib/sambot/templates/winrm_config
485
+ - lib/sambot/testing/consul_helper.rb
486
+ - lib/sambot/testing/vault_helper.rb
471
487
  - lib/sambot/ui.rb
472
488
  - lib/sambot/version.rb
473
489
  - lib/sambot/workflow/brew.rb