Puppetlabs MySQL - Resource not found

asked 2016-04-27 04:01:42 -0600

Sebastian gravatar image

I have two classes in a serverless Ubuntu 14.04 setup. Puppet is version 3.8.7, puppetlabs-mysql is version 3.7.0:

class example::mysql {
  include stdlib
  include mysql

  $mysqld_override_options = {
    'mysqld' => {
      'innodb_file_per_table' => 1,
      'lower_case_table_names' => 1,
    }
  }

  # This is not the ideal way to generate a password, as this isn't
  # truly random, but it's the least worse way, I found.
  $mysql_root_password = fqdn_rand_string(45)

  class { '::mysql::server':
    root_password           => $mysql_root_password,
    create_root_user        => true,
    create_root_my_cnf      => true,
    remove_default_accounts => true,
    override_options        => $mysqld_override_options,
  }
}

and

class example {
  include example::mysql

  define example::site ($serverName, $mysqlUser) {
    # we may drop the requirement for a separate mysqluser, once we
    # switch to ubuntu 16.04, as the mysql version shipped with 14.04
    # has in insanely low limit on the username length hindering us to
    # auto-generate it
    $mysqlDbName = regsubst($servername, '\.', '_', 'G')
    $mysqlDbPassWord = fqdn_rand_string(45, undef, $mysqlDbName)

    mysql::db { $mysqlDbName:
      user     => $mysqlUser,
      password => $mysqlDbPassWord,
      host     => 'localhost',    
  }

  example::site { 'www.example.com Testsite' : serverName => "www.example.com", mysqlUser => 'mysqltest' }
}

This fails with

Error: Could not find resource 'Mysql::Db[]' for relationship from 'Class[Mysql::Server::Root_password]' on node example

How to fix this error?

edit retag flag offensive close merge delete