Issue #3186 has been reported by Dan Bode.

----------------------------------------
Bug #3186: require not working as expected
http://projects.reductivelabs.com/issues/3186

Author: Dan Bode
Status: Unreviewed
Priority: Normal
Assigned to: 
Category: plumbing
Target version: 
Affected version: 0.25.4
Keywords: require order
Branch: 


I have an example where require is not correctly specifying a dependency 
between classes.

<pre>
$mysql_old_pw='b'
$mysql_root_pw='p'
$redmine_db='r'
$redmine_db_user='red'
$redmine_db_pw='red'
include redmine::mysql
</pre>

<pre>
class redmine::mysql {
  require mysql::server
  require mysql::ruby
  if ! $redmine_db {
    fail('$redmine_db parameter is required')
  }
  if ! $redmine_db_user {
    fail('$redmine_db_user parameter is required')
  }
  if ! $redmine_db_pw {
    fail('$redmine_db_pw parameter is required')
  }
  database{$redmine_db:
    ensure   => present,
    charset  => 'utf8',
    provider => 'mysql',
  }
  database_user{"${redmine_db_us...@localhost":
    ensure        => present,
    password_hash => mysql_password($redmine_db_pw),
    require       => Database[$redmine_db],
    provider      => 'mysql',
  }
  database_grant{"${redmine_...@localhost/${redmine_db}":
#    privileges => [ 'alter_priv', 'insert_priv', 'select_priv', 'update_priv' 
],
    provider   => 'mysql',
    privileges => all,
  }
}
</pre>

<pre>
class mysql::server {
  # set the mysql root password
  if(! $mysql_root_pw) {
    fail('$mysql_root_pw must be set for class mysql::server')
  }
  package{'mysql-server':
    name   => 'mysql-server',
    ensure => installed,
    notify => Service['mysqld'],
  }
.....
#more code here
</pre>

the require statement should order all of the resources in mysql::server before 
everything in redmine::mysql, but the Database resource is applied before the 
mysql-server package is installed (see output below).

<pre>
r...@ubuntu:/usr/local/dev/modules/infrastructure/modules/redmine/tests# puppet 
mysql.pp --noop
notice: //mysql::ruby/Package[ruby-mysql]/ensure: is absent, should be present 
(noop)
err: //redmine::mysql/Database[redmine]: Failed to retrieve current state of 
resource: Provider mysql is not functional on this platform
notice: //redmine::mysql/database_user[redm...@localhost]: Dependency 
database[redmine] has 1 failures
warning: //redmine::mysql/database_user[redm...@localhost]: Skipping because of 
failed dependencies
notice: //redmine::mysql/database_grant[redm...@localhost/redmine]: Dependency 
database[redmine] has 1 failures
warning: //redmine::mysql/database_grant[redm...@localhost/redmine]: Skipping 
because of failed dependencies
notice: //mysql::server/Package[mysql-server]/ensure: is purged, should be 
present (noop)
notice: //mysql::server/Service[mysqld]/enable: is false, should be true (noop)
notice: //mysql::server/Service[mysqld]: Would have triggered refresh from 1 
dependencies
err: //mysql::server/Exec[set_mysql_rootpw]: Failed to retrieve current state 
of resource: 
notice: //mysql::server/File[/root/.my.cnf]: Dependency exec[mysqladmin -u root 
-pblah password password] has 1 failures
warning: //mysql::server/File[/root/.my.cnf]: Skipping because of failed 
dependencies
notice: //mysql::server/File[/etc/my.cnf]/ensure: is absent, should be file 
(noop)
notice: //mysql::server/Service[mysqld-restart]: Dependency exec[mysqladmin -u 
root -pblah password password] has 1 failures
warning: //mysql::server/Service[mysqld-restart]: Skipping because of failed 
dependencies
notice: //mysql::server/Service[mysqld-restart]: Would have triggered refresh 
from 1 dependencies
</pre>

I can work around by specifying require=>Class['mysql::server'] for the 
resources that care about order, but I would rather use require.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://reductivelabs.com/redmine/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" 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-bugs?hl=en.

Reply via email to