Created
August 11, 2017 11:24
-
-
Save scopenco/3d5786c2209b0f693b1fcdd45e463ebf to your computer and use it in GitHub Desktop.
Revisions
-
scopenco created this gist
Aug 11, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ # # Author:: Andrei Skopenko (<andrei@skopenko.net>) # # Copyright 2017, Andrei Skopenko # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Ohai.plugin(:Vboxipaddress) do provides "ipaddress" depends "ipaddress", "network/interfaces", "virtualization/system", "etc/passwd" collect_data(:default) do # linux if virtualization["system"] == "vbox" && etc["passwd"].any? { |k,v| k == "vagrant"} interface_key = network["interfaces"].keys.last network["interfaces"][interface_key]['addresses'].each do |ip, params| ipaddress ip if params['family'] == ('inet') end # windows elsif kernel['cs_info'] && kernel['cs_info']['model'] == 'VirtualBox' ipaddress network["interfaces"][interface_key]['configuration']['ip_address'][0] end end end