Any equivalent of "puppet augeas" in Chef?

Hi there,

I need to do in-place file editing of config files using Chef. For now, i could
see that we can append data to the config files using the “bash” resource. But,
i need to change specific variables in config files using Chef.

I could see that there’s a handy tool called augeas in puppet that clearly
performs the above requirement. But, i couldn’t come up with anything in Chef.

So, is there any way this could be done in Chef?

Thanks in advance.

sivajimsingh@gmail.com writes:

Hi there,

I need to do in-place file editing of config files using Chef. For now, i could
see that we can append data to the config files using the "bash" resource. But,
i need to change specific variables in config files using Chef.

I could see that there's a handy tool called augeas in puppet that clearly
performs the above requirement. But, i couldn't come up with anything in Chef.

So, is there any way this could be done in Chef?

You can use the FileEdit class in a ruby block:

ruby_block "Update vars" do
block do
rc = Chef::Util::FileEdit.new(some_path)
rc.search_file_replace(...)
rc.write_file
end
action :create
end

/Jeppe

Recently discussed on this list:
http://community.opscode.com/cookbooks/line

2013/9/16 Jeppe Nejsum Madsen jeppe@ingolfs.dk

sivajimsingh@gmail.com writes:

Hi there,

I need to do in-place file editing of config files using Chef. For now,
i could
see that we can append data to the config files using the "bash"
resource. But,
i need to change specific variables in config files using Chef.

I could see that there's a handy tool called augeas in puppet that
clearly
performs the above requirement. But, i couldn't come up with anything in
Chef.

So, is there any way this could be done in Chef?

You can use the FileEdit class in a ruby block:

ruby_block "Update vars" do
block do
rc = Chef::Util::FileEdit.new(some_path)
rc.search_file_replace(...)
rc.write_file
end
action :create
end

/Jeppe

If you want to edit a configuration file, you can try (for test) this one
too (from me):
http://community.opscode.com/cookbooks/conffile

I only manage INI file, but anyone can had support for YAML ...
You can change/add properties or rewrite a file from an Hash.

I don't use augeas right now... but I will really enjoy any contribution in
this way.

Guilhem Lettron

On Mon, Sep 16, 2013 at 10:21 AM, Jorge Bianquetti jbianquetti@gmail.comwrote:

Recently discussed on this list:
http://community.opscode.com/cookbooks/line

2013/9/16 Jeppe Nejsum Madsen jeppe@ingolfs.dk

sivajimsingh@gmail.com writes:

Hi there,

I need to do in-place file editing of config files using Chef. For now,
i could
see that we can append data to the config files using the "bash"
resource. But,
i need to change specific variables in config files using Chef.

I could see that there's a handy tool called augeas in puppet that
clearly
performs the above requirement. But, i couldn't come up with anything
in Chef.

So, is there any way this could be done in Chef?

You can use the FileEdit class in a ruby block:

ruby_block "Update vars" do
block do
rc = Chef::Util::FileEdit.new(some_path)
rc.search_file_replace(...)
rc.write_file
end
action :create
end

/Jeppe