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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42f2db8ea11b622d6ad6dd1b691ccc5ded35c382
4
- data.tar.gz: 3d54a94859b480f43847134eafad448fc25b4f21
3
+ metadata.gz: e315e6013e06ae4e0e2e443a8f4eda40e1460241
4
+ data.tar.gz: a279b9fefcb4e7e1d36ea9f2055d1c0a87599e3a
5
5
  SHA512:
6
- metadata.gz: 597f363023a366eab93f06eb7ab900266107beeef7645372ce535559e9b0c7f1118767b67d5e308ab7b95b420d86c146bff7e28a407cfc821b95324805ade7c3
7
- data.tar.gz: 02e667660538c40126bf11b2d01ac646b6629b23bf5e8b513475a8be3677aea78e8cc6eedc35f36850d9a8567e064a5b73d39c7f57f9c83f6efaa9ac7d4f33fc
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 rysnc). The "unregister" event occurs during the "halt" process (which also is called during the "destroy" process) immediately before the instances goes down.
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
- Essentially, this supports developers wanting to use linuxes that have a subscription model for updates, like RHEL.
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
- The plugin is still very early alpha, so YMMV. If you try it out, and have problems, please feel free to file an issue.
9
+ ## Installation
12
10
 
13
- * vagrant plugin install vagrant-registration
14
- * configure subscription-manager credentials in your Vagrantfile
15
- * that should be it
11
+ Install as any other Vagrant plugin:
16
12
 
17
- ### subscription-manager Credential Configuration
13
+ ```ruby
14
+ vagrant plugin install vagrant-registration
15
+ ```
18
16
 
19
- You should add the following entries into your Vagrantfile:
17
+ ## Usage
20
18
 
21
- config.registration.subscriber_username = 'foo'
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
- This should go, preferably, into the Vagrantfile in your Vagrant home directory (defaults to ~/.vagrant.d), to make it available for every project. It can be later overriden in an individual project's Vagrant file, if needed.
21
+ - Only RHEL Subscription Manager is currectly supported.
25
22
 
26
- If you prefer not to store your username/password on your filesystem, you can optionally configure vagrant-registration plugin to use environment variables, such as:
23
+ ### subscription-manager Configuration
27
24
 
28
- config.registration.subscriber_username = ENV['SUB_USERNAME']
29
- config.registration.subscriber_password = ENV['SUB_PASSWORD']
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
- Finally, 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).
30
+ Setting up the credentials can be done as follows:
32
31
 
33
- You can also skip registration altogether if you would prefer but don't want to remove the plugin. If you want this function, please use
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 a registered machine (see the man page for why). In order to not slow boot time, we now, by default, pass the "--force" flag when we try to subscribe. If you want to disable this feature:
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 :subscriber_username
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 :subscriber_password
15
+ attr_accessor :password
16
+ attr_accessor :subscriber_password # to stay backwards compatible
15
17
 
16
- # Skip the registration (skip if true)
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 :skip
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
- # Force the registration (skip if true)
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
- @skip = UNSET_VALUE
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
- @subscriber_username = nil if @subscriber_username == UNSET_VALUE
35
- @subscriber_password = nil if @subscriber_password == UNSET_VALUE
36
- @skip = false if @skip == UNSET_VALUE
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
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Registration
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
@@ -3,11 +3,30 @@ module VagrantPlugins
3
3
  module Cap
4
4
  class Register
5
5
  def self.register(machine)
6
- username = machine.config.registration.subscriber_username
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
@@ -20,7 +20,7 @@ module VagrantPlugins
20
20
 
21
21
  guest_capability("redhat", "rhcert") do
22
22
  require_relative "cap/redhat_certification_tool"
23
- Cap::ContainerProbeTool
23
+ Cap::RedHatCertification
24
24
  end
25
25
  end
26
26
  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.8
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-02-18 00:00:00.000000000 Z
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: