# Ruby template indentation issue - puppet

**URL:** <https://www.ruby-forum.com/t/ruby-template-indentation-issue-puppet/259960>\
**Category:** Uncategorized\
**Created:** [July 8, 2020, 1:50pm UTC](https://www.ruby-forum.com/t/ruby-template-indentation-issue-puppet/259960 "2020-07-08T13:50:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sglakjnn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sglakjnn](https://www.ruby-forum.com/u/sglakjnn)\
**Post date:** [July 8, 2020, 1:50pm UTC](https://www.ruby-forum.com/t/ruby-template-indentation-issue-puppet/259960/1 "2020-07-08T13:50:09Z")

</div>

I’m unable to fix indentation for ruby template, I’ve spent hours on this and still couldn’t get it to work as expected.

Here is the template:

```auto
    <%= @log_path -%> {
      <%= @rotate_every %>
      rotate <%= @rotate_count %>
      compress
      <% if @delaycompress == true %>delaycompress
      <% end -%>missingok
      notifempty
      create <%= @create_mode -%> <%= @create_owner -%> <%= @create_group %>
      <% if @postrotate == true -%>postrotate
        <% @postrotate_cmd.each do |value| -%><%= value %>
      <% end -%>endscript<% end %>
    }

```

When `@postrotate` is false the output looks like this. The `}` is after a empty line.

```auto
    /var/log/auth.log {
      weekly
      rotate 4
      compress
      delaycompress
      missingok
      notifempty
      create 0644 root adm
      
      }

```

When `@postrotate` is true the output looks like this. The second `invoke commnad` should be a bit to the right.

```auto
    /var/log/auth.log {
      weekly
      rotate 4
      compress
      delaycompress
      missingok
      notifempty
      create 0644 root adm
      postrotate
        invoke-rc.d rsyslog reload > /dev/null
      invoke-rc.d rsyslog reload > /dev/null
      endscript
      }

```

Expected output when `@postrotate` is `false`:

```auto
    /var/log/auth.log {
      weekly
      rotate 4
      compress
      delaycompress
      missingok
      notifempty
      create 0644 root adm
    }

```

Expected output when `@postrotate` is `true`:

```auto
    /var/log/auth.log {
      weekly
      rotate 4
      compress
      delaycompress
      missingok
      notifempty
      create 0644 root adm
      postrotate
        invoke-rc.d rsyslog reload > /dev/null
        invoke-rc.d rsyslog reload > /dev/null
      endscript
    }

```
