Multiple vhosts, same document root

30 views
Skip to first unread message

b...@area536.com

unread,
Jul 6, 2017, 3:32:52 PM7/6/17
to puppet...@googlegroups.com
Hello Puppet users,

I'm working on a webserver module that needs to ensure directories for
document roots. I tried doing this by using file resources like so:

file { 'vhost-A':
ensure => 'directory',
path => '/var/www/sharedvhost',
...clipped for brevity...
}

file { 'vhost-B':
ensure => 'directory',
path => '/var/www/sharedvhost',
...clipped for brevity...
}

This, sadly, does not work. Even though I avoid the pitfall of declaring
two resources by the same name Puppet is clever enough to see that I'm
ensuring the same path in the end.

What I'd like the result to be, is the existence of /var/www/sharedvhost
with the ability for my vhost resource type to know about it but without
throwing errors.

Any help would be much appreciated!

Bas
Message has been deleted

Neil - Puppet List

unread,
Jul 11, 2017, 3:42:25 PM7/11/17
to PuppetList
Hello

stdlib package has a function ensure_resource that would allow you to create the directory as many times as needed. 

out of curiosity why not use the puppetlabs apache module? 

Cheers
Neil 

On 7 Jul 2017 09:39, "'Bas van de Wiel' via Puppet Users" <puppet...@googlegroups.com> wrote:

So I managed to hack a fix for this:

# Hackish pair of execs to allow multiple sites with the same docroot
exec { "${name}_${webroot}":
  cwd     => '/',
  user    => 'root',
  path    => '/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/beheer/bin',
  command => "`which mkdir` -p ${webroot}",
  creates => $webroot,
  notify  => Exec["${name}_webroot_permissions"],
}
 
exec { "${name}_webroot_permissions":
  cwd         => '/',
  user        => 'root',
  path        => '/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/beheer/bin',
  command     => "`which chown` ${apache::user}:${apache::group} ${webroot}",
  refreshonly => true,
}

Any comments?

Bas

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/fbdc265c-4fe1-59b3-fb07-c951abe957d6%40area536.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages