Hi all, I have a question on the use of chef LWRP when various
resources have to be configured in one file.
An example is fail2ban. Fail2ban is a perfect service to implement a
LWRP for, except that all jails have to be configured in jail.local.
Most programs (like logrotate) allow you to specify each instance of
your service in a "service.d" folder, so as to not clobber the
configuration of other services of the same program. Unfortunately,
fail2ban does this for actons and filters, but requires all jails to
be configured in jail.local.
Now the format for each jail is very simple, so it's easy to do a
template that loops over each jail definition like so:
<% @local_jail.each do |jail| -%>
[<%= jail["name"] %>]
logpath = <%= jail["logpath"] %>
enabled = true
filter = <%= jail["filter"] %>
action = <%= jail["action"] %>
maxretry = <%= jail["maxretry"] %>
bantime = <%= jail["bantime"] %>
<% end -%>
Idealy you could call this as a LWRP, so you could have something like:
fail2ban_app "myapp" do
However, as far as I have been able to see in the documentation, each
time the LWRP is called, it has to generate a template. Is it possible
to just have the LWRP just accumulate the variables each time it is
called and then generate the template at the end? Or is there another
way of doing this that I am not seeing? I am still somewhat of a chef
newbie so I might have missed something.
Archive powered by MHonArc 2.6.16.