On Jul 13, 5:34 am, Arnaud Gomes-do-Vale <arnaud.go...@ircam.fr> wrote: > Hi, > > First, thanks for your help. However I still have some issues with your > solution. > > > > jcbollinger <john.bollin...@stjude.org> writes: > > few bad ones. Here's a good rule of thumb: never use Puppet's > > "defined()" function in your manifests. Ever. It is brittle, and it > > will cause you grief, increasing exponentially with the number of > > uses. > .../... > > There is no need for subclassing or defined() here. I would approach > > the problem something like this: > > # Resource defaults for Packages in this class > > Package { > > ensure => installed, > > require => Package['php'], > > notify => Service['httpd'] > > } > > This creates a dependency loop: > > err: Could not apply complete catalog: Found dependency cycles in the > following relationships: Package[php] => Package[httpd], Package[httpd] => > Package[php], Package[php] => Package[php-ldap], Package[php-imap] => > Package[php-mysql], Package[php-gd] => Package[php-mysql], Package[php-ldap] > => Package[php-mysql], Package[php] => Package[php-mysql], Package[httpd] => > File[/etc/httpd/conf.d/mod-status.conf], Package[php] => > Package[php-mbstring], Package[httpd] => Service[httpd], Package[httpd] => > Service[httpd], Package[php-imap] => Service[httpd], Package[php-mysql] => > Service[httpd], Package[php-gd] => Service[httpd], Package[php-ldap] => > Service[httpd], Package[php] => Service[httpd], > File[/etc/httpd/conf.d/mod-status.conf] => Service[httpd], > Package[php-mbstring] => Service[httpd], Package[php] => Package[php-imap], > Package[php] => Package[php-gd], Package[httpd] => File[/var/www/html]; try > using the '--graph' option and open the '.dot' files in OmniGraffle or > GraphViz > > As far as I understand, Package['httpd'] (defined in class apache::base) > inherits the dependency on Package['php']. This is using Puppet 2.6.8; > has this changed in 2.7.x?
Fair enough, then move the 'require' parameter back out of resource defaults into individual Package resources. Using resource defaults is not an essential aspect of the solution. > > # ** No class apache::php53 ** > > So how do I tell Puppet which nodes need 5.1 and which need 5.3? With my > sample wordpress class I get the following error: See below. > err: Could not retrieve catalog from remote server: Error 400 on SERVER: > Could not find class apache::php53 in namespaces wordpress at > /etc/puppet/modules/wordpress/manifests/init.pp:6 on node testxen1.ircam.fr > > Looks like using a dummy class definition as a flag won't work. :-) I > could use a variable instead, but I guess the ordering issues would get > even worse? As I wrote, "Everybody that needs PHP just includes apache::php." There is no more apache::php53. > > # class apache::params unchanged, not shown > > So I'm still using defined(). Ah. That's a blunder on my part. These are the alternatives I can think of: 1) Per node, set a global variable that directs which set of PHP packages to use. 2) Use extlookup() to retrieve a flag variable such as described in (1), or else to retrieve the individual PHP package names. 3) Base the PHP package selection on node facts (possibly just $hostname) instead of on defined() 4) Though I don't favor parameterized classes, you could parameterize apache::php to allow your nodes to direct which set of PHP packages to use; whether this is feasible depends somewhat on how the class is used. Another way to do this might be to stick with apache::php53 as a subclass of apache::php, and use resource overrides. This is clean only if you don't need the PHP package names in other classes, but it looks like you're relying on titles instead of names anyway. The result might be something like this: ---- class apache::php { include 'apache::base' package { 'php': ensure => installed, require => Package['httpd'], notify => Service['httpd']; 'php-gd': ensure => installed, require => Package['php'], notify => Service['httpd']; 'php-imap': ensure => installed, require => Package['php'], notify => Service['httpd']; 'php-ldap': ensure => installed, require => Package['php'], notify => Service['httpd']; } } class apache::php53 inherits apache::php { # $os is defined in site.pp. if $::os == 'rhel5' { Package['php'] { name => 'php53u' } Package['php-gd'] { name => 'php53u-gd' } Package['php-imap'] { name => 'php53u-imap' } Package['php-ldap'] { name => 'php53u-ldap' } package { 'php-alt': name => 'php', ensure => absent, require => undef, before => Package['php'] } } else { warning 'Class apache::php53 should only ever be defined for RHEL5 and its clones.' } } # # No class apache::params, at least as pertains to apache::php # ---- RHEL5 nodes that want PHP 5.3 then include apache::php53. It is safe, but unnecessary, for such nodes also to include apache::php. -- John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.