vagrant-registration 1.1.0 → 1.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: f3faa5f60610d751ab605780b28956d11a6af323
4
- data.tar.gz: 0bef59c99cefb7dc5156b4d80ca841e0a82fe696
3
+ metadata.gz: 9a7c34f5e89fbe90dfc0194f6f467d1ef13e11bf
4
+ data.tar.gz: 4941f9c200a6a8f50fb14fa9c6910b5d3d51ef2e
5
5
  SHA512:
6
- metadata.gz: 3a39cf4efff1c4af5a311439120d816034d649d9fba5e77f1fd28a5ab736627ed149e86b60f635c0425514f5ecd02cdbdfda88d3ef84ef7cbc6b75f32c3f0256
7
- data.tar.gz: 6c65312f483594fc0bffa7e540c91b5a1ad0e84acbf375cb70c30397f0c45e4fd717a32624f63377a09c566a89ee739008233a378126816e68e8dc36b3f7be0e
6
+ metadata.gz: 7b322d3bf982b1e5a380f53d420be07ad83ea1e6d04ee575402daa27d204f95aa4449fdf2c26d147d9ac38810b987e0ff57a50c500865206fdae92a3bb1a3389
7
+ data.tar.gz: e9a80d397296c0098a1b1916e7f9351527c1e2e6269404714c015bc89834b3aa55f26bcda6a2779b53d9870fd5a2e59eeeb01aa4d121b4f895316aa6c9721762
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.0
4
+
5
+ - Fix: `vagrant destroy` not triggering subscription deactivation and removal, issue #57
6
+ - Fix: Allow auto-attach and force options to be configured
7
+ - Fix: Remove unnecessary shebang from python script
8
+ - Support for attaching to specified subscription pool(s), issue #36
9
+ - Fix: rhn_register upload certificate fails, issue #60
10
+
3
11
  ## 1.1.0
4
12
 
5
13
  - Print warning if specifically selected manager is not available
data/README.md CHANGED
@@ -133,7 +133,7 @@ description).
133
133
  config.registration.auto_attach = false
134
134
  ```
135
135
 
136
- Note that the `auto_attach` option is set to false when using org/activationkey for registration.
136
+ Note that the `auto_attach` option is set to false when using org/activationkey for registration or if pools are specified.
137
137
 
138
138
  #### subscription-manager Options Reference
139
139
 
@@ -189,6 +189,12 @@ Note that the `auto_attach` option is set to false when using org/activationkey
189
189
 
190
190
  # Skip the registration (optional, skip if true, defaults to false)
191
191
  config.registration.skip
192
+
193
+ # Attach to specified pool(s) (optional)
194
+ #
195
+ # Example:
196
+ # config.registration.pools = [ 'POOL-ID-1', 'POOL-ID-2' ]
197
+ config.registration.pools
192
198
  ```
193
199
 
194
200
  ### rhn-register Configuration
@@ -14,7 +14,7 @@ module VagrantPlugins
14
14
  config = env[:machine].config.registration
15
15
  guest = env[:machine].guest
16
16
 
17
- if capabilities_provided?(guest) && manager_installed?(guest) && !config.skip
17
+ if capabilities_provided?(guest) && manager_installed?(guest, env[:ui]) && !config.skip
18
18
  env[:ui].info('Unregistering box with vagrant-registration...')
19
19
  guest.capability(:registration_unregister)
20
20
  end
@@ -42,8 +42,8 @@ module VagrantPlugins
42
42
  end
43
43
 
44
44
  # Check if selected registration manager is installed
45
- def manager_installed?(guest)
46
- if guest.capability(:registration_manager_installed)
45
+ def manager_installed?(guest, ui)
46
+ if guest.capability(:registration_manager_installed, ui)
47
47
  true
48
48
  else
49
49
  @logger.debug('Registration manager not found on guest')
@@ -14,7 +14,7 @@ module VagrantPlugins
14
14
  config = env[:machine].config.registration
15
15
  guest = env[:machine].guest
16
16
 
17
- if capabilities_provided?(guest) && manager_installed?(guest) && !config.skip && config.unregister_on_halt
17
+ if capabilities_provided?(guest) && manager_installed?(guest, env[:ui]) && !config.skip && config.unregister_on_halt
18
18
  env[:ui].info('Unregistering box with vagrant-registration...')
19
19
  guest.capability(:registration_unregister)
20
20
  end
@@ -43,8 +43,8 @@ module VagrantPlugins
43
43
  end
44
44
 
45
45
  # Check if selected registration manager is installed
46
- def manager_installed?(guest)
47
- if guest.capability(:registration_manager_installed)
46
+ def manager_installed?(guest, ui)
47
+ if guest.capability(:registration_manager_installed, ui)
48
48
  true
49
49
  else
50
50
  @logger.debug('Registration manager not found on guest')
@@ -1,6 +1,6 @@
1
1
  module VagrantPlugins
2
2
  # Registration plugin to auto-register guests on `vagrant up`
3
3
  module Registration
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
6
6
  end
@@ -4,15 +4,15 @@ module VagrantPlugins
4
4
  class RhnRegister
5
5
  # Test that the machine is already registered
6
6
  def self.rhn_register_registered?(machine)
7
- true if machine.communicate.execute('/usr/sbin/rhn_check', sudo: true)
7
+ true if machine.communicate.sudo('/usr/sbin/rhn_check')
8
8
  rescue
9
9
  false
10
10
  end
11
11
 
12
12
  # Test that we have rhn installed
13
13
  def self.rhn_register(machine)
14
- machine.communicate.test('/usr/sbin/rhn_check --version', sudo: true) &&
15
- machine.communicate.test('/usr/sbin/rhnreg_ks --version', sudo: true)
14
+ machine.communicate.test('/usr/sbin/rhn_check --version') &&
15
+ machine.communicate.test('/usr/sbin/rhnreg_ks --version')
16
16
  end
17
17
 
18
18
  # Register the machine using 'rhnreg_ks' command, config is (Open)Struct
@@ -82,14 +82,14 @@ module VagrantPlugins
82
82
  # Make sure the provided CA certificate file will be configured
83
83
  cert_file_name = File.basename(machine.config.registration.ca_cert)
84
84
  cert_file_content = File.read(machine.config.registration.ca_cert, tmp)
85
- machine.communicate.execute("echo '#{cert_file_content}' > /usr/share/rhn/#{cert_file_name}", sudo: true)
85
+ machine.communicate.sudo("echo '#{cert_file_content}' > /usr/share/rhn/#{cert_file_name}")
86
86
  else
87
87
  ui.warn("WARNING: Provided CA certificate file #{machine.config.registration.ca_cert} does not exist, skipping")
88
88
  end
89
89
  end
90
90
  # Make sure the correct CA certificate file is always configured
91
91
  ui.info("Updating CA certificate to /usr/share/rhn/#{cert_file_name}`...")
92
- machine.communicate.execute("sed -i 's|^sslCACert\s*=.*$|sslCACert=/usr/share/rhn/#{cert_file_name}|g' /etc/sysconfig/rhn/up2date", sudo: true)
92
+ machine.communicate.sudo("sed -i 's|^sslCACert\s*=.*$|sslCACert=/usr/share/rhn/#{cert_file_name}|g' /etc/sysconfig/rhn/up2date")
93
93
  end
94
94
 
95
95
  # Build registration command that skips registration if the system is registered
@@ -101,7 +101,7 @@ module VagrantPlugins
101
101
  # provided server URL
102
102
  def self.rhn_register_server_url(machine, ui)
103
103
  ui.info("Update server URL to #{machine.config.registration.serverurl}...")
104
- machine.communicate.execute("sed -i 's|^serverURL=.*$|serverURL=/usr/share/rhn/#{machine.config.registration.serverurl}|' /etc/sysconfig/rhn/up2date", sudo: true)
104
+ machine.communicate.sudo("sed -i 's|^serverURL=.*$|serverURL=/usr/share/rhn/#{machine.config.registration.serverurl}|' /etc/sysconfig/rhn/up2date")
105
105
  end
106
106
 
107
107
  # The absolute path to the resource file
@@ -116,7 +116,7 @@ module VagrantPlugins
116
116
 
117
117
  # Build additional rhreg_ks options based on the plugin configuration
118
118
  def self.configuration_to_options(config)
119
- config.force = true unless config.force
119
+ config.force = true if config.force.nil?
120
120
 
121
121
  options = []
122
122
  options << "--profilename='#{config.name}'" if config.name
@@ -4,14 +4,14 @@ module VagrantPlugins
4
4
  class SubscriptionManager
5
5
  # Test that the machine is already registered
6
6
  def self.subscription_manager_registered?(machine)
7
- false if machine.communicate.execute("/usr/sbin/subscription-manager list --consumed | grep 'No consumed subscription pools to list'", sudo: true)
7
+ false if machine.communicate.sudo("/usr/sbin/subscription-manager list --consumed | grep 'No consumed subscription pools to list'")
8
8
  rescue
9
9
  true
10
10
  end
11
11
 
12
12
  # Test that we have subscription-manager installed
13
13
  def self.subscription_manager(machine)
14
- machine.communicate.test('/usr/sbin/subscription-manager', sudo: true)
14
+ machine.communicate.test('/usr/sbin/subscription-manager')
15
15
  end
16
16
 
17
17
  # Register the machine using 'register' option, config is (Open)Struct
@@ -28,11 +28,13 @@ module VagrantPlugins
28
28
  rescue Vagrant::Errors::VagrantError
29
29
  raise Vagrant::Errors::VagrantError.new, error.strip
30
30
  end
31
+
32
+ attach_pools(machine, machine.config.registration.pools)
31
33
  end
32
34
 
33
35
  # Unregister the machine using 'unregister' option
34
36
  def self.subscription_manager_unregister(machine)
35
- machine.communicate.execute('subscription-manager unregister || :', sudo: true)
37
+ machine.communicate.sudo('subscription-manager unregister || :')
36
38
  end
37
39
 
38
40
  # Return required configuration options for subscription-manager
@@ -47,7 +49,7 @@ module VagrantPlugins
47
49
  def self.subscription_manager_options(machine)
48
50
  [:username, :password, :serverurl, :baseurl, :org, :environment,
49
51
  :name, :auto_attach, :activationkey, :servicelevel, :release,
50
- :force, :type, :ca_cert]
52
+ :force, :type, :ca_cert, :pools]
51
53
  end
52
54
 
53
55
  # Return secret options for subscription-manager
@@ -67,9 +69,9 @@ module VagrantPlugins
67
69
  cert_file_content = File.read(machine.config.registration.ca_cert)
68
70
  cert_file_name = File.basename(machine.config.registration.ca_cert)
69
71
  cert_file_name = "#{cert_file_name}.pem" unless cert_file_name.end_with? '.pem'
70
- machine.communicate.execute("echo '#{cert_file_content}' > /etc/rhsm/ca/#{cert_file_name}", sudo: true)
72
+ machine.communicate.sudo("echo '#{cert_file_content}' > /etc/rhsm/ca/#{cert_file_name}")
71
73
  ui.info('Setting repo_ca_cert option in /etc/rhsm/rhsm.conf...')
72
- machine.communicate.execute("sed -i 's|^repo_ca_cert\s*=.*|repo_ca_cert = /etc/rhsm/ca/#{cert_file_name}|g' /etc/rhsm/rhsm.conf", sudo: true)
74
+ machine.communicate.sudo("sed -i 's|^repo_ca_cert\s*=.*|repo_ca_cert = /etc/rhsm/ca/#{cert_file_name}|g' /etc/rhsm/rhsm.conf")
73
75
  else
74
76
  ui.warn("WARNING: Provided CA certificate file #{machine.config.registration.ca_cert} does not exist, skipping")
75
77
  end
@@ -82,13 +84,14 @@ module VagrantPlugins
82
84
 
83
85
  # Build additional subscription-manager options based on plugin configuration
84
86
  def self.configuration_to_options(config)
85
- config.force = true unless config.force
87
+ config.force = true if config.force.nil?
86
88
 
87
89
  # --auto-attach cannot be used in case of org/activationkey registration
88
- if config.org && config.activationkey
90
+ # or if pools are specified
91
+ if (config.org && config.activationkey) || config.pools
89
92
  config.auto_attach = false
90
93
  else
91
- config.auto_attach = true unless config.auto_attach
94
+ config.auto_attach = true if config.auto_attach.nil?
92
95
  end
93
96
 
94
97
  options = []
@@ -107,6 +110,22 @@ module VagrantPlugins
107
110
  options << "--type='#{config.type}'" if config.type
108
111
  options.join(' ')
109
112
  end
113
+
114
+ # Attach subscription pools
115
+ def self.attach_pools(machine, pools)
116
+ if pools
117
+ command = "subscription-manager attach #{pools_to_options(pools)}"
118
+ machine.communicate.sudo(command)
119
+ end
120
+ end
121
+
122
+ # Return pools options for subscription-manager
123
+ def self.pools_to_options(pools)
124
+ pools = [pools] if pools.kind_of?(String)
125
+ pools.map do |pool|
126
+ "--pool=#{pool}"
127
+ end.join(' ')
128
+ end
110
129
  end
111
130
  end
112
131
  end
@@ -58,11 +58,6 @@ module VagrantPlugins
58
58
  Cap::SubscriptionManager
59
59
  end
60
60
 
61
- guest_capability('redhat', 'subscription_manager_upload_certificate') do
62
- require_relative 'cap/subscription_manager'
63
- Cap::SubscriptionManager
64
- end
65
-
66
61
  guest_capability('redhat', 'subscription_manager_unregister') do
67
62
  require_relative 'cap/subscription_manager'
68
63
  Cap::SubscriptionManager
@@ -1,4 +1,3 @@
1
- #!/usr/bin/python
2
1
  import argparse
3
2
  import xmlrpclib
4
3
  import os.path
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.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Langdon White
@@ -10,20 +10,20 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-10 00:00:00.000000000 Z
13
+ date: 2016-01-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: yard
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ">="
19
+ - - '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ">="
26
+ - - '>='
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
29
  description: Enables guests to be registered automatically which is especially useful
@@ -35,24 +35,24 @@ executables: []
35
35
  extensions: []
36
36
  extra_rdoc_files: []
37
37
  files:
38
- - CHANGELOG.md
39
- - Gemfile
40
- - LICENSE.md
41
- - README.md
42
- - Rakefile
43
38
  - lib/vagrant-registration.rb
44
- - lib/vagrant-registration/action.rb
45
39
  - lib/vagrant-registration/action/register.rb
46
40
  - lib/vagrant-registration/action/unregister_on_destroy.rb
47
41
  - lib/vagrant-registration/action/unregister_on_halt.rb
42
+ - lib/vagrant-registration/version.rb
43
+ - lib/vagrant-registration/action.rb
48
44
  - lib/vagrant-registration/config.rb
49
45
  - lib/vagrant-registration/plugin.rb
50
- - lib/vagrant-registration/version.rb
51
46
  - plugins/guests/redhat/cap/registration.rb
52
47
  - plugins/guests/redhat/cap/rhn_register.rb
53
48
  - plugins/guests/redhat/cap/subscription_manager.rb
54
49
  - plugins/guests/redhat/plugin.rb
55
50
  - resources/rhn_unregister.py
51
+ - Rakefile
52
+ - Gemfile
53
+ - README.md
54
+ - CHANGELOG.md
55
+ - LICENSE.md
56
56
  - vagrant-registration.gemspec
57
57
  homepage: https://github.com/projectatomic/adb-vagrant-registration
58
58
  licenses:
@@ -64,19 +64,18 @@ require_paths:
64
64
  - lib
65
65
  required_ruby_version: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ">="
72
+ - - '>='
73
73
  - !ruby/object:Gem::Version
74
74
  version: 1.3.6
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.4.8
77
+ rubygems_version: 2.0.14
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Automatic guest registration for Vagrant
81
81
  test_files: []
82
- has_rdoc: