On Feb 24, 10:17 am, Tim Dunphy <[email protected]> wrote:
> class dbservices {
>
>    $pgapps = [ "postgresql84-server","postgresql84" ]
>    package { $pgapps: ensure  => installed }
>
>    $mysqlapps = [ "mysql-server","mysql","php-mysql" ]
>    package { $mysqlapps: ensure  => installed }
>
>    service { postgresql:
>              name  => postgresql,
>              enable => true,
>              ensure => running,
>              require => Package[$pgapps]
>    }
>
>        service { mysqld:
>                  name  => mysqld,
>                  enable => true,
>                  ensure => running,
>                  require => Package[$mysqlapps]
>       }
>
> }

[...]

> If I do a yum remove of those apps and then write the required lines this way:
>
>                  require => Package["$mysqlapps"]
>                  require => Package["$pgapps"]
>
> (with quotes around the array variables)
>
> It results in this puppet run on the db host:
>
> [root@pclient ~]# puppetd --test
> info: Caching catalog for pclient.acadaca.net
> err: Could not run Puppet configuration client: Could not find
> dependency Package[mysql-servermysqlphp-mysql] for Service[mysqld] at
> /etc/puppet/manifests/classes/dbservices.pp:27

That's normal.  Puppet should perhaps issue a better (or earlier)
error message for this case, but the bottom line is that
Package[ $arrayvar ] references a single package whose name is the
concatenation of all the elements of $arrayvar, not, as you had hoped,
an array of Package references.

It is not easy in Puppet DSL to generate an array of resource
references from an array of resource names, but in this case it should
not be necessary to do so.  The postgresql and mysqld services do not
need to depend on all of $pgapps and $mysqlapps, respectively.  They
only need to depend on the packages that actually provide them, i.e.
postgresql84-server and mysql-server.  It does no good and is
potentially harmful to declare dependencies that don't actually exist,
so you should write:

service { "postgresql":
  name  => "postgresql",
  enable => true,
  ensure => running,
  require => Package["postgresql84-server']
}

service { "mysqld":
  name  => "mysqld",
  enable => true,
  ensure => running,
  require => Package["mysql-server"]
}

That should take care of the errors you encountered when the servers
are not already installed before the Puppet run.  I see no reason to
expect that it will affect the errors you encounter when Puppet tries
to start those services, however.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to