Re: Func-inventory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael DeHaan wrote:
Hi folks,

It's time to showcase another neat app written using func. It's "func-inventory". Func-inventory is just 153 lines of Python, and I wrote the initial version in about half of a day. I'm not saying that to brag, I'm saying that because this means func is *REALLY* simple to build new applications on. What does Func-inventory do? It's an app that allows for inventorying (and inventory tracking) of anything. Anything that has a func module can be stored, and the inventory is kept over time in version control, to see what items have been added or changed.

We're going to ship func-inventory in the func RPM, so it will be part of the standard toolset.

How about an example?

# func-inventory --verbose

Simple enough? By default, running func-inventory updates everything that is known about all things func (on all minions) into a tree in /var/lib/func/inventory.

Type "tree /var/lib/func/inventory" to see what I'm talking about. Bonus feature: Unless you specify "--no-git", this directory is automagically managed with git version control, so you can view changes using tools like "git log", "gitk" (a GUI app), or (if you set it up) GitWeb. For those unfamiliar with git, git is a powerful distributed version control system used by the Linux kernel. It supports writing arbitrary triggers, so you could have git email you reports of when your configuration changes. We may include some of those scripts with func, or we may eventually come up with some more advanced (module-specific) triggers for func to use to report on inventory changes.

The app also has lots of other shiny options, some of which are shown below. You can read the "func-inventory" manpage for more details.

func-inventory --tree /opt/put/my/files/here --server-spec "mailservers*.example.org" --modules hardware,packages --verbose

This would dump the inventory data of only your mailservers (and only from two func modules, hardware and packages) to the directory specified above.

One note ... Currently by default, we index all modules that have an info() method. Since some modules change state too often to be part of inventory, we'll most likely have an inventory() method in the future, which will frequently be aliased (but not always) to what info() returns now. You can also override the methods and modules
being inventoried on the command line.

I've only lightly tested the option handling so far (testing/upgrades to this are on the list for this week), though if anyone would like to play with it, just install the latest func, install git-core on the minion, and have at it. Thanks!

--Michael

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

I've added some new features to make this more useful recently ... namely "package inventory" (what RPM's are installed, and what are the relevant version numbers, releases, etc, about them) and "service inventory", which tells what services are enabled and also which are running/not. Inventory now looks for an "inventory()" method by default, so it won't attempt to take inventory of your running PID's or anything like that.

These work with regular func commands as well as func-inventory. Details on https://hosted.fedoraproject.org/projects/func/

Also recently alikins added support for func outputting in multiple formats (XMLRPC, JSON, pretty print, and raw) which are all now selectable on the command line for func.
The default is now the pretty printer.

One person on IRC suggested adding a module to remotely add a list of files to track (probably using checksums + stat data / permissions) which could be very useful for func inventory.

It might work very simply like:

# build up the list of things to track on various systems
func "*" call filetracker track /etc/foo.conf
func "web*.example.org" call filetracker track /etc/bar.conf

Then func-inventory could show you when those files changed, all part of the normal git-integrated tracking report. This seems really cool to me, especially because it would be really easy to share all of the existing inventory infrastructure and the diffs for any given system would show up with the other changed inventory
items (like hardware or services).

If anyone else has other ideas for what would be neat to track with func-inventory, please share here or on IRC. (Patches for new modules are also
always welcome too!)

FYI -- as someone pointed out, for the hardware stuff to work, you need to install smolt. Or alternatively you could pass in "hal_info" for the method name to inventory and just use the hal part, sans smolt. Baiscally this can be done just by executing func-inventory just one more time, like this:

func-inventory
func-inventory --modules hardware --methods hal_inventory

They will combine in the same tree.

--Michael


[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux