From efd7b459dd999ef3177cb519d6beb809bb4e4d93 Mon Sep 17 00:00:00 2001 From: langdon Date: Thu, 30 Oct 2014 15:36:06 -0400 Subject: [PATCH 1/4] Add more capabilities for Fedora guests --- plugins/guests/fedora/cap/flavor.rb | 25 +++++++++++++++++++++++++ plugins/guests/fedora/cap/nfs_client.rb | 13 +++++++++++++ plugins/guests/fedora/plugin.rb | 10 ++++++++++ 3 files changed, 48 insertions(+) create mode 100644 plugins/guests/fedora/cap/flavor.rb create mode 100644 plugins/guests/fedora/cap/nfs_client.rb diff --git a/plugins/guests/fedora/cap/flavor.rb b/plugins/guests/fedora/cap/flavor.rb new file mode 100644 index 000000000..5e36fbcb5 --- /dev/null +++ b/plugins/guests/fedora/cap/flavor.rb @@ -0,0 +1,25 @@ +module VagrantPlugins + module GuestFedora + module Cap + class Flavor + def self.flavor(machine) + # Read the version file + output = "" + machine.communicate.sudo("grep VERSION_ID /etc/os-release") do |type, data| + output += data if type == :stdout + end + version = output.split("=")[1].chomp!.to_i + + # Detect various flavors we care about + if version >= 20 + return :"fedora_#{version}" + else if version >= 20 + return :"fedora_#{version}" + else + return :fedora + end + end + end + end + end +end diff --git a/plugins/guests/fedora/cap/nfs_client.rb b/plugins/guests/fedora/cap/nfs_client.rb new file mode 100644 index 000000000..4c8e6a546 --- /dev/null +++ b/plugins/guests/fedora/cap/nfs_client.rb @@ -0,0 +1,13 @@ +module VagrantPlugins + module GuestFedora + module Cap + class NFSClient + def self.nfs_client_install(machine) + machine.communicate.tap do |comm| + comm.sudo("yum -y install nfs-utils nfs-utils-lib") + end + end + end + end + end +end diff --git a/plugins/guests/fedora/plugin.rb b/plugins/guests/fedora/plugin.rb index 66b2d111f..78e376f96 100644 --- a/plugins/guests/fedora/plugin.rb +++ b/plugins/guests/fedora/plugin.rb @@ -25,6 +25,16 @@ module VagrantPlugins require_relative "cap/network_scripts_dir" Cap::NetworkScriptsDir end + + guest_capability("fedora", "flavor") do + require_relative "cap/flavor" + Cap::Flavor + end + + guest_capability("fedora", "nfs_client_install") do + require_relative "cap/nfs_client" + Cap::NFSClient + end end end end From 3fcd3d691a9effcd54f45c65ae433d62dc271171 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sun, 31 May 2015 18:56:13 -0700 Subject: [PATCH 2/4] Fix syntax errors and style on Fedora flavor cap --- plugins/guests/fedora/cap/flavor.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/guests/fedora/cap/flavor.rb b/plugins/guests/fedora/cap/flavor.rb index 5e36fbcb5..253352f5e 100644 --- a/plugins/guests/fedora/cap/flavor.rb +++ b/plugins/guests/fedora/cap/flavor.rb @@ -4,19 +4,18 @@ module VagrantPlugins class Flavor def self.flavor(machine) # Read the version file - output = "" + version = nil machine.communicate.sudo("grep VERSION_ID /etc/os-release") do |type, data| - output += data if type == :stdout + if type == :stdout + version = data.split("=")[1].chomp.to_i + end end - version = output.split("=")[1].chomp!.to_i # Detect various flavors we care about - if version >= 20 - return :"fedora_#{version}" - else if version >= 20 - return :"fedora_#{version}" - else + if version.nil? || version < 20 return :fedora + else + return "fedora_#{version}".to_sym end end end From 30dda774548679c1e24554b3fc1aa2bdb9e352da Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sun, 31 May 2015 18:56:49 -0700 Subject: [PATCH 3/4] Remove unneeded tap on nfs_client cap for Fedora --- plugins/guests/fedora/cap/nfs_client.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/guests/fedora/cap/nfs_client.rb b/plugins/guests/fedora/cap/nfs_client.rb index 4c8e6a546..58e084510 100644 --- a/plugins/guests/fedora/cap/nfs_client.rb +++ b/plugins/guests/fedora/cap/nfs_client.rb @@ -3,9 +3,7 @@ module VagrantPlugins module Cap class NFSClient def self.nfs_client_install(machine) - machine.communicate.tap do |comm| - comm.sudo("yum -y install nfs-utils nfs-utils-lib") - end + machine.communicate.sudo("yum -y install nfs-utils nfs-utils-lib") end end end From 19f3c10777166024f12042bd4a506e609fa0ab0e Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sun, 31 May 2015 18:58:38 -0700 Subject: [PATCH 4/4] Always return the version --- plugins/guests/fedora/cap/flavor.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/guests/fedora/cap/flavor.rb b/plugins/guests/fedora/cap/flavor.rb index 253352f5e..2a29f50b5 100644 --- a/plugins/guests/fedora/cap/flavor.rb +++ b/plugins/guests/fedora/cap/flavor.rb @@ -11,8 +11,7 @@ module VagrantPlugins end end - # Detect various flavors we care about - if version.nil? || version < 20 + if version.nil? return :fedora else return "fedora_#{version}".to_sym