Make possible to use custom vhosts via hiera directly
Use Case
I was trying to use module via hiera and found that it is impossible to make an custom vhost via hiera.
Describe the Solution You Would Like
It would be great to have ability to create custom vhosts.
Describe Alternatives You've Considered
I had to create wrapper module.
There is apache::vhosts. Is that not enough?
not enough if you want to use custom vhost configuration
Why not? You can specify all the parameters you usually have. What can you do with a wrapper that you can't via Hiera? The issue now lacks any information to be useful.
There is define apache::vhost::custom It nowere implemented in the code. You can't use it via hiera directly. There are apache2 options that do not exist in apache::vhosts
There is define apache::vhost::custom It nowere implemented in the code. You can't use it via hiera directly.
That's true. You could submit a PR to apache::vhosts to add a parameter.
There are apache2 options that do not exist in apache::vhosts
Again, it helps to be explicit.
Hi I was trying to use this apache directive: AuthnProviderAlias ldap
You're right, that should be a feature request (or a pull request).
Defined types can be used if you define them via create resources, requires puppetlabs-stdlib to work. The stdlib::manage::create_resources is your friend!
classes:
- "stdlib::manage"
stdlib::manage::create_resources:
apache::custom_config:
myconfigname:
ensure: present
filename: "5-settings.conf"
priority: 5
owner: root
group: root
file_mode: "0644"
content: |
ServerSignature Off
# basically whatever you want.
apache::vhost::custom:
mycustomvhost:
ensure: 'present'
priority: 25
verify_config: true
content: |
# add your vhost
# content here
file:
/var/www/vhosts:
ensure: directory
owner: root
group: root
mode: '755'
Defined types can be used if you define them via create resources, requires puppetlabs-stdlib to work. The stdlib::manage::create_resources is your friend!
classes: - "stdlib::manage" stdlib::manage::create_resources: apache::custom_config: myconfigname: ensure: present filename: "5-settings.conf" priority: 5 owner: root group: root file_mode: "0644" content: | ServerSignature Off # basically whatever you want. apache::vhost::custom: mycustomvhost: ensure: 'present' priority: 25 verify_config: true content: | # add your vhost # content here file: /var/www/vhosts: ensure: directory owner: root group: root mode: '755'
Hi @rolfsrolfs, I have tried using puppet apply but somehow I was not able to get through, not sure if I am missing here.
The another way I was able to get through is :
Hiera
apache::vhost::custom:
content: |
Alias /custom /var/www/custom
<Directory /var/www/custom>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Manifest:
$custom_vhost = lookup('apache::vhost::custom')
create_resources('apache::vhost::custom',
{ 'content' => $custom_vhost }
}
Defined types can be used if you define them via create resources, requires puppetlabs-stdlib to work. The stdlib::manage::create_resources is your friend!
classes: - "stdlib::manage" stdlib::manage::create_resources: apache::custom_config: myconfigname: ensure: present filename: "5-settings.conf" priority: 5 owner: root group: root file_mode: "0644" content: | ServerSignature Off # basically whatever you want. apache::vhost::custom: mycustomvhost: ensure: 'present' priority: 25 verify_config: true content: | # add your vhost # content here file: /var/www/vhosts: ensure: directory owner: root group: root mode: '755'
After some tries was able to generate vhost using hiera as you mentioned in above comments. I think the missing part here is the manifest also needs to include the below class of stdlib :
include stdlib::manage
Once we include we can define any number of resources in hiera and we can get it generate the custom vhost. Thanks @gavindidrichsen for pointers.
@sergey-ganchuk can you please try with this approach, it should work as expected.