logicminds / bmclib Goto Github PK
View Code? Open in Web Editor NEWPuppet type for controlling the bmc as well as other useful facts
License: GNU Lesser General Public License v2.1
Puppet type for controlling the bmc as well as other useful facts
License: GNU Lesser General Public License v2.1
When running this module on Puppet >= 4, it throws a warning:
Warning: Facter: timeout option is not supported for custom facts and will be ignored.
when running puppet resource bmc
I get the following error.
Error: Could not run: undefined method `collect' for #Puppet::Type::Bmc::ProviderIpmitool:0x7fdf9cd00d30
An ipmitool created user can't login over the webinterface, if the ipmi messaging isn't set to "on":
ipmitool channel setaccess 1 6 link=off ipmi=on callin=off
1 = channel
6 = userid
would be great to have this option / parameter
Board: Intel
OS: Debian 8.10
Packages:
The function new_user_id()
fails to create / assign an ID for the new users on my Intel board, because there is no user (probably default on other systems) Empty
.
user = users.find {|user| user[:name] =~ /Empty/i } || users.find {|user| !user[:enabled] }
ipmitool user list 1
ID Name Callin Link Auth IPMI Msg Channel Priv Limit
1 false false true ADMINISTRATOR
2 root false true true ADMINISTRATOR
4 test2 false false true ADMINISTRATOR
if I create the user Empty
over the UI manually, it fails with another error:
Error: /Stage[main]/Profile::Ipmi/Bmcuser[root2]/ensure: change from 'absent' to 'present' failed: Execution of '/usr/bin/ipmitool user priv 3 4 3' returned 1: Set Privilege Level command failed (user 3): Invalid data field in request
(but that's maybe related a wrong resource on my side)
if you lookup the manufacturer
instead of the core fact dmi['board']['manufacturer']
you'll get the system manufacturer instead of the board manufacturer.
See more here: https://github.com/logicminds/bmclib/blob/master/lib/puppet/provider/bmcuser/ipmitool.rb#L79
The bmc provider for ipmitool needs to query the ipmitool to verify that the channel is enabled.
Currently in the exists? method there is a bug where if the channel is disabled the channel could never be enabled unless one of the network properties changed.
We just need to figure out how to query ipmi to find out if the channel is enabled.
def channel_enabled?
# TODO implement how to look up this info
true
end
For the following manifest:
class { 'bmclib':}
bmc { 'ipmidevice':
ensure => present,
provider => 'ipmitool',
}
I'm getting the following error message:
Error: Could not prefetch bmc provider 'ipmitool': undefined method `find' for #<Puppet::Type::Bmc::ProviderIpmitool:0x7facad506750>
This is on EL6 using puppet 3.7
version: 0.1.1
$ find bmclib/ -type f -exec file {} \;|grep -v .svn|egrep -i 'apple|Macintosh'
bmclib/._manifests: AppleDouble encoded Macintosh file
bmclib/._metadata.json: AppleDouble encoded Macintosh file
bmclib/._spec: AppleDouble encoded Macintosh file
bmclib/._LICENSE.txt: AppleDouble encoded Macintosh file
bmclib/tests/._ipmievd.pp: AppleDouble encoded Macintosh file
bmclib/tests/._example.pp: AppleDouble encoded Macintosh file
bmclib/tests/._init.pp: AppleDouble encoded Macintosh file
bmclib/._Gemfile.lock: AppleDouble encoded Macintosh file
bmclib/._Gemfile: AppleDouble encoded Macintosh file
bmclib/._DEVELOP.md: AppleDouble encoded Macintosh file
bmclib/._Rakefile: AppleDouble encoded Macintosh file
bmclib/._tests: AppleDouble encoded Macintosh file
bmclib/._EXAMPLES.md: AppleDouble encoded Macintosh file
bmclib/._README.md: AppleDouble encoded Macintosh file
bmclib/._Modulefile: AppleDouble encoded Macintosh file
bmclib/spec/._hosts: AppleDouble encoded Macintosh file
bmclib/spec/unit/._puppet: AppleDouble encoded Macintosh file
bmclib/spec/unit/puppet/._provider: AppleDouble encoded Macintosh file
bmclib/spec/unit/puppet/provider/bmc/._ipmitool_spec.rb: AppleDouble encoded Macintosh file
bmclib/spec/unit/puppet/provider/._bmcuser: AppleDouble encoded Macintosh file
bmclib/spec/unit/puppet/provider/._bmc: AppleDouble encoded Macintosh file
bmclib/spec/unit/puppet/provider/bmcuser/._ipmitool_spec.rb: AppleDouble encoded Macintosh file
bmclib/spec/unit/puppet/type/._bmc_spec.rb: AppleDouble encoded Macintosh file
bmclib/spec/unit/puppet/type/._bmcuser_spec.rb: AppleDouble encoded Macintosh file
bmclib/spec/unit/puppet/._type: AppleDouble encoded Macintosh file
bmclib/spec/unit/._facter: AppleDouble encoded Macintosh file
bmclib/spec/unit/facter/._bmc_device_present_spec.rb: AppleDouble encoded Macintosh file
bmclib/spec/._classes: AppleDouble encoded Macintosh file
bmclib/spec/fixtures/._manifests: AppleDouble encoded Macintosh file
bmclib/spec/fixtures/._modules: AppleDouble encoded Macintosh file
bmclib/spec/._spec.opts: AppleDouble encoded Macintosh file
bmclib/spec/classes/._bmclib_init_spec.rb: AppleDouble encoded Macintosh file
bmclib/spec/classes/._bmc_example_spec.rb: AppleDouble encoded Macintosh file
bmclib/spec/classes/._bmclib_ipmievd_spec.rb: AppleDouble encoded Macintosh file
bmclib/spec/classes/._bmclib_spec.rb: AppleDouble encoded Macintosh file
bmclib/spec/classes/._bmcuser_example_spec.rb: AppleDouble encoded Macintosh file
bmclib/spec/._defines: AppleDouble encoded Macintosh file
bmclib/spec/._fixtures: AppleDouble encoded Macintosh file
bmclib/spec/._unit: AppleDouble encoded Macintosh file
bmclib/spec/._spec_helper.rb: AppleDouble encoded Macintosh file
bmclib/spec/._functions: AppleDouble encoded Macintosh file
bmclib/._lib: AppleDouble encoded Macintosh file
bmclib/lib/._puppet: AppleDouble encoded Macintosh file
bmclib/lib/puppet/._provider: AppleDouble encoded Macintosh file
bmclib/lib/puppet/provider/bmc/._ipmitool.rb: AppleDouble encoded Macintosh file
bmclib/lib/puppet/provider/._bmcuser: AppleDouble encoded Macintosh file
bmclib/lib/puppet/provider/._bmc: AppleDouble encoded Macintosh file
bmclib/lib/puppet/provider/bmcuser/._ipmitool.rb: AppleDouble encoded Macintosh file
bmclib/lib/puppet/type/._bmcuser.rb: AppleDouble encoded Macintosh file
bmclib/lib/puppet/type/._bmc.rb: AppleDouble encoded Macintosh file
bmclib/lib/puppet/._type: AppleDouble encoded Macintosh file
bmclib/lib/._facter: AppleDouble encoded Macintosh file
bmclib/lib/facter/._bmc_device_present.rb: AppleDouble encoded Macintosh file
bmclib/lib/facter/._bmc.rb: AppleDouble encoded Macintosh file
bmclib/manifests/._ipmievd.pp: AppleDouble encoded Macintosh file
bmclib/manifests/._init.pp: AppleDouble encoded Macintosh file
So I'm getting around wanting to use this on real hardware with @fhats, on lots of different distros, puppet versions, etc.
But I'm finding that.. using the provider directly doesn't seem to work.
Like this part of self.instances in bmcuser:
userdata = ipmitoolcmd(["user list 1"])
Should be:
userdata = ipmitoolcmd(['user', 'list', '1'])
I must be the first person to actually run this, or maybe it worked on some other version of puppet or ruby that I don't have? (I've got a bunch)
How would you feel about giving me contributor access? Now that I need to run this at my own work, I'll be iterating rapidly, writing tests, triaging PR's etc?
Even if not, I would like to see more master development, and let releases to the forge be the stable part. When master doesn't change much, and bug fixes get dispersed across other people's forks, things get stale, and the barrier to big PRs gets larger.
I guess what I'm saying is: I don't want to maintain my own separate fork, build up a lot of changes quickly (I intend to get this working this week), and do a Massive PR like @razorsedge. :(
In the "About" section of the README.md, it states that "The BMClib is a puppet library that provides bmc related facts as well as a bmc type and bmcuser type. Currently the only provider available is ipmitool. However, in the future additional provider types will include freeipmi, hponcfg, and other oem related tools." (emphasis mine)
I see that there are classes to install ipmitool, which confuses me. I think that ipmitool management should be via a separate module (like perhaps jhoblitt/ipmi). This would fit in nicely with using logicminds/hpilo as a future provider.
Am I incorrect in how I have interpreted the intent of this module? Does it make sense to have an empty Class['bmclib']
and reject my PR #3 to add support for Service['ipmievd']
?
The bmcuser provider shows the password when a resource is declared. We need to implement the to_s function to override the password and hide the value.
Could not retrieve fact='bmc_mac', resolution='<anonymous>': undefined method `empty?' for nil:NilClass
Could not retrieve fact='bmc_subnet', resolution='<anonymous>': undefined method `empty?' for nil:NilClass
Could not retrieve fact='bmc_ip', resolution='<anonymous>': undefined method `empty?' for nil:NilClass
Could not retrieve fact='bmc_gateway', resolution='<anonymous>': undefined method `empty?' for nil:NilClass
Would be great to improve the ipmitool provider with the watchdog command.
this helps to reboot the system, after x seconds, if the machine freezed.
ipmitool mc watchdog on
Hi,
Since this is library like source code it would be better to have the license code to LGPL.
If all are in agreement I will switch to this to LGPL.
For those who have contributed, please respond to so that we all agree to this license change. (yes/no) is all that is needed.
@razorsedge
@solarkennedy
@Codeacious
@fhats
@bobtfish
Thanks everyone for the contributions thus far.
Now that we have a fact to determine if the bmc device is present we should be able to use this fact in our providers.
example:https://github.com/logicminds/bmclib/blob/master/lib/puppet/provider/bmc/ipmitool.rb#L9
bmclib is extremely helpful, thank you!
FYI, I modified the code to combine all the separate facts into one structured fact, called bmc,
Facter.add(:bmc) do
setcode do
bmc_hash = {}
bmc_hash["device_present"] = device_present?
bmc_hash["tools_present"] = tools_present?
if device_present? && tools_present?
bmc_hash["ip"] = ip
bmc_hash["mac"] = mac
bmc_hash["netmask"] = subnet
bmc_hash["gateway"] = gateway
bmc_hash["vlan"] = vlanid
bmc_hash["assignment"] = "unknown"
if dhcp?
bmc_hash["assignment"] = "dhcp"
end
if static?
bmc_hash["assignment"] = "static"
end
end
bmc_hash
end
end
def lanconfig
@lanconfig ||= parse_laninfo
end
def parse_laninfo
if ipmitool.empty? or ipmitool.nil?
return {}
end
channel_lookup = {
'Dell Inc.' => 1,
'FUJITSU' => 2,
'FUJITSU SIEMENS' => 2,
'HP' => 2,
'Intel Corporation' => 3,
}
channel = channel_lookup.fetch(Facter.value(:manufacturer), 1)
landata = Facter::Core::Execution.exec("#{ipmitool} lan print #{channel} 2>/dev/null") || ''
laninfo = {}
landata.lines.each do |line|
# clean up the data from spaces
item = line.split(':', 2)
key = item.first.strip.downcase.gsub(' ','_')
value = item.last.strip
laninfo[key] = value
end
laninfo
end
def ipmitool
unless @ipmitool
timeout = Facter::Core::Execution.which('timeout')
ipmitool_cmd = Facter::Core::Execution.which('ipmitool')
if ipmitool_cmd and timeout
@ipmitool = "#{timeout} 2 #{ipmitool_cmd}"
elsif ipmitool_cmd
@ipmitool = ipmitool_cmd
else
@ipmitool = nil
end
end
@ipmitool
end
def ip
lanconfig["ip_address"]
end
def mac
lanconfig["mac_address"]
end
def subnet
lanconfig["subnet_mask"]
end
def gateway
lanconfig["default_gateway_ip"]
end
def vlanid
lanconfig["802.1q_vlan_id"].downcase!
end
def dhcp?
lanconfig["ip_address_source"].match(/dhcp/i) != nil
end
def static?
lanconfig["ip_address_source"].match(/static/i) != nil
end
def ipsrc
lanconfig["ip_address_source"].downcase!
end
def device_present?
File.exists?('/dev/ipmi0') || File.exists?('/dev/ipmi/0') || File.exists?('/dev/ipmidev/0')
end
def tools_present?
!Facter::Core::Execution.which('ipmitool').nil?
end
I do not know much about Ruby, so I won't be surprised if there is a better way to do this....
I'm getting the following error when using the bmcuser type:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: No set of title patterns matched the title "ipmi_root".
I don't understand why because this type does not appear to use composite namevar.
this is how I use it:
bmcuser{'ipmi_root':
ensure => enabled,
provider => 'ipmitool',
privlevel => 'admin',
username => 'root',
userpass => $ipmi_root_user_pass,
force => true,
require => Class['bmclib']
}
I need more eyeballs on this code and it would be better if we handed this over to voxpupuli so it can be maintained easier.
I would recommend to use getter/setters in the provider. At least for setting the password.
Command for checking / get the password value:
ipmitool user test <userid> 20 <password>
this returns true / false.
fterwards we could set the password only if it's different with the setter method.
Just like the facts we will also need to implement a channel mapper for various types of bmc devices.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.