Search code examples
mysqldatabasepuppetpuppetlabs-mysql

Using Puppetlabs-mysql to allow more than one host


I am using Puppet v3.4.3 and Puppetlabs-mysql module v2.3.1 ( https://forge.puppetlabs.com/puppetlabs/mysql) to create database and I need to allow hosts localhost and % to use it. Both Puppet master and client run on Ubuntu-14.04 servers.

I use code like this:

mysql::db { 'mydb':
  user     => 'myuser',
  password => 'mypass',
  host     => 'localhost',
  grant    => ['SELECT', 'UPDATE'],
}

If I try to pass both hosts as an array they get combined together:

host => ['localhost', '%'],
Mysql users:
| user             | host              |
+------------------+-------------------+
| username         | localhost%        | 

If I try giving host-parameter twice I get error about duplicate declaration:

Error 400 on SERVER: Duplicate parameter 'host' for on Mysql::Db

Is what I want possible with this Puppet-module and if so how is it done?


Solution

  • You create one grant with your mysql::db, as in your first example. To allow the other host, you need to add a dedicated mysql::grant.