help with apache configuration

190 views
Skip to first unread message

Latina Endo

unread,
Apr 19, 2015, 10:34:59 PM4/19/15
to puppet...@googlegroups.com

I’m trying to configure 1 webserver to host 2 different domains (example1.com and example2.com) I need both to listen on 80 and 443. There are no subdomains.


I’m using puppetlabs’s apache module with the following configuration:


class profiles::webserver1 {


include apache


#Create the user

user { 'example1':

 ensure => present,

 uid     => 12120,

 managehome => true,

 }->


#Ensure mysql starts up

#class { '::mysql::server':

#  service_enabled =>  true,

#  }


apache::vhost { 'default':

 ensure  => false,

 port => 80,

 }


#install wordpress and configure mysql

wordpress::instance { '/opt/example1':

 version => '4.1.1',

 wp_owner => 'example1',

 wp_group => 'example1',

 db_user => 'example1',

 db_name => 'example1',

 db_password => 'thisshouldsuperbedone',

 }->


#Install php

class { '::apache::mod::php':

 content => '

 AddHandler php5-script .php

 AddType text/html .php',

 }


#Enable mod_rewrite

#apache::mod { 'rewrite': }


#Create apache vhost

apache::vhost { 'example1.com':

 port          => '80',

 docroot       => '/opt/example1',

 fallbackresource => '/index.php',

 directories   => [

{ path        => '/opt/example1',

   allow_override => ['AuthConfig', 'Indexes'],

},

 ],

 }->


#Create ssl vhost

apache::vhost { 'ssl.example1.com':

 port => '443',

 docroot => '/opt/example1',

 ssl => true,

 }


##===second domain===##

#Create the user

user { 'example2':

 ensure => present,

 uid => 12121,

#  managehome => true,

 }->


#Create apache vhost

apache::vhost { 'example2.com':

 port          => '80',

 docroot       => '/opt/example2',

 fallbackresource => '/index.php',

 directories   => [

{ path        => '/opt/example2',

   allow_override => ['AuthConfig', 'Indexes'],

},

 ],

 }->


#Create ssl vhost

apache::vhost { 'ssl.example2.com':

 port => '443',

 docroot => '/opt/example2',

 ssl => true,

 }


}


My problem is, a file called 15-default.conf is being created and its matching when i try to reach the site via either domainname. If i do https:// then it takes me to the right domain content. If i go and manually delete the 15-default.conf and restart httpd everything works as expected.


Reading the module’s documentation i see:

default_vhost

Sets up a default virtual host. Defaults to 'true', set to 'false' to set up customized virtual hosts.


But I’m not sure how to write that out on the profile/manifest, if I do


apache::vhost { 'default':

 ensure  => false,

 port => 80,

 }


I get the following error:

Error: Duplicate declaration: Apache::Vhost[default] is already declared in file /etc/puppet/modules/apache/manifests/init.pp:361; cannot redeclare at /etc/puppet/modules/profiles/manifests/example1.pp:22 on node example2


How can i keep that default file being created and is this a “proper” way to try to setup the 2 vhosts in apache.


Thanks!

-Latina


Joseph Karns

unread,
Apr 20, 2015, 8:41:28 AM4/20/15
to puppet...@googlegroups.com
Hello Latina:

on your line where you have include apache, change to something like this

class{  'apache':
default_mods => true,
default_vhost => false,
default_ssl_vhost => false, 
}

This will trigger the apache class and allow you to pass param's to it.

Thanks
Joseph

Latina Endo

unread,
Apr 25, 2015, 11:24:12 PM4/25/15
to puppet...@googlegroups.com
Thanks, that made the 15-default file go away.

I have a follow-up question, since i'm using cloudflare infront of the site, I need to put this (apache) module file and config in /etc/httpd/conf.d/cloudflare.conf. 

Everytime I run the puppet agent that file gets deleted, is a file resource the only way for me to ensure the file is always there when puppet runs?

Thanks for your help,
-Latina


On Sunday, April 19, 2015 at 10:34:59 PM UTC-4, Latina Endo wrote:

Joseph Karns

unread,
Apr 26, 2015, 5:25:05 PM4/26/15
to puppet...@googlegroups.com
Latina:

Can we see your manifest as it currently. Please highlight the section were you are adding the cloudflare module.

Thanks
Joey

--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/R10Bs99NPMU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/587916a6-a8c2-4273-9b7d-897b32e12c9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mr. Joseph Karns, RHCSA
Reply all
Reply to author
Forward
0 new messages