vagrant-registration 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +34 -38
- data/lib/vagrant-registration/action/register.rb +45 -12
- data/lib/vagrant-registration/version.rb +1 -1
- data/locales/en.yml +3 -0
- data/plugins/guests/redhat/cap/subscription_manager.rb +10 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30c4aa8836dba26f3cc2bd37286f4553f0811677
|
4
|
+
data.tar.gz: 5137ad1f5fee66e21228b4e8be7e8c186aa36076
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc371bfb460697d54d35ae498ddf36e50a1483d8cc6544aaa2c7e54a93c113458f67e6c9ba528b5cb9454b7b2ff39d78ca64ad1428a9e52a01cfe187d70f2c26
|
7
|
+
data.tar.gz: f35f25302ca53fd14c75503b7c4e4bfe4bc70368065ab5eeafcd766e4d3971cdb0b5d5a6887c90c6efc68f25bcc1e7637706309b3cd537c25125b2431c18e6bf
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.3.0
|
4
|
+
|
5
|
+
- Fixed formatting, typo, grammar in README
|
6
|
+
- Added MAINTAINERS file
|
7
|
+
- Fix #44 allow more than one try to fill username and password
|
8
|
+
- Fixes #99 using proxy info to unregister
|
9
|
+
- Fix #107 register when passing credentials as env variables
|
10
|
+
|
3
11
|
## 1.2.3
|
4
12
|
|
5
13
|
- Issue #90 Use locale based messaging
|
data/README.md
CHANGED
@@ -21,9 +21,9 @@
|
|
21
21
|
|
22
22
|
<!-- /MarkdownTOC -->
|
23
23
|
|
24
|
-
vagrant-registration plugin for Vagrant allows developers to easily register their guests for updates on systems with a subscription model (like Red Hat Enterprise Linux).
|
24
|
+
The vagrant-registration plugin for Vagrant allows developers to easily register their guests for updates on systems with a subscription model (like Red Hat Enterprise Linux).
|
25
25
|
|
26
|
-
This plugin would run *register* action on `vagrant up` before any provisioning and *unregister* on `vagrant halt` or `vagrant destroy`. The actions then call the registration capabilities that have to be provided for given OS.
|
26
|
+
This plugin would run *register* action on `vagrant up` before any provisioning and *unregister* on `vagrant halt` or `vagrant destroy`. The actions then call the registration capabilities that have to be provided for the given OS.
|
27
27
|
|
28
28
|
<a name="installation"></a>
|
29
29
|
## Installation
|
@@ -43,7 +43,7 @@ If you are on Fedora, you can install the packaged version of the plugin by runn
|
|
43
43
|
<a name="usage"></a>
|
44
44
|
## Usage
|
45
45
|
|
46
|
-
The plugin is designed in
|
46
|
+
The plugin is designed in a registration-manager agnostic way, which means, that the plugin itself, depends neither on any OS nor on the way of registration. The vagrant-registration plugin only calls registration capabilities for the given guest, passes the configuration options to them and handles interactive registration.
|
47
47
|
|
48
48
|
That being said, this plugin currently ships only with registration capability files for RHEL's Subscription Manager and `rhn_register`. Feel free to submit others.
|
49
49
|
|
@@ -51,7 +51,7 @@ To configure the plugin, always include the configuration options mentioned in t
|
|
51
51
|
|
52
52
|
```
|
53
53
|
Vagrant.configure('2') do |config|
|
54
|
-
...
|
54
|
+
...
|
55
55
|
end
|
56
56
|
```
|
57
57
|
|
@@ -64,13 +64,13 @@ end
|
|
64
64
|
config.registration.skip = true
|
65
65
|
```
|
66
66
|
|
67
|
-
- **unregister_on_halt** disables or enables automatic unregistration on halt (on shut down)
|
67
|
+
- **unregister_on_halt** disables or enables automatic unregistration on halt (on shut down). By default the plugin unregisters on halt, you can however change that by setting the option to `false` so that the box will unregister only on destroy:
|
68
68
|
|
69
69
|
```ruby
|
70
70
|
config.registration.unregister_on_halt = false
|
71
71
|
```
|
72
72
|
|
73
|
-
- **manager** selects the registration manager provider. By default the plugin will use the `subscription_manager` manager
|
73
|
+
- **manager** selects the registration manager provider. By default the plugin will use the `subscription_manager` as the registration manager provider. You can however, change that by setting the option to a different manager:
|
74
74
|
|
75
75
|
```ruby
|
76
76
|
config.registration.manager = 'subscription_manager'
|
@@ -79,11 +79,11 @@ end
|
|
79
79
|
<a name="credential-configuration"></a>
|
80
80
|
### Credential Configuration
|
81
81
|
|
82
|
-
|
82
|
+
You can set up the credentials as follows:
|
83
83
|
|
84
84
|
```ruby
|
85
85
|
Vagrant.configure('2') do |config|
|
86
|
-
...
|
86
|
+
...
|
87
87
|
if Vagrant.has_plugin?('vagrant-registration')
|
88
88
|
config.registration.username = 'foo'
|
89
89
|
config.registration.password = 'bar'
|
@@ -94,7 +94,7 @@ Vagrant.configure('2') do |config|
|
|
94
94
|
config.registration.org = 'foo'
|
95
95
|
config.registration.activationkey = 'bar'
|
96
96
|
end
|
97
|
-
...
|
97
|
+
...
|
98
98
|
end
|
99
99
|
```
|
100
100
|
|
@@ -104,63 +104,60 @@ later overridden in an individual project's Vagrantfile if needed.
|
|
104
104
|
|
105
105
|
If you prefer not to store your username and/or password on your filesystem,
|
106
106
|
you can optionally configure vagrant-registration plugin to use environment
|
107
|
-
variables
|
107
|
+
variables such as:
|
108
108
|
|
109
109
|
```ruby
|
110
110
|
Vagrant.configure('2') do |config|
|
111
|
-
...
|
111
|
+
...
|
112
112
|
config.registration.username = ENV['SUB_USERNAME']
|
113
113
|
config.registration.password = ENV['SUB_PASSWORD']
|
114
|
-
...
|
114
|
+
...
|
115
115
|
end
|
116
116
|
```
|
117
117
|
|
118
|
-
If you do not
|
118
|
+
If you do not configure your credentials as outlined above, you will receive a maximum of 3 prompts for them during the `vagrant up` process.
|
119
119
|
|
120
|
-
Please note
|
121
|
-
of the configured manager.
|
120
|
+
Please note that the interactive mode asks you for the preferred registration pair only for the configured manager.
|
122
121
|
|
123
122
|
<a name="http-proxy-configuration"></a>
|
124
123
|
### HTTP Proxy Configuration
|
125
124
|
|
126
|
-
HTTP
|
125
|
+
HTTP Proxy can be configured via the _proxy_, _proxyUser_ and _proxyPassword_ configuration options:
|
127
126
|
|
128
127
|
```ruby
|
129
128
|
Vagrant.configure('2') do |config|
|
130
|
-
...
|
129
|
+
...
|
131
130
|
if Vagrant.has_plugin?('vagrant-registration')
|
132
131
|
config.registration.proxy = 'mongo:8080'
|
133
132
|
config.registration.proxyUser = 'flash'
|
134
133
|
config.registration.proxyPassword = 'zarkov'
|
135
134
|
end
|
136
|
-
...
|
135
|
+
...
|
137
136
|
end
|
138
137
|
```
|
139
138
|
|
140
139
|
As described in the [credentials configuration](#credentials-configuration) section, these settings
|
141
|
-
can
|
140
|
+
can be placed either into the Vagrantfile in the Vagrant home directory or provided as
|
142
141
|
environment variables.
|
143
142
|
|
144
143
|
<a name="subscription-manager-configuration"></a>
|
145
144
|
### subscription-manager Configuration
|
146
145
|
|
147
|
-
vagrant-registration
|
148
|
-
configured by setting the `manager` option to `subscription_manager`:
|
146
|
+
The vagrant-registration plugin uses `subscription_manager` as the default manager. This can also be explicitly configured by setting the `manager` option to `subscription_manager`:
|
149
147
|
|
150
148
|
```ruby
|
151
149
|
Vagrant.configure('2') do |config|
|
152
|
-
...
|
150
|
+
...
|
153
151
|
if Vagrant.has_plugin?('vagrant-registration')
|
154
152
|
config.registration.manager = 'subscription_manager'
|
155
153
|
end
|
156
|
-
...
|
154
|
+
...
|
157
155
|
end
|
158
156
|
```
|
159
157
|
|
160
|
-
In case
|
161
|
-
you would be ask on your username/password combination.
|
158
|
+
In case you choose `subscription_manager` as the manager, you would be asked for your user credentials, such as the username and password.
|
162
159
|
|
163
|
-
vagrant-registration supports all the options
|
160
|
+
The vagrant-registration plugin supports all the options for the subscription-manager's register command.
|
164
161
|
You can set any option easily by setting `config.registration.OPTION_NAME = 'OPTION_VALUE'`
|
165
162
|
in your Vagrantfile (please see the subscription-manager's documentation for option
|
166
163
|
description).
|
@@ -263,11 +260,11 @@ vagrant-registration will use the `rhn_register` manager only if explicitly conf
|
|
263
260
|
|
264
261
|
```ruby
|
265
262
|
Vagrant.configure('2') do |config|
|
266
|
-
...
|
263
|
+
...
|
267
264
|
if Vagrant.has_plugin?('vagrant-registration')
|
268
265
|
config.registration.manager = 'rhn_register'
|
269
266
|
end
|
270
|
-
...
|
267
|
+
...
|
271
268
|
end
|
272
269
|
```
|
273
270
|
|
@@ -365,7 +362,7 @@ vagrant-registration supports most of the options of rhnreg_ks's command. You ca
|
|
365
362
|
<a name="development"></a>
|
366
363
|
## Development
|
367
364
|
|
368
|
-
To install a development environment, clone the repo and prepare dependencies by
|
365
|
+
To install a development environment, clone the repo and prepare dependencies by:
|
369
366
|
|
370
367
|
```
|
371
368
|
gem install bundler
|
@@ -381,27 +378,26 @@ The use of [RVM](https://rvm.io) is recommended. Verified to work with ruby 2.0.
|
|
381
378
|
#### Minitest
|
382
379
|
|
383
380
|
The source contains a set of [Minitest](http://ruby-doc.org/stdlib-2.0.0/libdoc/minitest/rdoc/MiniTest.html)
|
384
|
-
unit tests. They can be run via:
|
381
|
+
based unit tests. They can be run via:
|
385
382
|
|
386
383
|
$ bundle exec rake test
|
387
384
|
|
388
385
|
<a name="acceptance-tests"></a>
|
389
386
|
#### Acceptance tests
|
390
387
|
|
391
|
-
The source also contains a set of [Cucumber](https://cucumber.io/) acceptance tests. They can be run via:
|
388
|
+
The source also contains a set of [Cucumber](https://cucumber.io/) based acceptance tests. They can be run via:
|
392
389
|
|
393
390
|
$ bundle exec rake features
|
394
391
|
|
395
392
|
The tests assume that the CDK box files are available under
|
396
393
|
_build/boxes/cdk-\<provider\>.box_. You can either copy the box files manually or
|
397
|
-
use the _get_cdk_
|
394
|
+
use the _get_cdk_ rake task to download them.
|
398
395
|
|
399
|
-
|
400
|
-
are run. You can also run against Libvirt using the environment variable
|
401
|
-
_PROVIDER_:
|
396
|
+
As per default, only the scenarios for CDK in combination with VirtualBox
|
397
|
+
are run. You can also run the tests against Libvirt, using the environment variable _PROVIDER_:
|
402
398
|
|
403
399
|
# Run tests against Libvirt
|
404
|
-
$ bundle exec rake features
|
400
|
+
$ bundle exec rake features PROVIDER=libvirt
|
405
401
|
|
406
402
|
# Run against VirtualBox and Libvirt
|
407
403
|
$ bundle exec rake features PROVIDER=virtualbox,libvirt
|
@@ -410,8 +406,8 @@ You can also run a single feature specifying the explicit feature file to use:
|
|
410
406
|
|
411
407
|
$ bundle exec rake features FEATURE=features/<feature-filename>.feature
|
412
408
|
|
413
|
-
After test execution the
|
414
|
-
They can also be opened via
|
409
|
+
After test execution the acceptance test reports can be found under _build/features_report.html_.
|
410
|
+
They can also be opened via:
|
415
411
|
|
416
412
|
$ bundle exec rake features:open_report
|
417
413
|
|
@@ -5,34 +5,33 @@ module VagrantPlugins
|
|
5
5
|
module Action
|
6
6
|
# This registers the guest if the guest plugin supports it
|
7
7
|
class Register
|
8
|
+
MAX_REGISTRATION_ATTEMPTS = 3
|
9
|
+
|
8
10
|
def initialize(app, _)
|
9
11
|
@app = app
|
10
12
|
@logger = Log4r::Logger.new('vagrant_registration::action::register')
|
11
13
|
end
|
12
14
|
|
13
15
|
def call(env)
|
16
|
+
ui = env[:ui]
|
14
17
|
# Configuration from Vagrantfile
|
15
18
|
config = env[:machine].config.registration
|
16
19
|
machine = env[:machine]
|
17
20
|
guest = env[:machine].guest
|
18
21
|
|
19
|
-
if should_register?(machine,
|
20
|
-
|
21
|
-
check_configuration_options(machine,
|
22
|
+
if should_register?(machine, ui)
|
23
|
+
ui.info I18n.t('registration.action.register.registration_info')
|
24
|
+
check_configuration_options(machine, ui)
|
22
25
|
|
23
|
-
|
26
|
+
if credentials_provided? machine
|
27
|
+
guest.capability(:registration_register, ui)
|
28
|
+
else
|
24
29
|
@logger.debug I18n.t('registration.action.register.no_credentials')
|
25
30
|
|
26
31
|
# Offer to register ATM or skip
|
27
|
-
register_now =
|
28
|
-
|
29
|
-
if register_now == 'n'
|
30
|
-
config.skip = true
|
31
|
-
else
|
32
|
-
config = register_on_screen(machine, env[:ui])
|
33
|
-
end
|
32
|
+
register_now = ui.ask I18n.t('registration.action.register.prompt')
|
33
|
+
process_registration(guest, machine, ui, config) if register_now == 'y'
|
34
34
|
end
|
35
|
-
guest.capability(:registration_register, env[:ui]) unless config.skip
|
36
35
|
end
|
37
36
|
|
38
37
|
@logger.debug(I18n.t('registration.action.register.skip_due_config')) if config.skip
|
@@ -145,6 +144,40 @@ module VagrantPlugins
|
|
145
144
|
end
|
146
145
|
machine.config.registration
|
147
146
|
end
|
147
|
+
|
148
|
+
def process_registration(guest, machine, ui, config)
|
149
|
+
attempt_count = 1
|
150
|
+
|
151
|
+
MAX_REGISTRATION_ATTEMPTS.times do
|
152
|
+
config = register_on_screen(machine, ui)
|
153
|
+
|
154
|
+
begin
|
155
|
+
guest.capability(:registration_register, ui)
|
156
|
+
ui.info I18n.t('registration.action.register.registration_success')
|
157
|
+
# break out of loop on successful registration
|
158
|
+
break
|
159
|
+
rescue StandardError => e
|
160
|
+
if attempt_count == MAX_REGISTRATION_ATTEMPTS
|
161
|
+
ui.error e.message
|
162
|
+
exit 126
|
163
|
+
else
|
164
|
+
# reset registration config
|
165
|
+
reset_registration_config(machine)
|
166
|
+
attempt_count += 1
|
167
|
+
ui.info I18n.t('registration.action.register.registration_retry',
|
168
|
+
attempt_count: attempt_count, max_attempt: MAX_REGISTRATION_ATTEMPTS)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
config
|
174
|
+
end
|
175
|
+
|
176
|
+
def reset_registration_config(machine)
|
177
|
+
credentials_required(machine)[0].each do |option|
|
178
|
+
machine.config.registration.send("#{option}=".to_sym, nil)
|
179
|
+
end
|
180
|
+
end
|
148
181
|
end
|
149
182
|
end
|
150
183
|
end
|
data/locales/en.yml
CHANGED
@@ -21,6 +21,9 @@ en:
|
|
21
21
|
WARNING: %{options}"
|
22
22
|
unsupported_option: "WARNING: %{option} option is not supported for %{manager}"
|
23
23
|
skip_missing_guest_capability: 'Registration is skipped due to the missing guest capability'
|
24
|
+
registration_retry: |-
|
25
|
+
Invalid username/password. Try again (%{attempt_count}/%{max_attempt})
|
26
|
+
registration_success: 'Registration successful.'
|
24
27
|
unregister:
|
25
28
|
unregistration_info: 'Unregistering box with vagrant-registration...'
|
26
29
|
skip_due_config: 'Unregistration is skipped due to the configuration'
|
@@ -34,7 +34,7 @@ module VagrantPlugins
|
|
34
34
|
|
35
35
|
# Unregister the machine using 'unregister' option
|
36
36
|
def self.subscription_manager_unregister(machine)
|
37
|
-
machine.communicate.sudo(
|
37
|
+
machine.communicate.sudo("subscription-manager unregister #{configuration_to_options_unregister(machine.config.registration)}")
|
38
38
|
end
|
39
39
|
|
40
40
|
# Return required configuration options for subscription-manager
|
@@ -114,6 +114,15 @@ module VagrantPlugins
|
|
114
114
|
options.join(' ')
|
115
115
|
end
|
116
116
|
|
117
|
+
# Build subscription manager options for unregistering the Vagrant guest
|
118
|
+
def self.configuration_to_options_unregister(config)
|
119
|
+
options = []
|
120
|
+
options << "--proxy='#{config.proxy}'" if config.proxy
|
121
|
+
options << "--proxyuser='#{config.proxyUser}'" if config.proxyUser
|
122
|
+
options << "--proxypassword='#{config.proxyPassword}'" if config.proxyPassword
|
123
|
+
options.join(' ')
|
124
|
+
end
|
125
|
+
|
117
126
|
# Attach subscription pools
|
118
127
|
def self.attach_pools(machine, pools)
|
119
128
|
if pools
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-registration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Langdon White
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-09-02 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: Enables guests to be registered automatically which is especially useful
|
16
16
|
for RHEL or SLES guests.
|