example42 / puppet-mysql

Mysql Puppet Module
http://www.example42.com
Other
16 stars 38 forks source link

Error: Duplicate declaration: grant.pp:115 #63

Open ghost opened 9 years ago

ghost commented 9 years ago

Hi,

I am trying to run the same puppet apply on the same instance and gets this issue second time round, could this resource not be more unique?

Error: Duplicate declaration: File[mysqlgrant-ejbca-localhost-MSMCA.sql] is already declared in file /etc/puppet/modules/mysql/manifests/grant.pp:115; cannot redeclare at /etc/puppet/modules/mysql/manifests/grant.pp:115 on node ip-10-96-3-143.inf1.gb.msm.internal
ghost commented 9 years ago

I am wondering if it would be better to use the 'title' instead of dbname here;

https://github.com/example42/puppet-mysql/blob/master/manifests/grant.pp#L77

I am trying todo something like this:

  if exists($backup_file_guard_with_fqdn) {
    mysql::query { $supported_ejbca_dbname:
      mysql_query    => "DROP DATABASE IF EXISTS ${supported_ejbca_dbname};",
      mysql_user     => $supported_ejbca_username,
      mysql_password => $supported_ejbca_password,
      require        => Class['mysql'],
      before         => Service['jboss']
    } ->
    mysql::grant { "revoke-${supported_ejbca_dbname}":
      ensure         => 'absent',
      mysql_db       => $supported_ejbca_dbname,
      mysql_user     => $supported_ejbca_username,
      mysql_password => $supported_ejbca_password,
      require        => Class['mysql'],
      before         => Service['jboss']
    } ->
    mysql::grant { "create-${supported_ejbca_dbname}":
      ensure                   => 'present',
      mysql_db                 => $supported_ejbca_dbname,
      mysql_user               => $supported_ejbca_username,
      mysql_password           => $supported_ejbca_password,
      mysql_db_init_query_file => $backup_file_name_with_fqdn,
      require                  => Class['mysql'],
      before                   => Service['jboss']
    }
  } else {
    mysql::grant { "create-${supported_ejbca_dbname}":
      ensure         => 'present',
      mysql_db       => $supported_ejbca_dbname,
      mysql_user     => $supported_ejbca_username,
      mysql_password => $supported_ejbca_password,
      require        => Class['mysql'],
      before         => Service['jboss']
    }
  }