vagrant-registration 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -7
- data/Rakefile +18 -1
- data/lib/vagrant-registration.rb +0 -2
- data/lib/vagrant-registration/action/register.rb +13 -5
- data/lib/vagrant-registration/action/unregister.rb +1 -1
- data/lib/vagrant-registration/version.rb +1 -1
- data/plugins/guests/redhat/cap/registration.rb +5 -0
- data/plugins/guests/redhat/cap/subscription_manager.rb +10 -5
- data/plugins/guests/redhat/plugin.rb +0 -5
- data/tests/helpers.sh +4 -0
- data/tests/run.sh +15 -9
- data/tests/vagrantfiles/Vagrantfile.rhel_multi_machine +3 -3
- metadata +2 -11
- data/plugins/guests/fedora/cap/change_host_name.rb +0 -75
- data/plugins/guests/fedora/cap/configure_networks.rb +0 -98
- data/plugins/guests/fedora/cap/flavor.rb +0 -21
- data/plugins/guests/fedora/cap/network_scripts_dir.rb +0 -15
- data/plugins/guests/fedora/cap/nfs_client.rb +0 -11
- data/plugins/guests/fedora/guest.rb +0 -11
- data/plugins/guests/fedora/plugin.rb +0 -41
- data/plugins/guests/redhat/cap/redhat_certification_tool.rb +0 -11
- data/test +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d8e7119e5e2b2817d170b215b712e7c31381590
|
4
|
+
data.tar.gz: 5a684f6e31d2a18cc662030057e08bd35e5e257c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b6d313da487001b3be21481adb7a40756b1010f62da67e0f734a301fe9931c81d0ce9bc8ab70f2f1e7761d4a53673e6130485ee045e36f899d72b0e090f8fa3
|
7
|
+
data.tar.gz: 5e10cbb86cf1f3be46f76f664c05b1d38778c9d21a3d34a2432063b0964237d2c53ed1f6a7cbefaa3cfabd3569f9441417cbb6f889492188d872a5b1d2def4f7
|
data/README.md
CHANGED
@@ -2,22 +2,26 @@
|
|
2
2
|
|
3
3
|
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).
|
4
4
|
|
5
|
-
This plugin would run *register* action on `vagrant up` before any provisioning
|
6
|
-
and *unregister* on `vagrant halt` or `vagrant destroy`. The actions then call the registration capabilities that have to be provided for given OS.
|
5
|
+
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.
|
7
6
|
|
8
7
|
|
9
8
|
## Installation
|
10
9
|
|
11
10
|
Install vagrant-registration as any other Vagrant plugin:
|
12
11
|
|
13
|
-
```
|
14
|
-
vagrant plugin install vagrant-registration
|
12
|
+
```shell
|
13
|
+
$ vagrant plugin install vagrant-registration
|
14
|
+
```
|
15
|
+
|
16
|
+
If you are on Fedora, you can install the packaged version of the plugin by running:
|
17
|
+
|
18
|
+
```shell
|
19
|
+
# dnf install vagrant-registration
|
15
20
|
```
|
16
21
|
|
17
22
|
## Usage
|
18
23
|
|
19
|
-
The plugin is designed in an registration-manager-agnostic way which means that plugin itself does not depend on any OS nor way of registration. vagrant-registration only calls registration capabilities for given guest, passes the configuration options to them and handles
|
20
|
-
interactive registration.
|
24
|
+
The plugin is designed in an registration-manager-agnostic way which means that plugin itself does not depend on any OS nor way of registration. vagrant-registration only calls registration capabilities for given guest, passes the configuration options to them and handles interactive registration.
|
21
25
|
|
22
26
|
That being said, this plugin currently ships only with registration capability files for RHEL's Subscription Manager. Feel free to submit others.
|
23
27
|
|
@@ -45,11 +49,17 @@ if Vagrant.has_plugin?('vagrant-registration')
|
|
45
49
|
config.registration.username = 'foo'
|
46
50
|
config.registration.password = 'bar'
|
47
51
|
end
|
52
|
+
|
53
|
+
# Alternatively
|
54
|
+
if Vagrant.has_plugin?('vagrant-registration')
|
55
|
+
config.registration.org = 'foo'
|
56
|
+
config.registration.activationkey = 'bar'
|
57
|
+
end
|
48
58
|
```
|
49
59
|
|
50
60
|
This should go, preferably, into the Vagrantfile in your Vagrant home directory
|
51
61
|
(defaults to ~/.vagrant.d), to make it available for every project. It can be
|
52
|
-
later
|
62
|
+
later overridden in an individual project's Vagrantfile if needed.
|
53
63
|
|
54
64
|
If you prefer not to store your username and/or password on your filesystem,
|
55
65
|
you can optionally configure vagrant-registration plugin to use environment
|
@@ -62,6 +72,9 @@ variables, such as:
|
|
62
72
|
|
63
73
|
If you do not provide credentials, you will be prompted for them in the "up process."
|
64
74
|
|
75
|
+
Please note the the interactive mode asks you for the preferred registration pair only.
|
76
|
+
In case of a subscription-manager, you would be ask on your username/password combination.
|
77
|
+
|
65
78
|
#### subscription-manager Default Options
|
66
79
|
|
67
80
|
- **--force**: Subscription Manager will fail if you attempt to register an already registered machine (see the man page for explanation), therefore vagrant-registration appends the `--force` flag automatically when subscribing. If you would like to disable this feature, set `force` option to `false`:
|
@@ -77,6 +90,8 @@ If you do not provide credentials, you will be prompted for them in the "up proc
|
|
77
90
|
config.registration.auto_attach = false
|
78
91
|
```
|
79
92
|
|
93
|
+
Note that the `auto_attach` option is set to false when using org/activationkey for registration.
|
94
|
+
|
80
95
|
#### subscription-manager Options Reference
|
81
96
|
|
82
97
|
```ruby
|
data/Rakefile
CHANGED
@@ -1,8 +1,25 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
require 'yard'
|
3
3
|
|
4
|
+
# Documentation
|
4
5
|
YARD::Rake::YardocTask.new do |t|
|
5
6
|
t.files = ['lib/**/*.rb', 'plugins/**/*.rb']
|
6
7
|
t.options = []
|
7
8
|
t.stats_options = ['--list-undoc']
|
8
9
|
end
|
10
|
+
|
11
|
+
task :clean do
|
12
|
+
`rm -rf pkg`
|
13
|
+
end
|
14
|
+
|
15
|
+
# Compare latest release with current git head
|
16
|
+
require 'rubygems/comparator'
|
17
|
+
task compare: [:clean, :build] do
|
18
|
+
git_version = VagrantPlugins::Registration::VERSION
|
19
|
+
options = {}
|
20
|
+
options[:output] = 'pkg'
|
21
|
+
options[:keep_all] = true
|
22
|
+
comparator = Gem::Comparator.new(options)
|
23
|
+
comparator.compare_versions('vagrant-registration', ['_', git_version])
|
24
|
+
comparator.print_results
|
25
|
+
end
|
data/lib/vagrant-registration.rb
CHANGED
@@ -15,8 +15,6 @@ module VagrantPlugins
|
|
15
15
|
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
16
16
|
end
|
17
17
|
|
18
|
-
# Temporally load the extra capability files for Fedora
|
19
|
-
load(File.join(self.source_root, 'plugins/guests/fedora/plugin.rb'))
|
20
18
|
# Temporally load the extra capability files for Red Hat
|
21
19
|
load(File.join(self.source_root, 'plugins/guests/redhat/plugin.rb'))
|
22
20
|
end
|
@@ -47,7 +47,7 @@ module VagrantPlugins
|
|
47
47
|
true
|
48
48
|
else
|
49
49
|
@logger.debug("Registration is skipped due to the missing guest capability")
|
50
|
-
|
50
|
+
false
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -80,17 +80,25 @@ module VagrantPlugins
|
|
80
80
|
end
|
81
81
|
|
82
82
|
# Check if required credentials has been provided in Vagrantfile
|
83
|
+
#
|
84
|
+
# Checks if at least one of the registration options is able to
|
85
|
+
# register.
|
83
86
|
def credentials_provided?(machine)
|
84
|
-
|
85
|
-
|
87
|
+
provided = true
|
88
|
+
credentials_required(machine).each do |registration_option|
|
89
|
+
provided = true
|
90
|
+
registration_option.each do |value|
|
91
|
+
provided = false unless machine.config.registration.send value
|
92
|
+
end
|
93
|
+
break if provided
|
86
94
|
end
|
87
|
-
true
|
95
|
+
provided ? true : false
|
88
96
|
end
|
89
97
|
|
90
98
|
# Ask user on required credentials and return them,
|
91
99
|
# skip options that are provided by Vagrantfile
|
92
100
|
def register_on_screen(machine, ui)
|
93
|
-
credentials_required(machine).each do |option|
|
101
|
+
credentials_required(machine)[0].each do |option|
|
94
102
|
unless machine.config.registration.send(option)
|
95
103
|
echo = !(secrets(machine).include? option)
|
96
104
|
response = ui.ask("#{option}: ", echo: echo)
|
@@ -38,6 +38,11 @@ module VagrantPlugins
|
|
38
38
|
end
|
39
39
|
|
40
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]]
|
41
46
|
def self.registration_credentials(machine)
|
42
47
|
cap = "#{self.registration_manager(machine).to_s}_credentials".to_sym
|
43
48
|
if machine.guest.capability?(cap)
|
@@ -20,7 +20,7 @@ module VagrantPlugins
|
|
20
20
|
|
21
21
|
# Return required configuration options for subscription-manager
|
22
22
|
def self.subscription_manager_credentials(machine)
|
23
|
-
[:username, :password]
|
23
|
+
[[:username, :password], [:org, :activationkey]]
|
24
24
|
end
|
25
25
|
|
26
26
|
# Return secret options for subscription-manager
|
@@ -32,13 +32,18 @@ module VagrantPlugins
|
|
32
32
|
|
33
33
|
# Build additional subscription-manager options based on plugin configuration
|
34
34
|
def self.configuration_to_options(config)
|
35
|
-
# Defaults
|
36
35
|
config.force = true unless config.force
|
37
|
-
|
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
|
38
43
|
|
39
44
|
options = []
|
40
|
-
options << "--username='#{config.username}'"
|
41
|
-
options << "--password='#{config.password}'"
|
45
|
+
options << "--username='#{config.username}'" if config.username
|
46
|
+
options << "--password='#{config.password}'" if config.password
|
42
47
|
options << "--serverurl='#{config.serverurl}'" if config.serverurl
|
43
48
|
options << "--baseurl='#{config.baseurl}'" if config.baseurl
|
44
49
|
options << "--org='#{config.org}'" if config.org
|
@@ -57,11 +57,6 @@ module VagrantPlugins
|
|
57
57
|
require_relative "cap/subscription_manager"
|
58
58
|
Cap::SubscriptionManager
|
59
59
|
end
|
60
|
-
|
61
|
-
guest_capability("redhat", "rhcert") do
|
62
|
-
require_relative "cap/redhat_certification_tool"
|
63
|
-
Cap::RedHatCertification
|
64
|
-
end
|
65
60
|
end
|
66
61
|
end
|
67
62
|
end
|
data/tests/helpers.sh
CHANGED
@@ -31,6 +31,10 @@ function check_credentials() {
|
|
31
31
|
echo "VAGRANT_REGISTRATION_USERNAME and VAGRANT_REGISTRATION_PASSWORD needs to be provided."
|
32
32
|
exit 1
|
33
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
|
34
38
|
}
|
35
39
|
|
36
40
|
# Install vagrant and vagrant-registration
|
data/tests/run.sh
CHANGED
@@ -12,13 +12,16 @@
|
|
12
12
|
# registration. This can be provided in form of environment
|
13
13
|
# variables.
|
14
14
|
#
|
15
|
-
# For testing subscription-manager on RHEL export
|
16
|
-
# VAGRANT_REGISTRATION_USERNAME and
|
17
|
-
# VAGRANT_REGISTRATION_PASSWORD.
|
18
|
-
#
|
19
15
|
# NOTE: This will install a development version of
|
20
16
|
# vagrant-registration on your system.
|
21
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
|
+
#
|
22
25
|
|
23
26
|
DIR=$(dirname $(readlink -f "$0"))
|
24
27
|
|
@@ -27,21 +30,24 @@ DIR=$(dirname $(readlink -f "$0"))
|
|
27
30
|
|
28
31
|
setup_tests
|
29
32
|
|
30
|
-
# Test correct credentials
|
33
|
+
# Test correct username/password and org/activationkey credentials in a multi-machine setup
|
31
34
|
clean_up
|
32
35
|
export VAGRANT_VAGRANTFILE=$DIR/vagrantfiles/Vagrantfile.rhel_multi_machine
|
33
36
|
|
34
|
-
test_success 'vagrant up on RHEL multi_machine setup' 'vagrant up'
|
37
|
+
test_success 'vagrant up on RHEL multi_machine setup' 'vagrant up rhel1-valid-credentials'
|
35
38
|
|
36
|
-
test_output 'first machine is registered' \
|
39
|
+
test_output 'first machine is registered with given username/password' \
|
37
40
|
'vagrant ssh rhel1-valid-credentials -c '\''sudo subscription-manager register'\''' \
|
38
41
|
'This system is already registered.'
|
39
42
|
|
40
|
-
|
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' \
|
41
48
|
'vagrant ssh rhel2-valid-credentials -c '\''sudo subscription-manager register'\''' \
|
42
49
|
'This system is already registered.'
|
43
50
|
|
44
|
-
test_success 'vagrant halt on RHEL multi_machine setup' 'vagrant halt rhel1-valid-credentials'
|
45
51
|
test_success 'vagrant halt on RHEL multi_machine setup' 'vagrant destroy'
|
46
52
|
|
47
53
|
# Test wrong credentials
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Spin
|
1
|
+
# Spin 3 RHEL machines that will be registered
|
2
2
|
|
3
3
|
ENV['VAGRANT_DEFAULT_PROVIDER'] ||= 'libvirt'
|
4
4
|
ENV['VAGRANT_REGISTRATION_RHEL_BOX'] ||= 'rhel-7.0'
|
@@ -12,8 +12,8 @@ Vagrant.configure('2') do |config|
|
|
12
12
|
end
|
13
13
|
|
14
14
|
config.vm.define "rhel2-valid-credentials" do |c|
|
15
|
-
c.registration.
|
16
|
-
c.registration.
|
15
|
+
c.registration.org = ENV['VAGRANT_REGISTRATION_ORG']
|
16
|
+
c.registration.activationkey = ENV['VAGRANT_REGISTRATION_ACTIVATIONKEY']
|
17
17
|
end
|
18
18
|
|
19
19
|
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.16
|
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: 2015-06-
|
13
|
+
date: 2015-06-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: yard
|
@@ -50,18 +50,9 @@ files:
|
|
50
50
|
- lib/vagrant-registration/config.rb
|
51
51
|
- lib/vagrant-registration/plugin.rb
|
52
52
|
- lib/vagrant-registration/version.rb
|
53
|
-
- plugins/guests/fedora/cap/change_host_name.rb
|
54
|
-
- plugins/guests/fedora/cap/configure_networks.rb
|
55
|
-
- plugins/guests/fedora/cap/flavor.rb
|
56
|
-
- plugins/guests/fedora/cap/network_scripts_dir.rb
|
57
|
-
- plugins/guests/fedora/cap/nfs_client.rb
|
58
|
-
- plugins/guests/fedora/guest.rb
|
59
|
-
- plugins/guests/fedora/plugin.rb
|
60
|
-
- plugins/guests/redhat/cap/redhat_certification_tool.rb
|
61
53
|
- plugins/guests/redhat/cap/registration.rb
|
62
54
|
- plugins/guests/redhat/cap/subscription_manager.rb
|
63
55
|
- plugins/guests/redhat/plugin.rb
|
64
|
-
- test
|
65
56
|
- tests/helpers.sh
|
66
57
|
- tests/run.sh
|
67
58
|
- tests/vagrantfiles/Vagrantfile.rhel_multi_machine
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module GuestFedora
|
3
|
-
module Cap
|
4
|
-
class ChangeHostName
|
5
|
-
def self.change_host_name(machine, name)
|
6
|
-
new(machine, name).change!
|
7
|
-
end
|
8
|
-
|
9
|
-
attr_reader :machine, :new_hostname
|
10
|
-
|
11
|
-
def initialize(machine, new_hostname)
|
12
|
-
@machine = machine
|
13
|
-
@new_hostname = new_hostname
|
14
|
-
end
|
15
|
-
|
16
|
-
def change!
|
17
|
-
return unless should_change?
|
18
|
-
|
19
|
-
update_etc_hostname
|
20
|
-
update_etc_hosts
|
21
|
-
refresh_hostname_service
|
22
|
-
end
|
23
|
-
|
24
|
-
def should_change?
|
25
|
-
new_hostname != current_hostname
|
26
|
-
end
|
27
|
-
|
28
|
-
def current_hostname
|
29
|
-
@current_hostname ||= get_current_hostname
|
30
|
-
end
|
31
|
-
|
32
|
-
def get_current_hostname
|
33
|
-
hostname = ""
|
34
|
-
sudo "hostname -f" do |type, data|
|
35
|
-
hostname = data.chomp if type == :stdout && hostname.empty?
|
36
|
-
end
|
37
|
-
|
38
|
-
hostname
|
39
|
-
end
|
40
|
-
|
41
|
-
def update_etc_hostname
|
42
|
-
sudo("echo '#{short_hostname}' > /etc/hostname")
|
43
|
-
end
|
44
|
-
|
45
|
-
# /etc/hosts should resemble:
|
46
|
-
# 127.0.0.1 localhost
|
47
|
-
# 127.0.1.1 host.fqdn.com host.fqdn host
|
48
|
-
def update_etc_hosts
|
49
|
-
ip_address = '([0-9]{1,3}\.){3}[0-9]{1,3}'
|
50
|
-
search = "^(#{ip_address})\\s+#{Regexp.escape(current_hostname)}(\\s.*)?$"
|
51
|
-
replace = "\\1 #{fqdn} #{short_hostname}"
|
52
|
-
expression = ['s', search, replace, 'g'].join('@')
|
53
|
-
|
54
|
-
sudo("sed -ri '#{expression}' /etc/hosts")
|
55
|
-
end
|
56
|
-
|
57
|
-
def refresh_hostname_service
|
58
|
-
sudo("hostname -F /etc/hostname")
|
59
|
-
end
|
60
|
-
|
61
|
-
def fqdn
|
62
|
-
new_hostname
|
63
|
-
end
|
64
|
-
|
65
|
-
def short_hostname
|
66
|
-
new_hostname.split('.').first
|
67
|
-
end
|
68
|
-
|
69
|
-
def sudo(cmd, &block)
|
70
|
-
machine.communicate.sudo(cmd, &block)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
require "set"
|
2
|
-
require "tempfile"
|
3
|
-
|
4
|
-
require "vagrant/util/retryable"
|
5
|
-
require "vagrant/util/template_renderer"
|
6
|
-
|
7
|
-
module VagrantPlugins
|
8
|
-
module GuestFedora
|
9
|
-
module Cap
|
10
|
-
class ConfigureNetworks
|
11
|
-
extend Vagrant::Util::Retryable
|
12
|
-
include Vagrant::Util
|
13
|
-
|
14
|
-
def self.configure_networks(machine, networks)
|
15
|
-
network_scripts_dir = machine.guest.capability("network_scripts_dir")
|
16
|
-
|
17
|
-
virtual = false
|
18
|
-
interface_names = Array.new
|
19
|
-
machine.communicate.sudo("/usr/sbin/biosdevname; echo $?") do |_, result|
|
20
|
-
virtual = true if result.chomp == '4'
|
21
|
-
end
|
22
|
-
|
23
|
-
if virtual
|
24
|
-
machine.communicate.sudo("ls /sys/class/net | grep -v lo") do |_, result|
|
25
|
-
interface_names = result.split("\n")
|
26
|
-
end
|
27
|
-
|
28
|
-
interface_names = networks.map do |network|
|
29
|
-
"#{interface_names[network[:interface]]}"
|
30
|
-
end
|
31
|
-
else
|
32
|
-
machine.communicate.sudo("/usr/sbin/biosdevname -d | grep Kernel | cut -f2 -d: | sed -e 's/ //;'") do |_, result|
|
33
|
-
interface_names = result.split("\n")
|
34
|
-
end
|
35
|
-
|
36
|
-
interface_name_pairs = Array.new
|
37
|
-
interface_names.each do |interface_name|
|
38
|
-
machine.communicate.sudo("/usr/sbin/biosdevname --policy=all_ethN -i #{interface_name}") do |_, result|
|
39
|
-
interface_name_pairs.push([interface_name, result.gsub("\n", "")])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
setting_interface_names = networks.map do |network|
|
44
|
-
"eth#{network[:interface]}"
|
45
|
-
end
|
46
|
-
|
47
|
-
interface_name_pairs.each do |interface_name, previous_interface_name|
|
48
|
-
if setting_interface_names.index(previous_interface_name) == nil
|
49
|
-
interface_names.delete(interface_name)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# Accumulate the configurations to add to the interfaces file as well
|
55
|
-
# as what interfaces we're actually configuring since we use that later.
|
56
|
-
interfaces = Set.new
|
57
|
-
networks.each do |network|
|
58
|
-
interface = interface_names[network[:interface]-1]
|
59
|
-
interfaces.add(interface)
|
60
|
-
network[:device] = interface
|
61
|
-
|
62
|
-
# Remove any previous vagrant configuration in this network
|
63
|
-
# interface's configuration files.
|
64
|
-
machine.communicate.sudo("touch #{network_scripts_dir}/ifcfg-#{interface}")
|
65
|
-
machine.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-#{interface} > /tmp/vagrant-ifcfg-#{interface}")
|
66
|
-
machine.communicate.sudo("cat /tmp/vagrant-ifcfg-#{interface} > #{network_scripts_dir}/ifcfg-#{interface}")
|
67
|
-
machine.communicate.sudo("rm -f /tmp/vagrant-ifcfg-#{interface}")
|
68
|
-
|
69
|
-
# Render and upload the network entry file to a deterministic
|
70
|
-
# temporary location.
|
71
|
-
entry = TemplateRenderer.render("guests/fedora/network_#{network[:type]}",
|
72
|
-
options: network)
|
73
|
-
|
74
|
-
temp = Tempfile.new("vagrant")
|
75
|
-
temp.binmode
|
76
|
-
temp.write(entry)
|
77
|
-
temp.close
|
78
|
-
|
79
|
-
machine.communicate.upload(temp.path, "/tmp/vagrant-network-entry_#{interface}")
|
80
|
-
end
|
81
|
-
|
82
|
-
# Bring down all the interfaces we're reconfiguring. By bringing down
|
83
|
-
# each specifically, we avoid reconfiguring p7p (the NAT interface) so
|
84
|
-
# SSH never dies.
|
85
|
-
interfaces.each do |interface|
|
86
|
-
retryable(on: Vagrant::Errors::VagrantError, tries: 3, sleep: 2) do
|
87
|
-
machine.communicate.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-#{interface}")
|
88
|
-
machine.communicate.sudo("/sbin/ifdown #{interface}", error_check: true)
|
89
|
-
machine.communicate.sudo("/sbin/ifup #{interface}")
|
90
|
-
end
|
91
|
-
|
92
|
-
machine.communicate.sudo("rm -f /tmp/vagrant-network-entry_#{interface}")
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module GuestFedora
|
3
|
-
module Cap
|
4
|
-
class Flavor
|
5
|
-
def self.flavor(machine)
|
6
|
-
# Read the version file
|
7
|
-
machine.communicate.sudo("grep VERSION_ID /etc/os-release") do |type, data|
|
8
|
-
version = data.split("=")[1].chomp.to_i if type == :stdout
|
9
|
-
end
|
10
|
-
|
11
|
-
# Detect various flavors we care about
|
12
|
-
if version >= 20
|
13
|
-
return :"fedora_#{version}"
|
14
|
-
else
|
15
|
-
return :fedora
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module GuestFedora
|
3
|
-
module Cap
|
4
|
-
class NetworkScriptsDir
|
5
|
-
# The path to the directory with the network configuration scripts.
|
6
|
-
# This is pulled out into its own directory since there are other
|
7
|
-
# operating systems (SUSE) which behave similarly but with a different
|
8
|
-
# path to the network scripts.
|
9
|
-
def self.network_scripts_dir(machine)
|
10
|
-
"/etc/sysconfig/network-scripts"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require "vagrant"
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module GuestFedora
|
5
|
-
class Guest < Vagrant.plugin("2", :guest)
|
6
|
-
def detect?(machine)
|
7
|
-
machine.communicate.test("grep 'Fedora release 1[6789]\\|Fedora release 2[0-9]' /etc/redhat-release")
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require "vagrant"
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module GuestFedora
|
5
|
-
class Plugin < Vagrant.plugin("2")
|
6
|
-
name "Fedora guest"
|
7
|
-
description "Fedora guest support."
|
8
|
-
|
9
|
-
guest("fedora", "redhat") do
|
10
|
-
require File.expand_path("../guest", __FILE__)
|
11
|
-
Guest
|
12
|
-
end
|
13
|
-
|
14
|
-
guest_capability("fedora", "change_host_name") do
|
15
|
-
require_relative "cap/change_host_name"
|
16
|
-
Cap::ChangeHostName
|
17
|
-
end
|
18
|
-
|
19
|
-
guest_capability("fedora", "configure_networks") do
|
20
|
-
require_relative "cap/configure_networks"
|
21
|
-
Cap::ConfigureNetworks
|
22
|
-
end
|
23
|
-
|
24
|
-
guest_capability("fedora", "network_scripts_dir") do
|
25
|
-
require_relative "cap/network_scripts_dir"
|
26
|
-
Cap::NetworkScriptsDir
|
27
|
-
end
|
28
|
-
|
29
|
-
guest_capability("fedora", "flavor") do
|
30
|
-
require_relative "cap/flavor"
|
31
|
-
Cap::Flavor
|
32
|
-
end
|
33
|
-
|
34
|
-
guest_capability("fedora", "nfs_client_install") do
|
35
|
-
require_relative "cap/nfs_client"
|
36
|
-
Cap::NFSClient
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|