Class: Vagrant::Systems::Redhat
- Defined in:
- lib/vagrant/systems/redhat.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #change_host_name(name) ⇒ Object
- #enable_host_only_network(net_options) ⇒ Object
-
#network_scripts_dir ⇒ Object
The path to the directory with the network configuration scripts.
- #prepare_host_only_network(net_options) ⇒ Object
Methods inherited from Linux
#distro_dispatch, #halt, #mount_folder, #mount_nfs, #mount_shared_folder
Methods inherited from Base
#distro_dispatch, #halt, #initialize, #mount_nfs, #mount_shared_folder
Constructor Details
This class inherits a constructor from Vagrant::Systems::Base
Instance Method Details
#change_host_name(name) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vagrant/systems/redhat.rb', line 36 def change_host_name(name) vm.ssh.execute do |ssh| # Only do this if the hostname is not already set if !ssh.test?("sudo hostname | grep '#{name}'") ssh.exec!("sudo sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network") ssh.exec!("sudo hostname #{name}") ssh.exec!("sudo sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts") end end end |
#enable_host_only_network(net_options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vagrant/systems/redhat.rb', line 15 def enable_host_only_network() entry = TemplateRenderer.render('network_entry_redhat', :net_options => ) vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry") vm.ssh.execute do |ssh| interface_up = ssh.test?("/sbin/ifconfig eth#{[:adapter]} | grep 'inet addr:'") ssh.exec!("sudo /sbin/ifdown eth#{[:adapter]} 2> /dev/null") if interface_up ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> #{network_scripts_dir}/ifcfg-eth#{[:adapter]}'") ssh.exec!("sudo /sbin/ifup eth#{[:adapter]}") end end |
#network_scripts_dir ⇒ Object
The path to the directory with the network configuration scripts. This is pulled out into its own directory since there are other operationg systems (SuSE) which behave similarly but with a different path to the network scripts.
32 33 34 |
# File 'lib/vagrant/systems/redhat.rb', line 32 def network_scripts_dir '/etc/sysconfig/network-scripts/' end |
#prepare_host_only_network(net_options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/vagrant/systems/redhat.rb', line 4 def prepare_host_only_network() # Remove any previous host only network additions to the # interface file. vm.ssh.execute do |ssh| # Clear out any previous entries ssh.exec!("sudo touch #{network_scripts_dir}/ifcfg-eth#{[:adapter]}") ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-eth#{[:adapter]} > /tmp/vagrant-ifcfg-eth#{[:adapter]}") ssh.exec!("sudo su -c 'cat /tmp/vagrant-ifcfg-eth#{[:adapter]} > #{network_scripts_dir}/ifcfg-eth#{[:adapter]}'") end end |