Forge Home

hiera_mssql

Hiera 5 backend for MsSQL

5,585 downloads

5,585 latest version

4.3 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

Version information

  • 0.3.0 (latest)
released Sep 18th 2017
This version is compatible with:
  • Puppet Enterprise 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >= 4.0.0 < 5.0.0
  • RedHat, CentOS

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'laura-hiera_mssql', '0.3.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add laura-hiera_mssql
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install laura-hiera_mssql --version 0.3.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

laura/hiera_mssql — version 0.3.0 Sep 18th 2017

MsSQL backend for Hiera 5

Requirements

# ls -l /opt/rubylibs/lib/mssql-jdbc-6.2.1.jre8.jar
-rw-r--r-- 1 root root 1028744 Aug  9 19:11 /opt/rubylibs/lib/mssql-jdbc-6.2.1.jre8.jar
  • Install jdbc-mssql and java gems with Puppetserver
puppetserver gem install jdbc-sqlserver
puppetserver gem install java
  • Install tiny_tds gem with vendored Ruby
/opt/puppetlabs/puppet/bin/gem install tiny_tds
  • Set up a MsSQL database:
MsSQL [hiera]> select * from hieradata where var = 'message';
+-------+--------------+--------------+----------------------+
| id    |  variable    |  value       |    scope             |
+-------+--------------+--------------+----------------------+
| 1     | message      | Hello world! | laura.puppetlabs.com |
+-------+--------------+--------------+----------------------+
1 row in set (0.01 sec)

Name of columns are customizable. Variable have to be unique for each scope.

Create an user with read permissions to our table.

  • Configure hiera.yaml, each level of the hierarchy will have similar data, the only field that will change will be scope.

Facts and strings can be used for scope, an example with trusted certname and common:

  - name: "MsSQL Per Node Data"
    lookup_key: mssql_lookup_key
    options:
      host: mssql.puppetlabs.com
      user: hiera
      pass: hiera123
      database: hiera
      port: 12345
      # query = select %{value_field} from %{table} where %{key_field}="%{key}"
      table: configdata
      value_field: val
      key_field: var
      scope_field: scope
      scope: "%{trusted.certname}"
  - name: "MsSQL Common Data"
    lookup_key: mssql_lookup_key
    options:
      host: mssql.puppetlabs.com
      user: hiera
      pass: hiera123
      database: hiera
      port: 12345
      table: configdata
      value_field: val
      key_field: var
      scope_field: scope
      scope: "common"
`
  • You're all ready to go

Internals

The hiera backend works by querying the data with this query:

select * from %{table} where %{key_field}="%{key}" and %{scope_field}="%{scope}"

Using the information in the example above:

select * from hieradata where variable="message" and scope="laura.puppetlabs.com"

Defaults

The default values for the options are:

host: localhost
user: hiera
database: hiera
port: 1433
table: hiera
value_field: value
key_field: key
scope_field: scope
scope: common

Password is required.