Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make possible to use custom vhosts via hiera directly #2409

Open
sergey-ganchuk opened this issue May 3, 2023 · 10 comments
Open

Make possible to use custom vhosts via hiera directly #2409

sergey-ganchuk opened this issue May 3, 2023 · 10 comments

Comments

@sergey-ganchuk
Copy link

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.

@ekohl
Copy link
Collaborator

ekohl commented May 3, 2023

There is apache::vhosts. Is that not enough?

@sergey-ganchuk
Copy link
Author

not enough if you want to use custom vhost configuration

@ekohl
Copy link
Collaborator

ekohl commented May 3, 2023

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.

@sergey-ganchuk
Copy link
Author

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

@ekohl
Copy link
Collaborator

ekohl commented May 3, 2023

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.

@sergey-ganchuk
Copy link
Author

Hi
I was trying to use this apache directive:
AuthnProviderAlias ldap

@ekohl
Copy link
Collaborator

ekohl commented May 4, 2023

You're right, that should be a feature request (or a pull request).

@Ramesh7 Ramesh7 added the jira label Aug 10, 2023
@rolfsrolfs
Copy link

rolfsrolfs commented Aug 16, 2023

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'

@Ramesh7
Copy link
Contributor

Ramesh7 commented Sep 12, 2023

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 }
}

@Ramesh7
Copy link
Contributor

Ramesh7 commented Sep 18, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants