History
This is a fork of unmaintanied ruby gem [rubygems.org/gems/augeas] The gem is released as opennebula-augeas at [rubygems.org/gems/opennebula-augeas]
Ruby bindings for augeas
The class Augeas provides bindings to augeas [augeas.net] library.
Usage: Setting Data
Augeas::create do |aug|
aug.set("/files/etc/sysconfig/firstboot/RUN_FIRSTBOOT", "YES")
unless aug.save
raise IOError, "Failed to save changes"
end
end
Usage: Accessing Data
firstboot = Augeas::create {
|aug| aug.get("/files/etc/sysconfig/firstboot/RUN_FIRSTBOOT") }
Usage: Removing Data
Augeas::create do |aug|
aug.rm("/files/etc/sysconfig/firstboot/RUN_FIRSTBOOT")
unless aug.save
raise IOError, "Failed to save changes"
end
end
Usage: Minimal Setup with a Custom Root
By passing using the :no_modl_autoload
flag, no files are read on startup; that allows setting up a custom transform.
Augeas::create(:root => "/var/tmp/augeas-root",
:loadpath => "/usr/local/share/mylenses",
:no_modl_autoload => true) do |aug|
aug.transform(:lens => "Aliases.lns", :incl => "/etc/aliases")
aug.load
aug.get("/files/etc/aliases/*[name = 'postmaster']/value")
end
Build Dependencies
To build or install this gem manually, headers for libaugeas and libxml are needed. Additionally the pkg-config tool has to be installed.
Deprecation Warning
The Augeas API has been heavily rewritten in order to better support errors.
To use the new API, just use Augeas::create
instead of Augeas::open
. This is the documentation for the Augeas::create
method.
Create a new Augeas instance and return it.
Use :root
as the filesystem root. If :root
is nil
, use the value of the environment variable AUGEAS_ROOT
. If that doesn’t exist either, use “/”.
:loadpath
is a colon-spearated list of directories that modules should be searched in. This is in addition to the standard load path and the directories in AUGEAS_LENS_LIB
.
The following flags can be specified in a hash. They all default to false and can be enabled by setting them to true
:type_check
- typecheck lenses (since it can be very expensive it is not done by default)
:no_stdinc
- do not use the builtin load path for modules
:no_load
- do not load the tree during the initialization phase
:no_modl_autoload
- do not load the tree during the initialization phase
:enable_span
- track the span in the input nodes
:save_mode
can be one of :backup
, :newfile
, :noop
as explained below.
:noop - make save a no-op process, just record what would have changed
:backup - keep the original file with an .augsave extension
:newfile - save changes into a file with an .augnew extension and do
not overwrite the original file.
When a block is given, the Augeas instance is passed as the only argument into the block and closed when the block exits. With no block, the Augeas instance is returned.