bb8 0.1.0 → 0.2.0

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: ebd3491377b1b0031cc4b605d6bd1d2ce5c74861
4
- data.tar.gz: d2a9f45e7a93464020b06fe916436ee3dfa532c4
3
+ metadata.gz: ce698dad7541161007a7c53b2b6c96b7ef933b21
4
+ data.tar.gz: 0fe6140febe6b98e72b8d065684339024f139579
5
5
  SHA512:
6
- metadata.gz: abaaf5d51e16ec11d7415ac2f7e5086d731f6dbd77a13a6e46462bfb9f3e60d4e7c85bee5388ae2eaec231688067e3211767b870f1362d8d8f36d9d73b2cddbf
7
- data.tar.gz: e3b0e2244c90f714093f114ef2da5de4ea39c2df6ddeabf17cff9dff93797f9c28a6b0cc84fcc0cc4f3a38e04cb85a829292998886a0b3b78c8b61b821f97b2f
6
+ metadata.gz: e8e478a8956d128ad4cb50564bdb572bfa2ecdc81ded9e24fc698e9e8455c5ab8607fd14ce48a816da25805fe2e2ac5c540cfc60bf19397ba0e29b8c08959741
7
+ data.tar.gz: 3d46715a49d1e50fcca1d787ab22ebd68162a385feb576f4ad7098d7954a25896c3e674f7ae24c24a12cb2e05eed484cebf5560184fb6e236b448ee8a60621d1
data/README.markdown CHANGED
@@ -1,36 +1,59 @@
1
- # Bb8
1
+ # BB-8
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bb8`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ BB-8 helps you store your [Terraform](https://www.terraform.io) environments securely, managing the encryption of sensitive files into a git repository, and the encryption keys are shared with other team members using [Voltos](https://voltos.io).
6
4
 
7
5
  ## Installation
8
6
 
9
- Add this line to your application's Gemfile:
7
+ Install the gem:
10
8
 
11
- ```ruby
12
- gem 'bb8'
13
- ```
9
+ $ gem install bb8
14
10
 
15
- And then execute:
11
+ Also, you'll want to have [Terraform](https://www.terraform.io) and [Voltos](https://voltos.io) installed, plus have Voltos authenticated on your machine.
16
12
 
17
- $ bundle
13
+ ## Usage
18
14
 
19
- Or install it yourself as:
15
+ BB-8 manages your infrastructure plans within a single git repository, which has separate folders for each environment (e.g. production, staging, etc). To get going, run the init command with a directory for the git repository (or use `.` for the current directory)
20
16
 
21
- $ gem install bb8
17
+ $ bb8 init servers
22
18
 
23
- ## Usage
19
+ Then move into your project's directory (i.e. `cd servers`). You'll want to add an `origin` remote to your git repository where all of this infrastructure configuration will live.
20
+
21
+ $ git remote add origin git://...
22
+
23
+ The next step is to set up an environment:
24
24
 
25
- TODO: Write usage instructions here
25
+ $ bb8 staging init my-servers-staging
26
26
 
27
- ## Development
27
+ The order of arguments is as follows: the name of the environment, the `init` command, and the name of a bundle of Voltos settings. BB-8 will create the latter for you, if you've not already done so.
28
28
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
+ From this point on, you'll want to issue Terraform commands through BB-8 and a specified environment:
30
30
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
+ $ bb8 staging apply
32
+ $ bb8 staging show
33
+ $ bb8 staging destroy
34
+
35
+ The Terraform configuration is expected along the following lines:
36
+
37
+ * Common infrastructure for all environments should exist in a file `common.tf` in the root of the project. This is automatically copied to each environment directory.
38
+ * Environment-specific infrastructure configuration can live in files within the environment directory.
39
+ * Variable files such as `terraform.tfvars` should live in their appropriate environment folders.
40
+
41
+ Calling a Terraform command via BB-8 goes through this workflow every time:
42
+
43
+ * Merge the latest changes from the git remote.
44
+ * Decrypt all Terraform state and variable files.
45
+ * Invoke Terraform.
46
+ * Encrypt all Terraform state and variable files.
47
+ * Push changes up to the git remote.
48
+
49
+ The unencrypted versions of the state and variable files are _not_ added to the git repository, thus your secrets remain secret to anyone without access to each environment's Voltos bundle.
50
+
51
+ To allow others to work on your infrastructure, they'll need access to both the git repository, _and_ the appropriate Voltos bundles.
32
52
 
33
53
  ## Contributing
34
54
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bb8. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pat/bb8. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
56
+
57
+ ## Licence
36
58
 
59
+ Copyright (c) 2016, BB-8 is developed and maintained by Pat Allan, and is released under the open MIT Licence.
data/bb8.gemspec CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = BB8::VERSION
9
9
  spec.authors = ["Pat Allan"]
10
10
  spec.email = ["pat@freelancing-gods.com"]
11
+ spec.licenses = ['MIT']
11
12
 
12
13
  spec.summary = %q{Manage and share Terraform variables, environments, and states securely.}
13
14
  spec.homepage = "https://github.com/pat/bb8"
@@ -19,7 +20,8 @@ Gem::Specification.new do |spec|
19
20
  spec.executables = spec.files.grep(%r{^exe/}) { |file| File.basename(file) }
20
21
  spec.require_paths = ["lib"]
21
22
 
22
- spec.add_runtime_dependency "voltos", "~> 0.3"
23
+ spec.add_runtime_dependency "curb", "~> 0.9.3"
24
+ spec.add_runtime_dependency "voltos", "~> 0.3"
23
25
 
24
26
  spec.add_development_dependency "rspec", "~> 3.0"
25
27
  end
data/lib/bb8.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'curb'
1
2
  require 'fileutils'
2
3
  require 'json'
3
4
  require 'openssl'
@@ -20,4 +21,5 @@ require 'bb8/decrypt'
20
21
  require 'bb8/encrypt'
21
22
  require 'bb8/set_encryption_keys'
22
23
  require 'bb8/version'
24
+ require 'bb8/voltos_api'
23
25
  require 'bb8/voltos_variables'
@@ -1,6 +1,4 @@
1
1
  class BB8::Commands::InitialiseEnvironment
2
- VOLTOS_CONFIGURATION = File.expand_path("~/.voltos/config.json")
3
-
4
2
  def self.call(name, voltos_bundle, *arguments)
5
3
  new(name, voltos_bundle).call
6
4
  end
@@ -13,8 +11,8 @@ class BB8::Commands::InitialiseEnvironment
13
11
  FileUtils.mkdir_p name
14
12
  Dir.chdir name
15
13
 
16
- `voltos create #{voltos_bundle}`
17
- `voltos use #{voltos_bundle}`
14
+ api.create_bundle voltos_bundle unless bundles.include? voltos_bundle
15
+ `voltos use #{voltos_bundle}` unless set_bundle?
18
16
  BB8::SetEncryptionKeys.call
19
17
 
20
18
  File.write '.bb8_bundle', voltos_bundle
@@ -23,4 +21,16 @@ class BB8::Commands::InitialiseEnvironment
23
21
  private
24
22
 
25
23
  attr_reader :name, :voltos_bundle
24
+
25
+ def api
26
+ @api ||= BB8::VoltosAPI.new
27
+ end
28
+
29
+ def bundles
30
+ api.bundles.collect { |bundle| bundle['name'] }
31
+ end
32
+
33
+ def set_bundle?
34
+ File.exist?('.env') && File.read('.env')[/^VOLTOS_KEY=(\w+)/]
35
+ end
26
36
  end
data/lib/bb8/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module BB8
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -0,0 +1,34 @@
1
+ class BB8::VoltosAPI
2
+ DOMAIN = 'https://api.voltos.io'
3
+ VERSION = 'v1'
4
+ ENDPOINT = "#{DOMAIN}/#{VERSION}"
5
+
6
+ def bundles
7
+ JSON.parse Curl.get("#{ENDPOINT}/bundles") { |http|
8
+ http.headers['User-Agent'] = "BB8/#{BB8::VERSION}"
9
+ http.headers['Authorization'] = "Token token=#{token}"
10
+ }.body_str
11
+ end
12
+
13
+ def create_bundle(name)
14
+ JSON.parse Curl.post("#{ENDPOINT}/bundles", {
15
+ :name => name,
16
+ :token_name => 'BB8'
17
+ }) { |http|
18
+ http.headers['User-Agent'] = "BB8/#{BB8::VERSION}"
19
+ http.headers['Authorization'] = "Token token=#{token}"
20
+ }.body_str
21
+ end
22
+
23
+ private
24
+
25
+ def configuration
26
+ @configuration ||= JSON.parse(
27
+ File.read(File.expand_path('~/.voltos/config.json'))
28
+ )
29
+ end
30
+
31
+ def token
32
+ configuration['auths']["#{ENDPOINT}"]['auth']
33
+ end
34
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bb8
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-16 00:00:00.000000000 Z
11
+ date: 2016-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: curb
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.3
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: voltos
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -68,9 +82,11 @@ files:
68
82
  - lib/bb8/encrypt.rb
69
83
  - lib/bb8/set_encryption_keys.rb
70
84
  - lib/bb8/version.rb
85
+ - lib/bb8/voltos_api.rb
71
86
  - lib/bb8/voltos_variables.rb
72
87
  homepage: https://github.com/pat/bb8
73
- licenses: []
88
+ licenses:
89
+ - MIT
74
90
  metadata: {}
75
91
  post_install_message:
76
92
  rdoc_options: []