Search code examples
apache2puppetconcatenationvhosts

puppet concat::fragment not inserting content in vhost


So I have a vhost config in my puppet manifest file

apache::vhost { 'site.dev':
    port => '80',
    docroot => '/home/vagrant/projects/Personal/php/site/public',
    serveradmin => '[email protected]',
    options => ['Indexes','FollowSymLinks','MultiViews'],
    setenv => ["APP_ENV dev"],
    override => ['All'],
}

Now I want to add these options

EnableSendfile Off
EnableMMAP Off

I googled and found that concat::fragment might just be what I need, so I tried the following:

concat::fragment { "site.dev-static":
      target  => '25-site.dev.conf',
      order   => '01',
      content => '
        EnableSendfile Off
        EnableMMAP Off
      ',
}

NOTE In the target I have also tried with the full path: /etc/apache2/sites-available/25-site.dev.conf (with same results)

When I do vagrant provision I get this:

-- snip --
==> acs_dev: Warning: Scope(Concat::Fragment[Listen 80]): The $ensure parameter to concat::fragment is deprecated and has no effect.
-- snip --

I assume this worked fine but when I go to the vhos file at /etc/apache2/sites-available/25-site.dev.conf the EnableSendfile and EnableMMAP are not there.

I am using version 2.0.0 of puppetlabs concat module.

What do I need to do to make this work??

UPDATE

Apparently I could have just used

custom_fragment

In the vhost code. Don't know why this doesn't appear first in the module documentation.


Solution

  • You can add custom fragments in the vhost code like so:

    apache::vhost { 'foo':
      port              => '80',
      ip                => '127.0.0.1',
      add_listen        => false,
      proxy_pass        => [
        {
          'path' => '/',
          'url' => "http://127.0.0.1:8080",
          'reverse_urls' => "http://127.0.0.1:8080",
        },
      ],
      docroot           => '/var/www/html',
      custom_fragment   => '# Fragment content',
    }
    

    I also find that using the template function makes it easier to manage the content if it's a long fragment:

    custom_fragment   => template('apache_profile/etc/httpd/apache_custom_fragment.erb'),
    

    The custom_fragment parameter is documented in the README.md