New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to use different name for db resource other than db name #489
Allow to use different name for db resource other than db name #489
Conversation
Can you please add documentation for this new parameter as well as regression tests in spec/acceptance to test the new feature? |
How's it now? I did some cleanup and rebase :) |
In general, puppet's way of handling resources makes using the resource name as a parameter a terrible idea. Thank you for the fix, xcompass. mysql_user and mysql_grant need this also (and probably others). |
Agreed! Using resource name/title can be troublesome as they have to be unique. |
1) mysql::db define creating a database with dbname parameter should have the database
Failure/Error: shell("mysql -e 'show databases;'|grep realdb") do |s|
Beaker::Host::CommandFailure:
Host 'centos-64-x64' exited with 1 running:
mysql -e 'show databases;'|grep realdb
Last 10 lines of output were:
# ./spec/acceptance/mysql_db_spec.rb:71:in `block (3 levels) in <top (required)>' It appears not to have been created: [root@centos-64-x64 ~]# mysql -e "show databases;"
+--------------------+
| Database |
+--------------------+
| information_schema |
| foo |
| mysql |
| spec_db |
| spec_latin1 |
| spec_utf8 |
| test |
| zergdb |
+--------------------+
[root@centos-64-x64 ~]# |
@igalic I'm not a ruby guy. Which command did you use for the testing? I tried rake spec:system, but got the following error (one of them, basic all tests failed):
Tried ruby 1.9.3, 2.0.0, 2.1.0. All the same. I'm on a mac. |
Found possible issue. Updated the tests. @igalic could you try again as I can't run acceptance tests on my machine? Thanks. |
Hmm... Travis had some issue connecting to github....https://travis-ci.org/puppetlabs/puppetlabs-mysql/jobs/20842834#L99
Will try to trigger the CI build again... |
When defining the mysql::db as exported resources, there are chances that the same resource names are defined across the site, which will cause puppet agent fail. By adding an optional dbname parameter, default to the $name, it allows the resouce name to be defined differently, e.g. ${dbname}_${domain}. Also updated test and docs for dbname parameter and add acceptance test for dbname parameter feature
This will allow exported resource mysql::db to define same database but different hostname and enables the cluster web nodes to declear the mysql::db and to be collected on db node.
This time is better~ |
I'm running acceptance tests like so: igalic@levix ~/src/puppet/puppetlabs-mysql (git)-[dbname] % RS_DEBUG=on RS_DESTROY=onpass ~/.gem/ruby/1.9.1/bin/bundle exec rspec spec/acceptance/
Hypervisor for centos-64-x64 is vagrant
Beaker::Hypervisor, found some vagrant boxes to create
[centos-64-x64] VM not created. Moving on...
created Vagrantfile for VagrantHost centos-64-x64
Bringing machine 'centos-64-x64' up with 'virtualbox' provider...
[centos-64-x64] Importing base box 'centos-64-x64-vbox4210-nocm'...
… |
wheeee works now! (on the default set).… I'm testing % RS_SET=ubuntu-server-12042-x64 RS_DEBUG=on RS_DESTROY=onpass ~/.gem/ruby/1.9.1/bin/bundle exec rspec spec/acceptance/ now too |
} | ||
ensure_resource('mysql_database', $dbname, $db_resource) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, I didn't notice this change before, but: Why are you doing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is in the second commit message:
This will allow exported resource mysql::db to define same database but different hostname and enables the cluster web nodes to declare the mysql::db and to be collected on db node.
People can define different users on the same database. Before it will trigger and duplicated resources error because the mysql_database[$dbname] is already defined.
Allow to use different name for db resource other than db name
When defining the mysql::db as exported resources, there are chances that the
same resource names are defined across the site, which will cause puppet agent
fail. By adding an optional dbname parameter, default to the $name, it allows the
resource name to be defined differently, e.g. ${dbname}_${domain}.