guests/fedora: Move as a child of redhat
Fedora should have been a child of redhat for awhile now...
This commit is contained in:
parent
336cb3319c
commit
084d62b5a6
|
@ -1,29 +0,0 @@
|
|||
module VagrantPlugins
|
||||
module GuestFedora
|
||||
module Cap
|
||||
class ChangeHostName
|
||||
def self.change_host_name(machine, name)
|
||||
comm = machine.communicate
|
||||
|
||||
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||
basename = name.split(".", 2)[0]
|
||||
comm.sudo <<-EOH.gsub(/^ {14}/, "")
|
||||
echo '#{name}' > /etc/hostname
|
||||
hostname -F /etc/hostname
|
||||
hostnamectl set-hostname --static '#{name}'
|
||||
hostnamectl set-hostname --transient '#{name}'
|
||||
|
||||
# Remove comments and blank lines from /etc/hosts
|
||||
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
|
||||
|
||||
# Prepend ourselves to /etc/hosts
|
||||
grep -w '#{name}' /etc/hosts || {
|
||||
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
|
||||
}
|
||||
EOH
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,60 +0,0 @@
|
|||
require "tempfile"
|
||||
|
||||
require_relative "../../../../lib/vagrant/util/retryable"
|
||||
require_relative "../../../../lib/vagrant/util/template_renderer"
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestFedora
|
||||
module Cap
|
||||
class ConfigureNetworks
|
||||
extend Vagrant::Util::Retryable
|
||||
include Vagrant::Util
|
||||
|
||||
def self.configure_networks(machine, networks)
|
||||
comm = machine.communicate
|
||||
|
||||
network_scripts_dir = machine.guest.capability(:network_scripts_dir)
|
||||
interfaces = machine.guest.capability(:network_interface)
|
||||
|
||||
commands = []
|
||||
|
||||
networks.each.with_index do |network, i|
|
||||
network[:device] = interfaces[network[:interface]]
|
||||
|
||||
# Render a new configuration
|
||||
entry = TemplateRenderer.render("guests/fedora/network_#{network[:type]}",
|
||||
options: network,
|
||||
)
|
||||
|
||||
# Upload the new configuration
|
||||
remote_path = "/tmp/vagrant-network-entry-#{network[:device]}-#{Time.now.to_i}-#{i}"
|
||||
Tempfile.open("vagrant-fedora-configure-networks") do |f|
|
||||
f.binmode
|
||||
f.write(entry)
|
||||
f.fsync
|
||||
f.close
|
||||
machine.communicate.upload(f.path, remote_path)
|
||||
end
|
||||
|
||||
# Add the new interface and bring it back up
|
||||
final_path = "#{network_scripts_dir}/ifcfg-#{network[:device]}"
|
||||
commands << <<-EOH.gsub(/^ {14}/, '')
|
||||
# Down the interface before munging the config file. This might
|
||||
# fail if the interface is not actually set up yet so ignore
|
||||
# errors.
|
||||
/sbin/ifdown '#{network[:device]}' || true
|
||||
|
||||
# Move new config into place
|
||||
mv '#{remote_path}' '#{final_path}'
|
||||
|
||||
# Bring the interface up
|
||||
ARPCHECK=no /sbin/ifup '#{network[:device]}'
|
||||
EOH
|
||||
end
|
||||
|
||||
comm.sudo(commands.join("\n"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -14,7 +14,7 @@ module VagrantPlugins
|
|||
if version.nil?
|
||||
return :fedora
|
||||
else
|
||||
return "fedora_#{version}".to_sym
|
||||
return :"fedora_#{version}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
module VagrantPlugins
|
||||
module GuestFedora
|
||||
module Cap
|
||||
class NetworkScriptsDir
|
||||
# The path to the directory with the network configuration scripts.
|
||||
# This is pulled out into its own directory since there are other
|
||||
# operating systems (SUSE) which behave similarly but with a different
|
||||
# path to the network scripts.
|
||||
def self.network_scripts_dir(machine)
|
||||
"/etc/sysconfig/network-scripts"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,21 +11,6 @@ module VagrantPlugins
|
|||
Guest
|
||||
end
|
||||
|
||||
guest_capability(:fedora, :change_host_name) do
|
||||
require_relative "cap/change_host_name"
|
||||
Cap::ChangeHostName
|
||||
end
|
||||
|
||||
guest_capability(:fedora, :configure_networks) do
|
||||
require_relative "cap/configure_networks"
|
||||
Cap::ConfigureNetworks
|
||||
end
|
||||
|
||||
guest_capability(:fedora, :network_scripts_dir) do
|
||||
require_relative "cap/network_scripts_dir"
|
||||
Cap::NetworkScriptsDir
|
||||
end
|
||||
|
||||
guest_capability(:fedora, :flavor) do
|
||||
require_relative "cap/flavor"
|
||||
Cap::Flavor
|
||||
|
|
|
@ -17,9 +17,10 @@ module VagrantPlugins
|
|||
# Set the hostname - use hostnamectl if available
|
||||
echo '#{name}' > /etc/hostname
|
||||
if command -v hostnamectl; then
|
||||
hostnamectl set-hostname '#{name}'
|
||||
hostnamectl set-hostname --static '#{name}'
|
||||
hostnamectl set-hostname --transient '#{name}'
|
||||
else
|
||||
hostname '#{name}'
|
||||
hostname -F /etc/hostname
|
||||
fi
|
||||
|
||||
# Remove comments and blank lines from /etc/hosts
|
||||
|
|
|
@ -1,33 +1,14 @@
|
|||
require "tempfile"
|
||||
|
||||
require_relative "../../../../lib/vagrant/util/retryable"
|
||||
require_relative "../../../../lib/vagrant/util/template_renderer"
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestRedHat
|
||||
module Cap
|
||||
class ConfigureNetworks
|
||||
extend Vagrant::Util::Retryable
|
||||
include Vagrant::Util
|
||||
|
||||
def self.configure_networks(machine, networks)
|
||||
case machine.guest.capability(:flavor)
|
||||
when :rhel_7
|
||||
configure_networks_rhel7(machine, networks)
|
||||
else
|
||||
configure_networks_default(machine, networks)
|
||||
end
|
||||
end
|
||||
|
||||
def self.configure_networks_rhel7(machine, networks)
|
||||
# This is kind of jank but the configure networks is the same as
|
||||
# Fedora at this point.
|
||||
require_relative "../../fedora/cap/configure_networks"
|
||||
::VagrantPlugins::GuestFedora::Cap::ConfigureNetworks
|
||||
.configure_networks(machine, networks)
|
||||
end
|
||||
|
||||
def self.configure_networks_default(machine, networks)
|
||||
comm = machine.communicate
|
||||
|
||||
network_scripts_dir = machine.guest.capability(:network_scripts_dir)
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#VAGRANT-BEGIN
|
||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||
BOOTPROTO=dhcp
|
||||
ONBOOT=yes
|
||||
DEVICE=<%= options[:device] %>
|
||||
#VAGRANT-END
|
|
@ -1,16 +0,0 @@
|
|||
#VAGRANT-BEGIN
|
||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||
NM_CONTROLLED=no
|
||||
BOOTPROTO=none
|
||||
ONBOOT=yes
|
||||
IPADDR=<%= options[:ip] %>
|
||||
NETMASK=<%= options[:netmask] %>
|
||||
DEVICE=<%= options[:device] %>
|
||||
<% if options[:gateway] %>
|
||||
GATEWAY=<%= options[:gateway] %>
|
||||
<% end %>
|
||||
<% if options[:mac_address] %>
|
||||
HWADDR=<%= options[:mac_address] %>
|
||||
<% end %>
|
||||
PEERDNS=no
|
||||
#VAGRANT-END
|
|
@ -1,9 +0,0 @@
|
|||
#VAGRANT-BEGIN
|
||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||
NM_CONTROLLED=no
|
||||
BOOTPROTO=static
|
||||
ONBOOT=yes
|
||||
IPV6INIT=yes
|
||||
IPV6ADDR=<%= options[:ip] %>
|
||||
DEVICE=<%= options[:device] %>
|
||||
#VAGRANT-END
|
|
@ -9,5 +9,8 @@ DEVICE=<%= options[:device] %>
|
|||
<% if options[:gateway] %>
|
||||
GATEWAY=<%= options[:gateway] %>
|
||||
<% end %>
|
||||
<% if options[:mac_address] %>
|
||||
HWADDR=<%= options[:mac_address] %>
|
||||
<% end %>
|
||||
PEERDNS=no
|
||||
#VAGRANT-END
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#VAGRANT-BEGIN
|
||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||
auto <%= options[:device] %>
|
||||
iface <%= options[:device] %> inet6 static
|
||||
address <%= options[:ip] %>
|
||||
netmask <%= options[:netmask] %>
|
||||
<% if options[:gateway] %>
|
||||
gateway <%= options[:gateway] %>
|
||||
NM_CONTROLLED=no
|
||||
BOOTPROTO=static
|
||||
ONBOOT=yes
|
||||
DEVICE=<%= options[:device] %>
|
||||
IPV6INIT=yes
|
||||
IPV6ADDR=<%= options[:ip] %>/<%= options[:netmask] %>
|
||||
<% if options[:gateway] -%>
|
||||
IPV6_DEFAULTGW=<%= options[:gateway] %>
|
||||
<% end %>
|
||||
#VAGRANT-END
|
||||
|
|
Loading…
Reference in New Issue