0

I have to create api.conf in /etc/apache2/sites-available dir in a server(xyz02.software.com). The apache config is managed via apache module(apache::vhost) in role::script..so basically it is ///modules/role/manifest/script.pp......

<VirtualHost *:80>

ServerAdmin webmaster@localhost

ServerName xyz02.software.com

ErrorLog ${APACHE_LOG_DIR}/api-error.log

CustomLog ${APACHE_LOG_DIR}/api-access.log combined


apache::vhost { 'xyz02.software.com':

ensure => present,

port => 80,

docroot => /var/www,

serveradmin => webmaster@localhost,

servername => xyz02.software.com,

notify => [ Service['apache2'], ], }

when i write this in puppet this way, it create with name 25-xyz.software.com.conf while i have to get with name api.conf....I don't know how i should mention to get with api.conf name.....also this script create the file also in other servers like xyz01 and xyz03 which also shouldn't happen....Is their anything like if statement I should provide?

sameer
  • 1
  • 2

1 Answers1

0

Sorry, but fundamentally the apache module assumes it has complete control over the Apache config files, their names and locations. This means that you can't tell apache::vhost to use api.conf.

The Puppet manifest for apache::vhost is hardcoded to use filenames of the form 25-vhostname.conf:

https://github.com/puppetlabs/puppetlabs-apache/blob/main/manifests/vhost.pp#L2205

The good news is that this almost certainly doesn't matter. The way Apache config works, api.conf and the Puppet vhost config will most likely play together nicely.

Jon
  • 3,573
  • 2
  • 17
  • 24
  • I used this way and it wrked for me but it didn't add the file in /etc/apache2/sites-enabled/ dir ..what is missing? file { '/etc/apache2/sites-available/api.conf': ensure => present, owner => root, group => root, mode => '0644', links => follow, source => 'puppet:///modules/server/api.conf', notify => [Exec["enable api.conf"],], } – sameer Sep 27 '22 at 15:08