Class: Facter::Operatingsystem::Linux
- Defined in:
- lib/facter/operatingsystem/linux.rb
Direct Known Subclasses
Instance Method Summary collapse
- #collect_lsb_information ⇒ Object
- #get_lsb_facts_hash ⇒ Object
- #get_lsbdistcodename ⇒ Object
- #get_lsbdistdescription ⇒ Object
- #get_lsbdistid ⇒ Object
- #get_lsbdistrelease ⇒ Object
- #get_lsbmajdistrelease ⇒ Object
- #get_lsbminordistrelease ⇒ Object
- #get_lsbrelease ⇒ Object
- #get_operatingsystem ⇒ Object
- #get_operatingsystemmajorrelease ⇒ Object
- #get_operatingsystemminorrelease ⇒ Object
- #get_operatingsystemrelease ⇒ Object
- #get_osfamily ⇒ Object
- #has_lsb? ⇒ Boolean
Methods inherited from Base
#get_operatingsystemrelease_hash
Instance Method Details
#collect_lsb_information ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/facter/operatingsystem/linux.rb', line 221 def collect_lsb_information @lsb_data ||= Facter::Core::Execution.exec("lsb_release -cidvr 2>/dev/null") @data_hash = {} if @lsb_data && @data_hash.empty? @lsb_data.split("\n").each do |element| lsbvar, value = element.split("\t") lsbvar.gsub!(":", "") @data_hash["#{lsbvar}"] = value end end @data_hash unless @data_hash.empty? end |
#get_lsb_facts_hash ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/facter/operatingsystem/linux.rb', line 189 def get_lsb_facts_hash lsb_hash = {} if lsbdistcodename = get_lsbdistcodename lsb_hash["distcodename"] = lsbdistcodename end if lsbdistid = get_lsbdistid lsb_hash["distid"] = lsbdistid end if lsbdistdescription = get_lsbdistdescription lsb_hash["distdescription"] = lsbdistdescription end if lsbrelease = get_lsbrelease lsb_hash["release"] = lsbrelease end if lsbdistrelease = get_lsbdistrelease lsb_hash["distrelease"] = lsbdistrelease end if lsbmajdistrelease = get_lsbmajdistrelease lsb_hash["majdistrelease"] = lsbmajdistrelease end if lsbminordistrelease = get_lsbminordistrelease lsb_hash["minordistrelease"] = lsbminordistrelease end lsb_hash end |
#get_lsbdistcodename ⇒ Object
119 120 121 122 123 |
# File 'lib/facter/operatingsystem/linux.rb', line 119 def get_lsbdistcodename if (lsb_data = collect_lsb_information) lsb_data["Codename"] end end |
#get_lsbdistdescription ⇒ Object
131 132 133 134 135 |
# File 'lib/facter/operatingsystem/linux.rb', line 131 def get_lsbdistdescription if (lsb_data = collect_lsb_information) lsb_data["Description"].sub(/^"(.*)"$/,'\1') end end |
#get_lsbdistid ⇒ Object
125 126 127 128 129 |
# File 'lib/facter/operatingsystem/linux.rb', line 125 def get_lsbdistid if (lsb_data = collect_lsb_information) lsb_data["Distributor ID"] end end |
#get_lsbdistrelease ⇒ Object
143 144 145 146 147 |
# File 'lib/facter/operatingsystem/linux.rb', line 143 def get_lsbdistrelease if (lsb_data = collect_lsb_information) lsb_data["Release"] end end |
#get_lsbmajdistrelease ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/facter/operatingsystem/linux.rb', line 149 def get_lsbmajdistrelease lsbdistrelease = get_lsbdistrelease if == "Ubuntu" if (lsbreleasemajor = lsbdistrelease.split(".")) if lsbreleasemajor.length >= 2 result = "#{lsbreleasemajor[0]}.#{lsbreleasemajor[1]}" else result = lsbreleasemajor end end else if /(\d*)\./i =~ lsbdistrelease result = $1 else result = lsbdistrelease end end result end |
#get_lsbminordistrelease ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/facter/operatingsystem/linux.rb', line 169 def get_lsbminordistrelease lsbdistrelease = get_lsbdistrelease if == "Ubuntu" mdata = /(\d+).(\d+).(\d+)/i.match(lsbdistrelease) if mdata == nil result = nil else result = mdata[3] end else mdata = /(\d+).(\d+)/i.match(lsbdistrelease) if mdata == nil result = nil else result = mdata[2] end end result end |
#get_lsbrelease ⇒ Object
137 138 139 140 141 |
# File 'lib/facter/operatingsystem/linux.rb', line 137 def get_lsbrelease if (lsb_data = collect_lsb_information) lsb_data["LSB Version"] end end |
#get_operatingsystem ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/facter/operatingsystem/linux.rb', line 8 def if Facter.value(:kernel) == "GNU/kFreeBSD" "GNU/kFreeBSD" elsif lsbdistid = get_lsbdistid if lsbdistid == "Ubuntu" @operatingsystem ||= "Ubuntu" elsif lsbdistid == "LinuxMint" @operatingsystem ||= "LinuxMint" else @operatingsystem ||= end else @operatingsystem ||= end end |
#get_operatingsystemmajorrelease ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/facter/operatingsystem/linux.rb', line 79 def if = if == "Ubuntu" if (releasemajor = .split(".")) if releasemajor.length >= 2 "#{releasemajor[0]}.#{releasemajor[1]}" else releasemajor[0] end end else if (releasemajor = .split(".")[0]) releasemajor end end end end |
#get_operatingsystemminorrelease ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/facter/operatingsystem/linux.rb', line 97 def if = if == "Ubuntu" if (releaseminor = .split(".")[2]) releaseminor end else if (releaseminor = .split(".")[1]) if releaseminor.include? "-" releaseminor.split("-")[0] else releaseminor end end end end end |
#get_operatingsystemrelease ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/facter/operatingsystem/linux.rb', line 43 def case when "Alpine" get_alpine_release_with_release_file when "Amazon" get_amazon_release_with_lsb when "AristaEOS" get_arista_release_with_release_file when "BlueWhite64" get_bluewhite_release_with_release_file when "CentOS", "RedHat", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "XenServer", "Fedora", "MeeGo", "OracleLinux", "OEL", "oel", "OVS", "ovs" get_redhatish_release_with_release_file when "Debian" get_debian_release_with_release_file when "LinuxMint" get_linux_mint_release_with_release_file when "Mageia" get_mageia_release_with_release_file when "OpenWrt" get_openwrt_release_with_release_file when "Slackware" get_slackware_release_with_release_file when "Slamd64" get_slamd64_release_with_release_file when "SLES", "SLED", "OpenSuSE" get_suse_release_with_release_file when "Ubuntu" get_ubuntu_release_with_release_file when "VMwareESX" get_vmwareESX_release_with_release_file else Facter.value(:kernelrelease) end end |
#get_osfamily ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/facter/operatingsystem/linux.rb', line 24 def get_osfamily case when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "OracleLinux", "OVS", "OEL", "Amazon", "XenServer" "RedHat" when "LinuxMint", "Ubuntu", "Debian" "Debian" when "SLES", "SLED", "OpenSuSE", "SuSE" "Suse" when "Gentoo" "Gentoo" when "Archlinux", "Manjarolinux" "Archlinux" when "Mageia", "Mandriva", "Mandrake" "Mandrake" else Facter.value("kernel") end end |
#has_lsb? ⇒ Boolean
115 116 117 |
# File 'lib/facter/operatingsystem/linux.rb', line 115 def has_lsb? true end |