hiera-eyaml-gpg 0.4 → 0.5.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,8 +1,7 @@
1
1
  source 'https://rubygems.org/'
2
2
 
3
3
  gem 'hiera-eyaml', ">=1.3.8"
4
- gem 'gpgme', ">=2.0.0"
5
4
 
6
5
  group :development do
7
6
  gem "aruba"
8
- end
7
+ end
data/README.md CHANGED
@@ -25,6 +25,17 @@ To get started, install the hiera-eyaml-gpg gem.
25
25
 
26
26
  $ gem install hiera-eyaml-gpg
27
27
 
28
+ You will also need to install either the `gpgme` (recommended) or `ruby_gpg` gem:
29
+
30
+ $ gem install gpgme
31
+
32
+ OR
33
+
34
+ $ gem install ruby_gpg -v ">=0.3.1"
35
+
36
+ Note: you will need to use `ruby_gpg` with the Puppet server as it uses JRuby which cannot
37
+ make use of native extensions such as `gpgme`.
38
+
28
39
  If you haven't already installed it, this requires and will install the hiera-eyaml gem, which you
29
40
  should probably acquint yourself with at https://github.com/TomPoulton/hiera-eyaml.
30
41
 
@@ -38,7 +49,7 @@ How to use
38
49
 
39
50
  Once installed you can create encrypted hiera-eyaml blocks that are encrypted using GPG.
40
51
 
41
- $ eyaml -n gpg -e -s "A secret string to encrypt" --gpg-recipients bob@example.com,hiera@example.com
52
+ $ eyaml encrypt -n gpg -s "A secret string to encrypt" --gpg-recipients bob@example.com,hiera@example.com
42
53
 
43
54
  If you do not have a web of trust (i.e. you normally use --always-trust for gpg signing) then you'll need
44
55
  to use the `--gpg-always-trust` option on the command line.
@@ -46,7 +57,7 @@ to use the `--gpg-always-trust` option on the command line.
46
57
  It gets pretty dull to keep on remembering which recipients you should use, so you can put them in a file
47
58
  and specify that instead.
48
59
 
49
- $ eyaml -n gpg -e -s "A secret string to encrypt" --gpg-recipients-file hiera-eyaml-gpg.recipients
60
+ $ eyaml encrypt -n gpg -s "A secret string to encrypt" --gpg-recipients-file hiera-eyaml-gpg.recipients
50
61
 
51
62
  In fact, when editing a file on disk and neither of the --gpg-recipient options are provided it will
52
63
  automatically look for a `hiera-eyaml-gpg.recipients` file in the same directory as the file being edited
@@ -18,5 +18,4 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency('hiera-eyaml', '>=1.3.8')
21
- gem.add_dependency('gpgme', '>=2.0.0')
22
21
  end
@@ -3,9 +3,9 @@ class Hiera
3
3
  module Eyaml
4
4
  module Encryptors
5
5
  module Gpg
6
- VERSION = "0.4"
6
+ VERSION = "0.5.rc1"
7
7
  end
8
8
  end
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -1,4 +1,13 @@
1
- require 'gpgme'
1
+ begin
2
+ require 'gpgme'
3
+ rescue LoadError
4
+ begin
5
+ require 'ruby_gpg'
6
+ rescue LoadError
7
+ fail "hiera-eyaml-gpg requires either the 'gpgme' or 'ruby_gpg' gem"
8
+ end
9
+ end
10
+
2
11
  require 'base64'
3
12
  require 'pathname'
4
13
  require 'hiera/backend/eyaml/encryptor'
@@ -93,8 +102,13 @@ class Hiera
93
102
  end
94
103
 
95
104
  def self.encrypt plaintext
96
- ENV["GNUPGHOME"] = self.option :gnupghome
97
- debug("GNUPGHOME is #{ENV['GNUPGHOME']}")
105
+ unless defined?(GPGME)
106
+ raise RecoverableError, "Encryption is only supported when using the 'gpgme' gem"
107
+ end
108
+
109
+ gnupghome = self.option :gnupghome
110
+ GPGME::Engine.home_dir = gnupghome
111
+ debug("GNUPGHOME is #{gnupghome}")
98
112
 
99
113
  ctx = GPGME::Ctx.new
100
114
 
@@ -132,8 +146,15 @@ class Hiera
132
146
  end
133
147
 
134
148
  def self.decrypt ciphertext
135
- ENV["GNUPGHOME"] = self.option :gnupghome
136
- debug("GNUPGHOME is #{ENV['GNUPGHOME']}")
149
+ gnupghome = self.option :gnupghome
150
+ debug("GNUPGHOME is #{gnupghome}")
151
+
152
+ unless defined?(GPGME)
153
+ RubyGpg.config.homedir = gnupghome if gnupghome
154
+ return RubyGpg.decrypt_string(ciphertext)
155
+ end
156
+
157
+ GPGME::Engine.home_dir = gnupghome
137
158
 
138
159
  ctx = if hiera?
139
160
  GPGME::Ctx.new
@@ -158,8 +179,8 @@ class Hiera
158
179
  txt.seek 0
159
180
  txt.read
160
181
  else
161
- warn("No usable keys found in #{ENV['GNUPGHOME']}. Check :gpgpghome value in hiera.yaml is correct")
162
- raise ArgumentError, "No usable keys found in #{ENV['GNUPGHOME']}. Check :gpgpghome value in hiera.yaml is correct"
182
+ warn("No usable keys found in #{gnupghome}. Check :gpg_gnupghome value in hiera.yaml is correct")
183
+ raise ArgumentError, "No usable keys found in #{gnupghome}. Check :gpg_gnupghome value in hiera.yaml is correct"
163
184
  end
164
185
  end
165
186
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera-eyaml-gpg
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
5
- prerelease:
4
+ version: 0.5.rc1
5
+ prerelease: 4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Simon Hildrew
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-26 00:00:00.000000000 Z
12
+ date: 2015-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hiera-eyaml
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.3.8
30
- - !ruby/object:Gem::Dependency
31
- name: gpgme
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 2.0.0
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: 2.0.0
46
30
  description: GPG encryptor for use with hiera-eyaml
47
31
  email:
48
32
  executables: []
@@ -75,13 +59,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
59
  required_rubygems_version: !ruby/object:Gem::Requirement
76
60
  none: false
77
61
  requirements:
78
- - - ! '>='
62
+ - - ! '>'
79
63
  - !ruby/object:Gem::Version
80
- version: '0'
64
+ version: 1.3.1
81
65
  requirements: []
82
66
  rubyforge_project:
83
- rubygems_version: 1.8.23
67
+ rubygems_version: 1.8.23.2
84
68
  signing_key:
85
69
  specification_version: 3
86
70
  summary: Encryption plugin for hiera-eyaml backend for Hiera
87
71
  test_files: []
72
+ has_rdoc: