vagrant-registration 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -2
- data/README.md +7 -1
- data/lib/vagrant-registration/action.rb +10 -3
- data/lib/vagrant-registration/action/register.rb +12 -2
- data/lib/vagrant-registration/action/unregister_on_destroy.rb +56 -0
- data/lib/vagrant-registration/action/unregister_on_halt.rb +57 -0
- data/lib/vagrant-registration/config.rb +2 -0
- data/lib/vagrant-registration/plugin.rb +9 -4
- data/lib/vagrant-registration/version.rb +1 -1
- data/plugins/guests/redhat/cap/registration.rb +10 -0
- data/plugins/guests/redhat/cap/subscription_manager.rb +7 -0
- data/plugins/guests/redhat/plugin.rb +10 -0
- data/vagrant-registration-0.0.16/.gitignore +34 -0
- data/vagrant-registration-0.0.16/CHANGELOG.md +3 -0
- data/vagrant-registration-0.0.16/Gemfile +9 -0
- data/vagrant-registration-0.0.16/LICENSE.md +339 -0
- data/vagrant-registration-0.0.16/README.md +149 -0
- data/vagrant-registration-0.0.16/Rakefile +25 -0
- data/vagrant-registration-0.0.16/Vagrantfile +44 -0
- data/vagrant-registration-0.0.16/dummy.box +0 -0
- data/vagrant-registration-0.0.16/lib/vagrant-registration.rb +21 -0
- data/vagrant-registration-0.0.16/lib/vagrant-registration/action.rb +22 -0
- data/vagrant-registration-0.0.16/lib/vagrant-registration/action/register.rb +113 -0
- data/{lib → vagrant-registration-0.0.16/lib}/vagrant-registration/action/unregister.rb +0 -0
- data/vagrant-registration-0.0.16/lib/vagrant-registration/config.rb +39 -0
- data/vagrant-registration-0.0.16/lib/vagrant-registration/plugin.rb +74 -0
- data/vagrant-registration-0.0.16/lib/vagrant-registration/version.rb +5 -0
- data/vagrant-registration-0.0.16/plugins/guests/redhat/cap/registration.rb +72 -0
- data/vagrant-registration-0.0.16/plugins/guests/redhat/cap/subscription_manager.rb +63 -0
- data/vagrant-registration-0.0.16/plugins/guests/redhat/plugin.rb +62 -0
- data/vagrant-registration-0.0.16/tests/helpers.sh +128 -0
- data/vagrant-registration-0.0.16/tests/run.sh +59 -0
- data/vagrant-registration-0.0.16/tests/vagrantfiles/Vagrantfile.rhel_multi_machine +19 -0
- data/vagrant-registration-0.0.16/tests/vagrantfiles/Vagrantfile.rhel_wrong_credentials +14 -0
- data/vagrant-registration-0.0.16/vagrant-registration.gemspec +49 -0
- data/vagrant-registration-0.0.17/.gitignore +34 -0
- data/vagrant-registration-0.0.17/CHANGELOG.md +3 -0
- data/vagrant-registration-0.0.17/Gemfile +9 -0
- data/vagrant-registration-0.0.17/LICENSE.md +339 -0
- data/vagrant-registration-0.0.17/README.md +149 -0
- data/vagrant-registration-0.0.17/Rakefile +25 -0
- data/vagrant-registration-0.0.17/Vagrantfile +44 -0
- data/vagrant-registration-0.0.17/dummy.box +0 -0
- data/vagrant-registration-0.0.17/lib/vagrant-registration.rb +21 -0
- data/vagrant-registration-0.0.17/lib/vagrant-registration/action.rb +22 -0
- data/vagrant-registration-0.0.17/lib/vagrant-registration/action/register.rb +113 -0
- data/vagrant-registration-0.0.17/lib/vagrant-registration/action/unregister.rb +56 -0
- data/vagrant-registration-0.0.17/lib/vagrant-registration/config.rb +39 -0
- data/vagrant-registration-0.0.17/lib/vagrant-registration/plugin.rb +74 -0
- data/vagrant-registration-0.0.17/lib/vagrant-registration/version.rb +5 -0
- data/vagrant-registration-0.0.17/plugins/guests/redhat/cap/registration.rb +72 -0
- data/vagrant-registration-0.0.17/plugins/guests/redhat/cap/subscription_manager.rb +63 -0
- data/vagrant-registration-0.0.17/plugins/guests/redhat/plugin.rb +62 -0
- data/vagrant-registration-0.0.17/tests/helpers.sh +128 -0
- data/vagrant-registration-0.0.17/tests/run.sh +59 -0
- data/vagrant-registration-0.0.17/tests/vagrantfiles/Vagrantfile.rhel_multi_machine +19 -0
- data/vagrant-registration-0.0.17/tests/vagrantfiles/Vagrantfile.rhel_wrong_credentials +14 -0
- data/vagrant-registration-0.0.17/vagrant-registration.gemspec +49 -0
- data/vagrant-registration-0.0.17/vagrant-registration.spec +90 -0
- metadata +93 -45
@@ -0,0 +1,72 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestRedHat
|
3
|
+
module Cap
|
4
|
+
# This provides registration capabilities for vagrant-registration
|
5
|
+
#
|
6
|
+
# As we might support more registration options (managers), this
|
7
|
+
# just calls the capabilities of the selected registration manager
|
8
|
+
# (from config.registration.manager).
|
9
|
+
class Registration
|
10
|
+
# Register the given machine
|
11
|
+
def self.registration_register(machine)
|
12
|
+
cap = "#{self.registration_manager(machine).to_s}_register".to_sym
|
13
|
+
if machine.guest.capability?(cap)
|
14
|
+
machine.guest.capability(cap, machine.config.registration)
|
15
|
+
else
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Unregister the given machine
|
21
|
+
def self.registration_unregister(machine)
|
22
|
+
cap = "#{self.registration_manager(machine).to_s}_unregister".to_sym
|
23
|
+
if machine.guest.capability?(cap)
|
24
|
+
machine.guest.capability(cap)
|
25
|
+
else
|
26
|
+
false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Check that the machine has the selected registration manager installed
|
31
|
+
def self.registration_manager_installed(machine)
|
32
|
+
cap = "#{self.registration_manager(machine).to_s}".to_sym
|
33
|
+
if machine.guest.capability?(cap)
|
34
|
+
machine.guest.capability(cap)
|
35
|
+
else
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Required configuration options of the registration manager
|
41
|
+
#
|
42
|
+
# This is array of arrays of all possible registration combinations.
|
43
|
+
# First one is the default used in interactive mode.
|
44
|
+
#
|
45
|
+
# e.g. [[:username, :password]]
|
46
|
+
def self.registration_credentials(machine)
|
47
|
+
cap = "#{self.registration_manager(machine).to_s}_credentials".to_sym
|
48
|
+
if machine.guest.capability?(cap)
|
49
|
+
machine.guest.capability(cap)
|
50
|
+
else
|
51
|
+
[]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Return secret options for the registration manager
|
56
|
+
def self.registration_secrets(machine)
|
57
|
+
cap = "#{self.registration_manager(machine).to_s}_secrets".to_sym
|
58
|
+
if machine.guest.capability?(cap)
|
59
|
+
machine.guest.capability(cap)
|
60
|
+
else
|
61
|
+
[]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Return selected registration manager or default
|
66
|
+
def self.registration_manager(machine)
|
67
|
+
(machine.config.registration.manager || 'subscription_manager').to_sym
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestRedHat
|
3
|
+
module Cap
|
4
|
+
class SubscriptionManager
|
5
|
+
# Test that we have subscription-manager installed
|
6
|
+
def self.subscription_manager(machine)
|
7
|
+
machine.communicate.test("/sbin/subscription-manager", sudo: true)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Register the machine using 'register' option, config is (Open)Struct
|
11
|
+
def self.subscription_manager_register(machine, config)
|
12
|
+
command = "subscription-manager register #{configuration_to_options(config)}"
|
13
|
+
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)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Unregister the machine using 'unregister' option
|
17
|
+
def self.subscription_manager_unregister(machine)
|
18
|
+
machine.communicate.execute("subscription-manager unregister || :", sudo: true)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Return required configuration options for subscription-manager
|
22
|
+
def self.subscription_manager_credentials(machine)
|
23
|
+
[[:username, :password], [:org, :activationkey]]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Return secret options for subscription-manager
|
27
|
+
def self.subscription_manager_secrets(machine)
|
28
|
+
[:password]
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# Build additional subscription-manager options based on plugin configuration
|
34
|
+
def self.configuration_to_options(config)
|
35
|
+
config.force = true unless config.force
|
36
|
+
|
37
|
+
# --auto-attach cannot be used in case of org/activationkey registration
|
38
|
+
if config.org && config.activationkey
|
39
|
+
config.auto_attach = false
|
40
|
+
else
|
41
|
+
config.auto_attach = true unless config.auto_attach
|
42
|
+
end
|
43
|
+
|
44
|
+
options = []
|
45
|
+
options << "--username='#{config.username}'" if config.username
|
46
|
+
options << "--password='#{config.password}'" if config.password
|
47
|
+
options << "--serverurl='#{config.serverurl}'" if config.serverurl
|
48
|
+
options << "--baseurl='#{config.baseurl}'" if config.baseurl
|
49
|
+
options << "--org='#{config.org}'" if config.org
|
50
|
+
options << "--environment='#{config.environment}'" if config.environment
|
51
|
+
options << "--name='#{config.name}'" if config.name
|
52
|
+
options << "--auto-attach" if config.auto_attach
|
53
|
+
options << "--activationkey='#{config.activationkey}'" if config.activationkey
|
54
|
+
options << "--servicelevel='#{config.servicelevel}'" if config.servicelevel
|
55
|
+
options << "--release='#{config.release}'" if config.release
|
56
|
+
options << "--force" if config.force
|
57
|
+
options << "--type='#{config.type}'" if config.type
|
58
|
+
options.join(' ')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GuestRedHat
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
6
|
+
guest_capability("redhat", "registration_register") do
|
7
|
+
require_relative "cap/registration"
|
8
|
+
Cap::Registration
|
9
|
+
end
|
10
|
+
|
11
|
+
guest_capability("redhat", "registration_unregister") do
|
12
|
+
require_relative "cap/registration"
|
13
|
+
Cap::Registration
|
14
|
+
end
|
15
|
+
|
16
|
+
guest_capability("redhat", "registration_manager_installed") do
|
17
|
+
require_relative "cap/registration"
|
18
|
+
Cap::Registration
|
19
|
+
end
|
20
|
+
|
21
|
+
guest_capability("redhat", "registration_credentials") do
|
22
|
+
require_relative "cap/registration"
|
23
|
+
Cap::Registration
|
24
|
+
end
|
25
|
+
|
26
|
+
guest_capability("redhat", "registration_secrets") do
|
27
|
+
require_relative "cap/registration"
|
28
|
+
Cap::Registration
|
29
|
+
end
|
30
|
+
|
31
|
+
guest_capability("redhat", "registration_manager") do
|
32
|
+
require_relative "cap/registration"
|
33
|
+
Cap::Registration
|
34
|
+
end
|
35
|
+
|
36
|
+
guest_capability("redhat", "subscription_manager") do
|
37
|
+
require_relative "cap/subscription_manager"
|
38
|
+
Cap::SubscriptionManager
|
39
|
+
end
|
40
|
+
|
41
|
+
guest_capability("redhat", "subscription_manager_register") do
|
42
|
+
require_relative "cap/subscription_manager"
|
43
|
+
Cap::SubscriptionManager
|
44
|
+
end
|
45
|
+
|
46
|
+
guest_capability("redhat", "subscription_manager_unregister") do
|
47
|
+
require_relative "cap/subscription_manager"
|
48
|
+
Cap::SubscriptionManager
|
49
|
+
end
|
50
|
+
|
51
|
+
guest_capability("redhat", "subscription_manager_credentials") do
|
52
|
+
require_relative "cap/subscription_manager"
|
53
|
+
Cap::SubscriptionManager
|
54
|
+
end
|
55
|
+
|
56
|
+
guest_capability("redhat", "subscription_manager_secrets") do
|
57
|
+
require_relative "cap/subscription_manager"
|
58
|
+
Cap::SubscriptionManager
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# Set up test environment
|
2
|
+
function setup_tests() {
|
3
|
+
check_credentials
|
4
|
+
install_dependencies
|
5
|
+
|
6
|
+
# Test results that should be printed at the end
|
7
|
+
TEST_RESULTS=''
|
8
|
+
FAILED=0
|
9
|
+
SUCCEDED=0
|
10
|
+
EXIT_CODE=0
|
11
|
+
}
|
12
|
+
|
13
|
+
# Print test results
|
14
|
+
function print_results() {
|
15
|
+
if [ "$TEST_RESULTS" != "" ]; then
|
16
|
+
printf "\n$TEST_RESULTS\n"
|
17
|
+
fi
|
18
|
+
printf "\n$SUCCEDED succeded, $FAILED failed.\n"
|
19
|
+
exit $EXIT_CODE
|
20
|
+
}
|
21
|
+
|
22
|
+
# Clean up before each test
|
23
|
+
function clean_up() {
|
24
|
+
# Clean up Vagrant metadata
|
25
|
+
rm -rf $DIR/.vagrant
|
26
|
+
}
|
27
|
+
|
28
|
+
# Check that we have credentials to run the test suite
|
29
|
+
function check_credentials() {
|
30
|
+
if [ "$VAGRANT_REGISTRATION_USERNAME" = "" ] || [ "$VAGRANT_REGISTRATION_PASSWORD" = "" ]; then
|
31
|
+
echo "VAGRANT_REGISTRATION_USERNAME and VAGRANT_REGISTRATION_PASSWORD needs to be provided."
|
32
|
+
exit 1
|
33
|
+
fi
|
34
|
+
if [ "$VAGRANT_REGISTRATION_ORG" = "" ] || [ "$VAGRANT_REGISTRATION_ACTIVATIONKEY" = "" ]; then
|
35
|
+
echo "VAGRANT_REGISTRATION_ORG and VAGRANT_REGISTRATION_ACTIVATIONKEY needs to be provided."
|
36
|
+
exit 1
|
37
|
+
fi
|
38
|
+
}
|
39
|
+
|
40
|
+
# Install vagrant and vagrant-registration
|
41
|
+
function install_dependencies() {
|
42
|
+
# Install Vagrant if it's not present
|
43
|
+
PLUGIN_INSTALLED=$(vagrant --help)
|
44
|
+
if [ $? -ne 0 ]; then
|
45
|
+
sudo yum install vagrant-libvirt -y
|
46
|
+
fi
|
47
|
+
|
48
|
+
# Uninstall vagrant-registration if installed
|
49
|
+
# TODO: Uninstall RPM package if needed
|
50
|
+
PLUGIN_INSTALLED=$(vagrant plugin list | grep vagrant-registration)
|
51
|
+
if [ -z "$PLUGIN_INSTALLED" ]; then
|
52
|
+
vagrant plugin uninstall vagrant-registration
|
53
|
+
fi
|
54
|
+
|
55
|
+
# Install vagrant-registration from current sources
|
56
|
+
rm -rf pkg
|
57
|
+
rake build
|
58
|
+
vagrant plugin install pkg/vagrant-registration*.gem
|
59
|
+
}
|
60
|
+
|
61
|
+
# Test that command succeded
|
62
|
+
#
|
63
|
+
# Usage:
|
64
|
+
#
|
65
|
+
# test_success TEST_NAME COMMAND_TO_RUN
|
66
|
+
#
|
67
|
+
# Example:
|
68
|
+
#
|
69
|
+
# test_success "ls won't fail" "ls -all"
|
70
|
+
function test_success() {
|
71
|
+
eval $2 >&1 >/dev/null
|
72
|
+
if [ $? -ne 0 ]; then
|
73
|
+
printf "F"
|
74
|
+
FAILED=$((FAILED + 1))
|
75
|
+
EXIT_CODE=1
|
76
|
+
TEST_RESULTS="$TEST_RESULTS\nTest '$1' failed with command:"
|
77
|
+
TEST_RESULTS="$TEST_RESULTS\n $2"
|
78
|
+
else
|
79
|
+
SUCCEDED=$((SUCCEDED + 1))
|
80
|
+
printf '.'
|
81
|
+
fi
|
82
|
+
}
|
83
|
+
|
84
|
+
# Test that command failed
|
85
|
+
#
|
86
|
+
# Usage:
|
87
|
+
#
|
88
|
+
# test_failure TEST_NAME COMMAND_TO_RUN
|
89
|
+
#
|
90
|
+
# Example:
|
91
|
+
#
|
92
|
+
# test_failure "this should fail" "echoo"
|
93
|
+
function test_failure() {
|
94
|
+
eval $2 >&1 >/dev/null
|
95
|
+
if [ $? -ne 0 ]; then
|
96
|
+
SUCCEDED=$((SUCCEDED + 1))
|
97
|
+
printf '.'
|
98
|
+
else
|
99
|
+
printf "F"
|
100
|
+
FAILED=$((FAILED + 1))
|
101
|
+
EXIT_CODE=1
|
102
|
+
TEST_RESULTS="$TEST_RESULTS\nTest '$1' dit not fail with command:"
|
103
|
+
TEST_RESULTS="$TEST_RESULTS\n $2"
|
104
|
+
fi
|
105
|
+
}
|
106
|
+
|
107
|
+
# Test that command produced an expected output
|
108
|
+
#
|
109
|
+
# Usage:
|
110
|
+
#
|
111
|
+
# test_output TEST_NAME COMMAND_TO_RUN EXPECTED_OUTPUT
|
112
|
+
#
|
113
|
+
# Example:
|
114
|
+
#
|
115
|
+
# test_output "echo abc outputs abc" "echo 'abc'" "abc"
|
116
|
+
function test_output() {
|
117
|
+
eval $2 >&1| grep "$3" >/dev/null
|
118
|
+
if [ $? -ne 0 ]; then
|
119
|
+
printf "F"
|
120
|
+
FAILED=$((FAILED + 1))
|
121
|
+
EXIT_CODE=1
|
122
|
+
TEST_RESULTS="$TEST_RESULTS\nTest '$1' failed with command:"
|
123
|
+
TEST_RESULTS="$TEST_RESULTS\n $2 | grep '$3'"
|
124
|
+
else
|
125
|
+
SUCCEDED=$((SUCCEDED + 1))
|
126
|
+
printf '.'
|
127
|
+
fi
|
128
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# This tests test vagrant-registration plugin running on Fedora
|
4
|
+
# with libvirt. If you do not have Vagrant installed or if you
|
5
|
+
# have vagrant-libvirt package on your system, Vagrant will be
|
6
|
+
# installed or vagrant-libvirt removed respectively. In that case
|
7
|
+
# you need sudo to run the tests. If you do not run Fedora, make
|
8
|
+
# sure you have Vagrant installed (any provider should do if you
|
9
|
+
# add RHEL box called 'rhel-7').
|
10
|
+
#
|
11
|
+
# IMPORTANT: Tests need valid credentials to actually test
|
12
|
+
# registration. This can be provided in form of environment
|
13
|
+
# variables.
|
14
|
+
#
|
15
|
+
# NOTE: This will install a development version of
|
16
|
+
# vagrant-registration on your system.
|
17
|
+
#
|
18
|
+
# == subscription-manager
|
19
|
+
#
|
20
|
+
# For testing subscription-manager on RHEL export
|
21
|
+
# VAGRANT_REGISTRATION_USERNAME with VAGRANT_REGISTRATION_PASSWORD
|
22
|
+
# for username/password registration and VAGRANT_REGISTRATION_ORG
|
23
|
+
# with VAGRANT_REGISTRATION_ACTIVATIONKEY for org/activationkey one.
|
24
|
+
#
|
25
|
+
|
26
|
+
DIR=$(dirname $(readlink -f "$0"))
|
27
|
+
|
28
|
+
# Import test helpers
|
29
|
+
. $DIR/helpers.sh
|
30
|
+
|
31
|
+
setup_tests
|
32
|
+
|
33
|
+
# Test correct username/password and org/activationkey credentials in a multi-machine setup
|
34
|
+
clean_up
|
35
|
+
export VAGRANT_VAGRANTFILE=$DIR/vagrantfiles/Vagrantfile.rhel_multi_machine
|
36
|
+
|
37
|
+
test_success 'vagrant up on RHEL multi_machine setup' 'vagrant up rhel1-valid-credentials'
|
38
|
+
|
39
|
+
test_output 'first machine is registered with given username/password' \
|
40
|
+
'vagrant ssh rhel1-valid-credentials -c '\''sudo subscription-manager register'\''' \
|
41
|
+
'This system is already registered.'
|
42
|
+
|
43
|
+
test_success 'vagrant halt on RHEL multi_machine setup' 'vagrant halt rhel1-valid-credentials'
|
44
|
+
test_success 'vagrant halt on RHEL multi_machine setup' 'vagrant destroy'
|
45
|
+
test_success 'vagrant up on RHEL multi_machine setup' 'vagrant up rhel2-valid-credentials'
|
46
|
+
|
47
|
+
test_output 'second machine is registered with given org/activationkey' \
|
48
|
+
'vagrant ssh rhel2-valid-credentials -c '\''sudo subscription-manager register'\''' \
|
49
|
+
'This system is already registered.'
|
50
|
+
|
51
|
+
test_success 'vagrant halt on RHEL multi_machine setup' 'vagrant destroy'
|
52
|
+
|
53
|
+
# Test wrong credentials
|
54
|
+
clean_up
|
55
|
+
export VAGRANT_VAGRANTFILE=$DIR/vagrantfiles/Vagrantfile.rhel_wrong_credentials
|
56
|
+
test_failure 'vagrant up on RHEL with wrong credentials should fail' 'vagrant up'
|
57
|
+
test_success 'vagrant destroy on RHEL with wrong credentials' 'vagrant destroy'
|
58
|
+
|
59
|
+
print_results
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Spin 3 RHEL machines that will be registered
|
2
|
+
|
3
|
+
ENV['VAGRANT_DEFAULT_PROVIDER'] ||= 'libvirt'
|
4
|
+
ENV['VAGRANT_REGISTRATION_RHEL_BOX'] ||= 'rhel-7.0'
|
5
|
+
|
6
|
+
Vagrant.configure('2') do |config|
|
7
|
+
config.vm.box = ENV['VAGRANT_REGISTRATION_RHEL_BOX']
|
8
|
+
|
9
|
+
config.vm.define "rhel1-valid-credentials" do |c|
|
10
|
+
c.registration.username = ENV['VAGRANT_REGISTRATION_USERNAME']
|
11
|
+
c.registration.password = ENV['VAGRANT_REGISTRATION_PASSWORD']
|
12
|
+
end
|
13
|
+
|
14
|
+
config.vm.define "rhel2-valid-credentials" do |c|
|
15
|
+
c.registration.org = ENV['VAGRANT_REGISTRATION_ORG']
|
16
|
+
c.registration.activationkey = ENV['VAGRANT_REGISTRATION_ACTIVATIONKEY']
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Spin 1 RHEL machine with wrong credentials
|
2
|
+
|
3
|
+
ENV['VAGRANT_DEFAULT_PROVIDER'] ||= 'libvirt'
|
4
|
+
ENV['VAGRANT_REGISTRATION_RHEL_BOX'] ||= 'rhel-7.0'
|
5
|
+
|
6
|
+
Vagrant.configure('2') do |config|
|
7
|
+
config.vm.box = ENV['VAGRANT_REGISTRATION_RHEL_BOX']
|
8
|
+
|
9
|
+
config.vm.define "rhel1-wrong-credentials" do |c|
|
10
|
+
c.registration.username = 'wrong_username'
|
11
|
+
c.registration.password = 'wrong_password'
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
require "vagrant-registration/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "vagrant-registration"
|
6
|
+
s.version = VagrantPlugins::Registration::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.license = "GPL-2.0"
|
9
|
+
s.authors = ["Langdon White", "Josef Strzibny", "et al"]
|
10
|
+
s.email = ["langdon@fedoraproject.org", "strzibny@strzibny.name"]
|
11
|
+
s.summary = "Automatic guest registration for Vagrant"
|
12
|
+
s.description = "Enables guests to be registered automatically which is especially useful for RHEL or SLES guests."
|
13
|
+
s.homepage = "https://github.com/projectatomic/adb-vagrant-registration"
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
|
16
|
+
# Note that the entire gitignore(5) syntax is not supported, specifically
|
17
|
+
# the "!" syntax, but it should mostly work correctly.
|
18
|
+
root_path = File.dirname(__FILE__)
|
19
|
+
all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
|
20
|
+
all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
|
21
|
+
gitignore_path = File.join(root_path, ".gitignore")
|
22
|
+
gitignore = File.readlines(gitignore_path)
|
23
|
+
gitignore.map! { |line| line.chomp.strip }
|
24
|
+
gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
|
25
|
+
|
26
|
+
unignored_files = all_files.reject do |file|
|
27
|
+
# Ignore any directories, the gemspec only cares about files
|
28
|
+
next true if File.directory?(file)
|
29
|
+
|
30
|
+
# Ignore any paths that match anything in the gitignore. We do
|
31
|
+
# two tests here:
|
32
|
+
#
|
33
|
+
# - First, test to see if the entire path matches the gitignore.
|
34
|
+
# - Second, match if the basename does, this makes it so that things
|
35
|
+
# like '.DS_Store' will match sub-directories too (same behavior
|
36
|
+
# as git).
|
37
|
+
#
|
38
|
+
gitignore.any? do |ignore|
|
39
|
+
File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
|
40
|
+
File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
s.files = unignored_files
|
45
|
+
s.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
|
46
|
+
s.require_path = 'lib'
|
47
|
+
|
48
|
+
s.add_development_dependency 'yard'
|
49
|
+
end
|