vagrant-registration 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -21
- data/lib/vagrant-registration/config.rb +92 -11
- data/lib/vagrant-registration/version.rb +1 -1
- data/plugins/guests/redhat/cap/register.rb +22 -3
- data/plugins/guests/redhat/plugin.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e315e6013e06ae4e0e2e443a8f4eda40e1460241
|
4
|
+
data.tar.gz: a279b9fefcb4e7e1d36ea9f2055d1c0a87599e3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99c38ec395222dda39ae3a9debfd4dd8a944735f122328b4be485952c7604b28f21cf4a9d249c6cf3ccc3823dd853855e266a5eb0b1150ed3c6673346a4dd9ec
|
7
|
+
data.tar.gz: 69771079e48c96a54d18d1eaa330dd275dbb4715aaf2416a9eaf352297cc9a51b97ce4801a368e8c2531fab0f37a98672459a70e51763bbabc53f2365cf7415a
|
data/README.md
CHANGED
@@ -1,42 +1,64 @@
|
|
1
1
|
# vagrant-registration
|
2
2
|
|
3
|
-
The vagrant-registration plugin supports new capabilities "register" and "unregister." The "register" event occurs during the "up" process, immediately after startup but before any provisioning (including built-in like
|
3
|
+
The vagrant-registration plugin supports new capabilities "register" and "unregister." The "register" event occurs during the "up" process, immediately after startup but before any provisioning (including built-in like rsync). The "unregister" event occurs during the "halt" process (which also is called during the "destroy" process) immediately before the instances goes down.
|
4
4
|
|
5
|
-
|
5
|
+
This allows developers to easily register their guests that use subscription model for updates, like Red Hat Enterprise Linux.
|
6
6
|
|
7
|
-
To use, make sure you have the capabilities registered and your subscription-manager credentials properly configured in your Vagrant file.
|
8
7
|
|
9
|
-
## Using
|
10
8
|
|
11
|
-
|
9
|
+
## Installation
|
12
10
|
|
13
|
-
|
14
|
-
* configure subscription-manager credentials in your Vagrantfile
|
15
|
-
* that should be it
|
11
|
+
Install as any other Vagrant plugin:
|
16
12
|
|
17
|
-
|
13
|
+
```ruby
|
14
|
+
vagrant plugin install vagrant-registration
|
15
|
+
```
|
18
16
|
|
19
|
-
|
17
|
+
## Usage
|
20
18
|
|
21
|
-
|
22
|
-
config.registration.subscriber_password = 'bar'
|
19
|
+
*Note:* This plugin is still alpha. Please help us to find and fix any bugs.
|
23
20
|
|
24
|
-
|
21
|
+
- Only RHEL Subscription Manager is currectly supported.
|
25
22
|
|
26
|
-
|
23
|
+
### subscription-manager Configuration
|
27
24
|
|
28
|
-
|
29
|
-
|
25
|
+
vagrant-registration supports all the options of subscription-manager's register command.
|
26
|
+
You can set any option easily by setting `config.registration.OPTION_NAME = 'OPTION_VALUE'`
|
27
|
+
in your Vagrantfile (please see the subscription-manager's documentation for option
|
28
|
+
description).
|
30
29
|
|
31
|
-
|
30
|
+
Setting up the credentials can be done as follows:
|
32
31
|
|
33
|
-
|
32
|
+
```ruby
|
33
|
+
config.registration.username = 'foo'
|
34
|
+
config.registration.password = 'bar'
|
35
|
+
```
|
34
36
|
|
37
|
+
This should go, preferably, into the Vagrantfile in your Vagrant home directory
|
38
|
+
(defaults to ~/.vagrant.d), to make it available for every project. It can be
|
39
|
+
later overriden in an individual project's Vagrantfile, if needed.
|
40
|
+
|
41
|
+
If you prefer not to store your username and/or password on your filesystem,
|
42
|
+
you can optionally configure vagrant-registration plugin to use environment
|
43
|
+
variables, such as:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
config.registration.username = ENV['SUB_USERNAME']
|
47
|
+
config.registration.password = ENV['SUB_PASSWORD']
|
48
|
+
```
|
49
|
+
|
50
|
+
If you do not provide credentials, you will be prompted for them in the "up process". However, this is a tentative feature because if you are launching more than one VM from one Vagrantfile, the feature acts unexepectedly (appearing to hang because the prompt for creds gets lost in the scrollback).
|
51
|
+
|
52
|
+
You can also skip the registration process altogether by setting a `skip` option
|
53
|
+
to `true`:
|
54
|
+
|
55
|
+
```ruby
|
35
56
|
config.registration.skip = true
|
57
|
+
```
|
36
58
|
|
37
|
-
RHEL Subscription Manager will fail if you attempt to register
|
59
|
+
*Note:* RHEL Subscription Manager will fail if you attempt to register an already registered machine (see man page for explanation). Not to slow the boot time, vagrant-registration appends the "--force" flag when subscribing. If you would like to disable this feature, set `force` option to `false`:
|
38
60
|
|
61
|
+
```ruby
|
39
62
|
config.registration.force = false
|
63
|
+
```
|
40
64
|
|
41
|
-
## Support
|
42
|
-
Currently, "capabilities" are only provided for Red Hat's Subscription Manager. To add others, one just needs to add a new guest plugin, then a cap directory with register.rb and unregister.rb. See the redhat guest for an example.
|
@@ -3,38 +3,119 @@ require "vagrant"
|
|
3
3
|
module VagrantPlugins
|
4
4
|
module Registration
|
5
5
|
class Config < Vagrant.plugin("2", :config)
|
6
|
-
# The username to subscribe with
|
6
|
+
# The username to subscribe with (required)
|
7
7
|
#
|
8
8
|
# @return [String]
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :username
|
10
|
+
attr_accessor :subscriber_username # to stay backwards compatible
|
10
11
|
|
11
|
-
# The password of the subscriber
|
12
|
+
# The password of the subscriber (required)
|
12
13
|
#
|
13
14
|
# @return [String]
|
14
|
-
attr_accessor :
|
15
|
+
attr_accessor :password
|
16
|
+
attr_accessor :subscriber_password # to stay backwards compatible
|
15
17
|
|
16
|
-
#
|
18
|
+
# Give the hostname of the subscription service to use (required for Subscription
|
19
|
+
# Asset Manager, defaults to Customer Portal Subscription Management)
|
20
|
+
#
|
21
|
+
# @return [String]
|
22
|
+
attr_accessor :serverurl
|
23
|
+
|
24
|
+
# Give the hostname of the content delivery server to use to receive updates
|
25
|
+
# (required for Satellite 6)
|
26
|
+
#
|
27
|
+
# @return [String]
|
28
|
+
attr_accessor :baseurl
|
29
|
+
|
30
|
+
# Give the organization to which to join the system (required, except for
|
31
|
+
# hosted environments)
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
attr_accessor :org
|
35
|
+
|
36
|
+
# Register the system to an environment within an organization (optional)
|
37
|
+
#
|
38
|
+
# @return [String]
|
39
|
+
attr_accessor :environment
|
40
|
+
|
41
|
+
# Name of the subscribed system (optional, defaults to hostname if unset)
|
42
|
+
#
|
43
|
+
# @return [String]
|
44
|
+
attr_accessor :name
|
45
|
+
|
46
|
+
# Auto attach suitable subscriptions (optional, auto attach if true)
|
17
47
|
#
|
18
48
|
# @return [Bool]
|
19
|
-
attr_accessor :
|
49
|
+
attr_accessor :auto_attach
|
50
|
+
|
51
|
+
# Attach existing subscriptions as part of the registration process (optional)
|
52
|
+
#
|
53
|
+
# @return [String]
|
54
|
+
attr_accessor :activationkey
|
20
55
|
|
21
|
-
#
|
56
|
+
# Set the service level to use for subscriptions on that machine
|
57
|
+
# (optional, used only used with the --auto-attach)
|
58
|
+
#
|
59
|
+
# @return [String]
|
60
|
+
attr_accessor :servicelevel
|
61
|
+
|
62
|
+
# Set the operating system minor release to use for subscriptions for
|
63
|
+
# the system (optional, used only used with the --auto-attach)
|
64
|
+
#
|
65
|
+
# @return [String]
|
66
|
+
attr_accessor :release
|
67
|
+
|
68
|
+
# Force the registration (optional, force if true, defaults to true)
|
22
69
|
#
|
23
70
|
# @return [Bool]
|
24
71
|
attr_accessor :force
|
25
72
|
|
73
|
+
# Set what type of consumer is being registered (optional, defaults to system)
|
74
|
+
#
|
75
|
+
# @return [String]
|
76
|
+
attr_accessor :type
|
77
|
+
|
78
|
+
# Skip the registration (optional, skip if true, defaults to false)
|
79
|
+
#
|
80
|
+
# @return [Bool]
|
81
|
+
attr_accessor :skip
|
82
|
+
|
26
83
|
def initialize(region_specific=false)
|
84
|
+
@username = UNSET_VALUE
|
27
85
|
@subscriber_username = UNSET_VALUE
|
86
|
+
@password = UNSET_VALUE
|
28
87
|
@subscriber_password = UNSET_VALUE
|
29
|
-
@
|
88
|
+
@serverurl = UNSET_VALUE
|
89
|
+
@baseurl = UNSET_VALUE
|
90
|
+
@org = UNSET_VALUE
|
91
|
+
@environment = UNSET_VALUE
|
92
|
+
@name = UNSET_VALUE
|
93
|
+
@auto_attach = true
|
94
|
+
@activationkey = UNSET_VALUE
|
95
|
+
@servicelevel = UNSET_VALUE
|
96
|
+
@release = UNSET_VALUE
|
30
97
|
@force = true
|
98
|
+
@type = UNSET_VALUE
|
99
|
+
@skip = UNSET_VALUE
|
31
100
|
end
|
32
101
|
|
33
102
|
def finalize!
|
34
|
-
@
|
35
|
-
@
|
36
|
-
@
|
103
|
+
@username = @subscriber_username if @username == UNSET_VALUE
|
104
|
+
@password = @subscriber_password if @password == UNSET_VALUE
|
105
|
+
@username = nil if @username == UNSET_VALUE
|
106
|
+
@password = nil if @password == UNSET_VALUE
|
107
|
+
@serverurl = nil if @serverurl = UNSET_VALUE
|
108
|
+
@baseurl = nil if @baseurl = UNSET_VALUE
|
109
|
+
@org = nil if @org = UNSET_VALUE
|
110
|
+
@environment = nil if @environment = UNSET_VALUE
|
111
|
+
@name = nil if @name == UNSET_VALUE
|
112
|
+
@auto_attach = true if @auto_attach == UNSET_VALUE
|
113
|
+
@activationkey = nil if @activationkey = UNSET_VALUE
|
114
|
+
@servicelevel = nil if @servicelevel = UNSET_VALUE
|
115
|
+
@release = nil if @release = UNSET_VALUE
|
37
116
|
@force = true if @force == UNSET_VALUE
|
117
|
+
@type = nil if @type == UNSET_VALUE
|
118
|
+
@skip = false if @skip == UNSET_VALUE
|
38
119
|
end
|
39
120
|
end
|
40
121
|
end
|
@@ -3,11 +3,30 @@ module VagrantPlugins
|
|
3
3
|
module Cap
|
4
4
|
class Register
|
5
5
|
def self.register(machine)
|
6
|
-
|
7
|
-
password = machine.config.registration.subscriber_password
|
8
|
-
command = "subscription-manager register --username=#{username} --password=#{password} --auto-attach #{"--force" if machine.config.registration.force}"
|
6
|
+
command = "subscription-manager register #{configuration_to_options(machine.config)}"
|
9
7
|
machine.communicate.execute("cmd=$(#{command}); if [ \"$?\" != \"0\" ]; then echo $cmd | grep 'This system is already registered' || (echo $cmd 1>&2 && exit 1) ; fi", sudo: true)
|
10
8
|
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
# Build additional subscription-manager options based on plugin configuration
|
13
|
+
def self.configuration_to_options(config)
|
14
|
+
options = []
|
15
|
+
options << "--username=#{config.registration.username}"
|
16
|
+
options << "--password=#{config.registration.password}"
|
17
|
+
options << "--serverurl=#{config.registration.serverurl}" if config.registration.serverurl
|
18
|
+
options << "--baseurl=#{config.registration.baseurl}" if config.registration.baseurl
|
19
|
+
options << "--org=#{config.registration.org}" if config.registration.org
|
20
|
+
options << "--environment=#{config.registration.environment}" if config.registration.environment
|
21
|
+
options << "--name=#{config.registration.name}" if config.registration.name
|
22
|
+
options << "--auto-attach" if config.registration.auto_attach
|
23
|
+
options << "--activationkey=#{config.registration.activationkey}" if config.registration.activationkey
|
24
|
+
options << "--servicelevel=#{config.registration.servicelevel}" if config.registration.servicelevel
|
25
|
+
options << "--release=#{config.registration.release}" if config.registration.release
|
26
|
+
options << "--force" if config.registration.force
|
27
|
+
options << "--type=#{config.registration.type}" if config.registration.type
|
28
|
+
options.join(' ')
|
29
|
+
end
|
11
30
|
end
|
12
31
|
end
|
13
32
|
end
|
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: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Langdon White
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Enables guests to have a registration capability, this is expecially
|
15
15
|
useful on RHEL or SLES
|
@@ -78,3 +78,4 @@ signing_key:
|
|
78
78
|
specification_version: 4
|
79
79
|
summary: Enables guests to have a registration capability
|
80
80
|
test_files: []
|
81
|
+
has_rdoc:
|