Hiera Mysql

MySQL back end for Hiera
Alternatives To Hiera Mysql
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Puppetlabs Mysql3851733 days ago79August 26, 202118apache-2.0Ruby
MySQL Puppet Module / Manifests + Types & Providers
Symfony2 Vagrant265
6 years ago17Puppet
Symfony2 Vagrant development setup with Nginx, MySQL,PhpMyAdmin, MongoDb and other handfull tools
Vagrant Php Box141
7 years ago15Puppet
Set up super fast a PHP5 development box with apache, mysql, phpmyadmin and whatever else that you may need
Wp Vagrant136
5 years ago2Puppet
WordPress Vagrant boxes for testing PHP 5.3, 5.4, and 5.5
Drupal Lxc Vagrant Docker94
7 years ago2Puppet
Deploy and develop on Drupal with LXC, Vagrant and Docker. Includes: nginx,php-fpm,apc,xhprof,mysql,phpmyadim,composer
3 years ago10mitJava
MySQL Metrics Plugin
Puppet Jira62
a year ago19April 23, 20218apache-2.0Ruby
Atlassian JIRA Puppet Module
Phalcon Vm44
4 years ago13mitJavaScript
Vagrant configuration for PHP7, Phalcon 3.x and Zephir development.
Yii2 Advanced With Vagrant43
9 years ago2PHP
Yii2 advanced app setup with Vagrant / Debian 7.1 / PHP 5.4
Vagrant Lamp Centos6338
9 years ago6PHP
Vagrant setup for CentOS 6.3 LAMP stack (Linux, Apache, MySQL and PHP).
Alternatives To Hiera Mysql
Select To Compare

Alternative Project Comparisons


This is hiera-mysql for Hiera 5 users (Puppet 4.9+) - if you are running older versions please see the 2.x branch for the hiera-mysql Hiera 3 backend

For more information on migrating to Hiera 5, See the official documentation


puppet module install crayfishx/hiera_mysql


Hiera-mysql supports both native C extensions for use with standard ruby and the jRuby JDBC and will load whichever library is suitable for the ruby it has been installed on. This ensures that hiera-mysql operates under puppet apply which uses regular Ruby and also under puppetserver which implements jRuby.

If you are using Hiera-mysql under jRuby for Puppet Server you will need to install the jdbc gem:

/opt/puppetlabs/bin/puppetserver gem install jdbc-mysql

If you are using Hiera-mysql under standard ruby (eg: for puppet apply), you will need the mysql gem

/opt/puppetlabs/puppet/bin/gem install mysql


Hiera-mysql 2.0.0 is the legacy backend to Hiera 3.x and shipped as a rubygem. Important fixes may still be contributed to the 2.x branch, however it's highly recommended that users switch to 3.x. Hiera-mysql 3.0.0 is a complete refactor designed to work as a Hiera 5 backend, for users running Puppet 4.9 or higher. Hiera-mysql 3.0.0 does not ship as a rubygem and should be used from the Puppet module.


Hiera is a configuration data store with pluggable back ends, hiera-mysql is a back end that fetches configuration valus from a MySQL/MariaDB database. It can be use instead of or along side other back ends.


There are two different ways to configure the mysql backend. You can configure it as a lookup_key or data_hash backend. The differences between these two types are documented in the official Hiera docs. lookup_key should be used to perform a MySQL query for each individual lookup request and return the value. data_hash should be used to perform one MySQL query per catalog compilation that returns a key value map for all data values. Examples of both methods can be found below.

Example database

In the following examples, the following database structure is being used;

MariaDB [config]> DESC configdata;
| Field       | Type      | Null | Key | Default | Extra          |
| id          | int(11)   | NO   | PRI | NULL    | auto_increment |
| val         | char(255) | YES  |     | NULL    |                |
| var         | char(255) | YES  |     | NULL    |                |
| environment | char(255) | YES  |     | NULL    |                |
4 rows in set (0.00 sec)

MariaDB [config]> select * from configdata;
| id | val         | var           | environment |
|  1 | | ntp::server   | production  |
|  2 |    | ntp::server   | development |
|  3 | Hello       | motd::message | production  |

Hiera configuration

The hiera-mysql backend takes the following for the options hash of the Hiera configuration

  • host: Hostname to connect to
  • username: Username to use for authentication
  • password: Password to use for authentication
  • database: Name of the MySQL database
  • query: The SQL query to run. The special keyword __KEY__ can be used to interpolate the lookup key into the query (only for lookup_key)
  • return: For use with the lookup_key type. When set to first will always return the first row even if the query returned multiple, when set to array will always return an array even if the query only returned one row.


The lookup_key type defines a query that should be run for each lookup request and expects to return one value. If the query returns multiple rows, then the first row will be returned. __KEY__ may be used in the query and will be interpolated as the lookup key.


  - name: "MySQL lookup"
    lookup_key: hiera_mysql
      host: localhost
      username: root
      password: foobar
      database: config
      query: "SELECT val FROM configdata WHERE var='__KEY__' AND environment='%{environment}'"


The lookup_type method can return arrays. By default, it will always return a string if one row is returned from the query, and will return an array when multiple rows are returned. You can be more explicit by setting the return option in the options hash to:

  • array: Always return an array, even if the query only returned one row.
  • first: Always return the first row as a string, even if the query returned multiple rows.


The data_hash type defines a query that should be run just once for each Puppet run. The query should be one that returns rows of two columns, the first column matching the key and the second with the value. Further column will be ignored.


  - name: "MySQL lookup"
    data_hash: hiera_mysql
      host: localhost
      username: root
      password: foobar
      database: config
      query: "SELECT var,val FROM configdata WHERE environment='%{environment}'"


Popular Mysql Projects
Popular Puppet Projects
Popular Data Storage Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.