Using augeas
This wraps the augeas product for simple edits of structured files.
Simple usage
f=MintPress::Resources::Augeas.new(name: "/tmp/mintpress-resources-test-file-3",
lens: "Shellvars.lns",
values: {"HOSTNAME" => "duck.duckgoose.com"},
no_autoload: true,
host: host).create
f=MintPress::Resources::Augeas.new(name: "/tmp/mintpress-resources-test-file-3.properites",
lens: "Properties.lns",
values: {"llama.duck" => "cow"},
no_autoload: true,
host: host).create
More complex usage
For HTTPD: github.com/hercules-team/augeas/blob/master/lenses/httpd.aug
You’ll notice it has a directive/value type of structure, rather than pure hash structure We use the ‘container’
# Create a simple HTTP conf from scratch
require 'mintpress-resources'
# Add a listen
f = MintPress::Resources::Augeas.new(name: "/tmp/jj.conf",
lens: "Httpd.lns",
container: "directive",
values: { "Listen" => 80, "Listen2" => 90 },
no_autoload: true,
host: MintPress::Infrastructure::LocalHost.new).create
# Ensure we have a vhost container to put it in
f = MintPress::Resources::Augeas.new(name: "/tmp/jj.conf",
lens: "Httpd.lns",
values: { "VirtualHost/arg" => "127.0.0.1:90" },
no_autoload: true,
host: MintPress::Infrastructure::LocalHost.new).create
# This is pathed under, so lets use the virtual_path directive of augeas to do this
f = MintPress::Resources::Augeas.new(name: "/tmp/jj.conf",
lens: "Httpd.lns",
container: "directive",
virtual_path: "/VirtualHost",
values: { "DocumentRoot" => "/var/tmp/www" },
no_autoload: true,
host: MintPress::Infrastructure::LocalHost.new).create
Iterators for items such as hosts files
Document augeas_iterator