On Wed, May 13, 2009 at 20:59, Evan Hisey <ehi...@gmail.com> wrote:
> You should be able to do this using the the require and before
> metatypes. Have the package{"mysql": before => Exec["mysql-config]}.
> Some thing liek that should get teh ordering correct for you.

The problem is that the provider suitability resolution happens before
any of the ordering. Consider the following simplified class:

class mysql {
    package { "mysql-client": ensure => installed }
    package { "mysql-server": ensure => installed }
    mysql_user { "u...@localhost":
        password_hash => "hashed password",
        require => [Package["mysql-server"], Package["mysql-client"]],
    }
}

One would expect the two packages would be installed and then the new
db user to be created. However, the mysql_user provider needs
/usr/bin/mysql to be present. Since it isn't (because mysql isn't
installed yet), no suitable providers are found and the run fails
immediately.

If I rewrite the provider to call the various commands directly
instead of using the commands() method, the provider is determined to
be suitable. However, careful ordering must be used to ensure that
mysql has been installed at any point the provider is called. One
unfortunate consequence of this is that the mysql types cannot be
required by anything else, because the require check may happen before
mysql has been installed and then a bunch of stuff fails.

I currently have a fragile collection of require and before specifiers
scattered all over the place and files that are created for the sole
purpose of being synchronisation points, like so:

class mysql {
    package { "mysql-client": ensure => installed }
    package { "mysql-server": ensure => installed }
    mysql_user { "u...@localhost":
        password_hash => "hashed password",
        require => [Package["mysql-server"], Package["mysql-client"]],
        before => File["/var/cruft/mysql_post_inst"],
    }
    file { "/var/cruft/mysql_post_inst": content => "" }
}

class otherstuff {
    package { "myapp": ensure => installed }
    mysql_user { "appu...@localhost":
        password_hash => "hashed password",
        require => [Package["mysql-server"], Package["mysql-client"]],
        before => File["/var/cruft/mysql_post_inst"],
    }
    mysql_database { "appdb":
        require => [Package["mysql-server"], Package["mysql-client"]],
        before => File["/var/cruft/mysql_post_inst"],
    }
    exec { "/usr/local/share/myapp/dbsetup":
        subscribe => Package["myapp"],
        refreshonly => true,
        require => File["/var/cruft/mysql_post_inst"],
    }
}

Of course, in my case I have several of these synchronisation points
because there are several steps that each require a previous set of
operations to be completed before they are valid.

Is this really the best way to handle such dependencies?

--J

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to