0

Is there any way to create a "Directory" in a vhost and put inside an "Include" with Puppet?

Like this:

<Directory "/var/www">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Require all granted
    Include /etc/apache2/myconf.d/htpasswd.conf
</Directory>

I did it with "custom_fragment" but I would like to do with "additional_includes", but "additional_includes" can't use it inside the variable "directories".

Is there any another way?

Thanks.

jotacor
  • 2,878
  • 1
  • 18
  • 19

3 Answers3

2

I assume you are using Puppet Enterprise or the PLAM.

It has indeed no native support for what you are trying. custom_fragment is actually a very good choice here.

If you really want to add the include through a dedicated hash key, you can modify the module and open a pull request. You will basically have to add a section like the existing ones to the template. Also, some brief documentation. The guys love pull requests ;-)

Felix Frank
  • 8,125
  • 1
  • 23
  • 30
0

Looks like you're looking for an array?

if you are using the puppetlabs module, you can use "additional_includes"

additional_includes Specifies paths to additional static, vhost-specific Apache configuration files. Useful for implementing a unique, custom configuration not supported by this module. Can be an array. Defaults to '[]'.

https://forge.puppetlabs.com/puppetlabs/apache#parameter-directories-for-apachevhost

apache::vhost { 'myvhost.whaterver.com':
  port                => 8080,
  docroot             => '/var/www/folder',
  directories         => [
    {  'path'                => '/var/www/folder',
       'options'             => 'None',
       'allow_override'      => 'None',
       'order'               => 'Allow,Deny',
       'allow'               => 'from All',
       'additional_includes' => ['/etc/apache2/myconf.d/htpasswd.conf', 'other settings'],
      },],

`

Rook
  • 5,734
  • 3
  • 34
  • 43
-1

Here a snippet that works for me:

    class {'apache':
            default_vhost => false,
    }

    apache::vhost {'mydefault':
            port => 80,
            docroot => '/var/www/html',

            directories => [
                    {
                            'path' => '/var/www/html',
                            'provider' => 'files',
                    },
                    {
                            'path' => '/media/my_builds',
                            'options' => 'Indexes FollowSymLinks MultiViews',
                            'allowoverride' => 'None',
                            'require' => 'all granted',
                            'additional_includes' => ['what Randy Black said'],
                    },
            ],

            aliases => [
                    {
                            alias => '/my_builds',
                            path => '/media/my_builds',
                    },
            ],
    }
Robert Fey
  • 1,747
  • 22
  • 23