Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Resource defaults not working for Apache

I am using the PuppetLabs apache module. I would like to set SetEnvIf values for ever single vhost.

I set the value in my web_server profile:

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

    Apache::Vhost {
        setenvif      => [
            'User-Agent "KEMP 1.0" dontlogkemp dontlog',
        ],
    }
}

No matter what I do, it is not added to the config. I tried several other values for testing (port and priority) and none of them seem to work either.

Puppet version: 3.8.1


I do have a sort of ugly workaround (which puts the config for the whole apache server instead of for every vhost):

define apache_setenv($setenvif) {
    apache::custom_config { 'setenvif':
        priority => '0',
        content  => template('apache/vhost/_setenv.erb'),
    }
}
apache_setenv(
    setenvif => [
        'User-Agent "KEMP 1.0" dontlogkemp dontlog',
    ]
);

Resource defaults not working for Apache

I am using the PuppetLabs apache module. I would like to set SetEnvIf values for ever single vhost.

I set the value in my web_server profile:

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

    Apache::Vhost {
        setenvif      => [
            'User-Agent "KEMP 1.0" dontlogkemp dontlog',
        ],
    }
}

My vhosts are defined in other classes, but I want them to inherit this default:

class profile::web_server::cluster {
    apache::vhost { 'clustered site 1':
        ...
    }
    apache::vhost { 'clustered site 2':
        ...
    }
}
class profile::web_server::server1 {
    apache::vhost { 'site 1 on server 1 only':
        ...
    }
    apache::vhost { 'site 2 on server 1 only':
        ...
    }
}
...

No matter what I do, it is not added to the config. I tried several other values for testing (port and priority) and none of them seem to work either.

Puppet version: 3.8.1


I do have a sort of ugly workaround (which puts the config for the whole apache server instead of for every vhost):

define apache_setenv($setenvif) {
    apache::custom_config { 'setenvif':
        priority => '0',
        content  => template('apache/vhost/_setenv.erb'),
    }
}
apache_setenv(
    setenvif => [
        'User-Agent "KEMP 1.0" dontlogkemp dontlog',
    ]
);

Resource defaults not working for Apache

I am using the PuppetLabs apache module. I would like to set SetEnvIf values for ever single vhost.

I set the value in my web_server profile:

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

    Apache::Vhost {
        setenvif      => [
            'User-Agent "KEMP 1.0" dontlogkemp dontlog',
            'User-Agent "SearchApp 2.1" dontlogsearchapp dontlog',
        ],
    }
}

My vhosts are defined in other classes, but I want them to inherit this default:

class profile::web_server::cluster {
    apache::vhost { 'clustered site 1':
        ...
    }
    apache::vhost { 'clustered site 2':
        ...
    }
}
class profile::web_server::server1 {
    apache::vhost { 'site 1 on server 1 only':
        ...
    }
    apache::vhost { 'site 2 on server 1 only':
        ...
    }
}
class profile::web_server::server2 {
    apache::vhost { 'site 3 on server 2 only':
        ...
    }
    apache::vhost { 'site 4 on server 2 only':
        ...
    }
    apache::vhost { 'site 5 on server 2 only':
        ...
    }
    apache::vhost { 'site 6 on server 2 only':
        ...
    }
}
...

No matter what I do, it is not added to the config. I tried several other values for testing (port and priority) and none of them seem to work either.

All the sites are behind a load balancer and need this SetEnvIfso that their access logs don't fill up with uptime checks by our load balancer and search engine indexer. The useragent may change or we may add additional ones, so I only want to have it in one place for 100+ vhosts.

Puppet version: 3.8.1


I do have a sort of ugly workaround (which puts the config for the whole apache server instead of for every vhost):

define apache_setenv($setenvif) {
    apache::custom_config { 'setenvif':
        priority => '0',
        content  => template('apache/vhost/_setenv.erb'),
    }
}
apache_setenv(
    setenvif => [
        'User-Agent "KEMP 1.0" dontlogkemp dontlog',
        'User-Agent "SearchApp 2.1" dontlogsearchapp dontlog',
    ]
);