How to manage the service for web server and app?

24 views
Skip to first unread message

Haani Niyaz

unread,
Jul 29, 2016, 6:19:15 AM7/29/16
to Puppet Users
Hi there,

I have a use case where we currently manage a  web server, and an app. Now this similar to deploying tomcat and a webapp or apache and a php app. Both the server and the app subscribe to the Package/File/Service pattern however I seem to have hit a problem managing the service (requiring the web server service to restart when the app config files changes). 

This is the structure of the mdule (to manage the server & app as a defined type):

.

 

├── app

  ├── config.pp

  ├── install.pp

  ├── manage_credentials.pp (defined type)

  └── params.pp

├── app.pp (defined type)

├── config.pp

├── init.pp

├── install.pp

├── params.pp

└── service.pp




I've setup the web server in a typical Package/File/Service style and perhaps its also worth noting that in the manifest/config.pp file I notify Class['web_server::service'] for each file change.




In the app.pp defined type I have the following:


define web_server::app(
  $package_name
,
  $repo_name
,
  $package_version
,
  $credentials
) {

   include web_server

   
class{'web_server::app::install':

      package_name    
=> $package_name,
      repo_name        
=> $repo_name,
      package_version  
=> $package_version,
   
} ->

   
class { 'web_server::app::config':
      credentials
=> $credentials,
   
}

    contain
::web_server::app::install
    contain
::web_server::app::config

}



Inside the server::app::config file i have a few  Class['web_server::service'] notify statements to restart the service on app file changes. However this is causing dependency cycle errors.



Any idea where I'm going wrong with this? How do you generally manage this type of scenario? I looked at the apache forge module and it seems to be littered with Class['apache::service'] notify statements within classes/subclasses - what am I missing here?

Thomas Müller

unread,
Aug 9, 2016, 1:58:59 AM8/9/16
to Puppet Users


Am Freitag, 29. Juli 2016 12:19:15 UTC+2 schrieb Haani Niyaz:



In the app.pp defined type I have the following:


define web_server::app(
  $package_name
,
  $repo_name
,
  $package_version
,
  $credentials
) {

   include web_server

   
class{'web_server::app::install':

      package_name    
=> $package_name,
      repo_name        
=> $repo_name,
      package_version  
=> $package_version,
   
} ->

   
class { 'web_server::app::config':
      credentials
=> $credentials,
   
}

    contain
::web_server::app::install
    contain
::web_server::app::config

}



Inside the server::app::config file i have a few  Class['web_server::service'] notify statements to restart the service on app file changes. However this is causing dependency cycle errors.

here?


You can't declare a class more than once.  the " class{'web_server::app::install':" and class { 'web_server::app::config': needs to be a defined type too, if you require it to be called with different params. A class can only exist excatly once.

IMHO contain should not be used inside a defined type - but as you need to convert the classes to defined types, this problem is already solved. (https://docs.puppet.com/puppet/latest/reference/lang_containment.html#containing-classes)

- Thomas

Reply all
Reply to author
Forward
0 new messages