Version information
This version is compatible with:
- Puppet Enterprise >=3.4.3
- Puppet >=3.4.3
- , , , , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'hajee-connect', '0.0.24'
Learn more about managing modules with a PuppetfileDocumentation
####Table of Contents
- Overview
- Module Description - What Connect does and why it is useful
- Setup - The basics of getting started with connect
- Usage - Configuration options and additional functionality
- Troubleshooting
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
##Overview
Connect is a replacement for YAML in hiera. When you start with Puppet, using hiera with YAML is an excellent way to split code and configuration data. But when your configuration grows, you start to notice some troubles with this combination:
- Your YAML files start to become bigger and bigger and bigger and slowly but surely become incomprehensible.
- You would like to reference other values. YAML supports this..... but not between different files. Besides the
&
and*
anchor syntax becomes a hassle, when you use it much. - You have found the yaml interpolation using
"%{hiera('lookup_value')"
to lookup values over you whole YAML structure..... but noticed, you can only use this for strings, and not for other data types.
If you recognize any of these problems, Connect might be for you! If you haven't run into these problems, Connect is probably like taking a sledgehammer to crack a nut, and it is best to stay with YAML.
Want to know the details, Check the Connect Language, in a Nutshell, for more intro into the language.
##Module Description
Connect is a hiera
backend. Using the Connect language, you can describe your Puppet parameters in an simple and concise way. You can:
- separate your config files into separate files and include them when you need them.
- You can easily reference variables. These variables can be in any other configuration file. They can be in an included configuration, or they can be defined at another hiera hierarchy level.
- You can import data from other sources like PuppetDb and mix and match them with your own parameter settings.
- You can reference encrypted variables in a safe way.
...and much more.
##Example
domain_name = 'example.com'
import from puppetdb into datacenter:: {
ntp_servers = 'Class[Ntp::Server]' # Fetches all NTP nodes from puppetdb
# into the array datacenter::ntp_servers
dns_servers = 'Class[Dns::Server]' # Fetches all DNS nodes from puppetdb
# into the array datacenter::dns_servers
}
ftp_node = "ftp.${domain_name}"
all_nodes = [
ntp_servers,
dns_servers,
ftp_node,
]
include 'generic_settings/*' # include all settings
include "${domain_name}/settings" # include specific setting for domain
Check the Connect Language, in a Nutshell, for more intro into the language.
##Setup
###Installing the module
To use the connect hiera module, you first have to make sure it is installed.
puppet module install hajee/connect
If you are using a Puppetfile, you need the following lines:
mod 'hajee-connect'
###Enabling Connect in hiera
To start using the connect hiera backend, you have to enable it in the hiera config file. Add the connect
line to the :backends:
array. The order of the entries in the array, is the order hiera will use to resolve the lookups.
---
:backends:
- yaml
- connect
...
:connect:
:datadir: /etc/puppet/config
...
Add a :datadir:
entry for the connect backend. The default is /etc/puppet/config
.
###What connect affects
If you have configured connect, like specified in the hiera.yaml
ALL hiera lookups will be passed to the Connect backend.
###Setup Requirements
Because connect is based on hiera and puppet, you need to have both the hiera and puppet gem installed.
Some of the data sources require extra Ruby gems or other components. Check their documentation for details
###Beginning with connect module
To test if everything works, ue the next steps:
- add connect to the
hiera.yaml
. You can find an example here - Create a
common.config
in the folder/etc/puppet/config
. You can find an example here. - Create a
test.pp
with this content - Run the small test manifest and check the output
$ puppet apply test.pp
Notice: Scope(Class[Test]): it works
Notice: Compiled catalog for 10.0.2.15 in environment production in 0.20 seconds
Notice: Finished catalog run in 0.03 seconds
You can also use the values inpsector to check the value:
$ puppet connect values test::parameter
###Tools
The values inspector
Bundled with connect comes the values inspector. This tool lets you see the interpreted value of a specified parameter. In lay man's terms, it parses your connect file's and shows you the value.
$ puppet connect values my_parameter
You can also use a wildcard for the parameter. Wildcards are specified as regular expressions.
$ puppet connect values my_scope::.*
This will show all parameters in the scope my_scope
.
puppet connect values
will also show you where your parameters are defined and referenced. This is a tremendous help when debugging or just understand a complex set of connect configuration files.
The objects inspector
Similar to the values inspector, is the objects inspector This tool lets you see the interpreted value of a specified object. Just like the values inspector, it parses your connect file's and shows you the contents of your objects.
$ puppet connect objects my_node
You can also use a wildcard for the parameter. Wildcards are specified as regular expressions.
$ puppet connect objects my_*.
This will show all objects starting with my_
.
If you just want to see the objects of a certain type, use --type
or -t
$ puppet connect objects --type host my_*.
Will show you all just starting with my_
puppet connect objects
will also show you where your objects are defined and referenced. This is a tremendous help when debugging or just understand a complex set of connect configuration files.
###Using the accompanying Vagrant box
You can also get started with a Vagrant box that is preconfigured.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'hajee/centos-5.10-x86_64'...
==> default: Matching MAC address for NAT networking...
...
default: Running: inline script
==> default: Running provisioner: shell...
default: Running: inline script
==> default: Running provisioner: shell...
default: Running: inline script
$ vagrant ssh
Last login: Sun Dec 14 17:08:18 2014 from 10.0.2.2
$ sudo su - # Make yourself root
$ cd /vagrant/tests/ # Goto the folder containing the test manifest
$ puppet apply test.pp # Apply it.
Notice: Scope(Class[Test]): it works localhost
Notice: Compiled catalog for localhost.localdomain in environment production in 0.39 seconds
Notice: Finished catalog run in 0.03 seconds
$
On your host os, you can edit the `examples/default.config' file to experiment with the Connect language.
##detailed description
Check the Connect Language, in a Nutshell, for more intro into the language.
##Troubleshooting
If you make mistakes in the config files, Connect will show you a parse error. The parse error shows the file and the line number of the parse error. This should help you pinpoint any errors. The parsing of the connect files will be done once before the real puppet run starts. This ensures's Puppet can only start after it has made certain the Connect configs are syntactically correct
##Limitations
This module is tested CentOS and Redhat. It will probably work on other Linux distributions.
##Development
This is an open source project, and contributions are welcome.
###OS support
Currently we have tested:
- CentOS 5
- Redhat 5
###Testing
Make sure you have:
- rake
- bundler
Install the necessary gems:
bundle install
And run the tests from the root of the source code:
rake spec
We are currently working on getting the acceptance test running as well.
History
28-5-2017 version 0.0.24
- [docs] Added collection of objects to documentation
- [objects] Fix wildcard reference
- [core] Implement regexp object support
- [parser] Add support for regexp object titles
- [lexer] add support for regexp
- [core] Add late binding to interpolator
25-5-2016 version 0.0.23
- Fix errors when config file contains only comments
- Fix reporting of line numbers when using multi line assignments
20-5-2016 version 0.0.22
- Better debugging messages on assign
- Fixed some issue's with ruby incompatibility
30-10-2015 version 0.0.21
- Fixes to run on Puppet Enterprise 2015.2
- No more GEM distributions
30-10-2015 version 0.0.20
- Refresh lookups if search order changes
29-10-2015 version 0.0.19
- Refresh lookups if a config file has changed
25-10-2015 version 0.0.18
- Still support ruby 1.8.7
25-10-2015 version 0.0.17
- Added support for Hiera 2.0
25-10-2015 version 0.0.16
- Added support for building a GEM
24-10-2015 version 0.0.15
- Added support for jruby
23-07-2015 version 0.0.14
- Fixed some bugs in selectors on objects
11-06-2015 version 0.0.14
- Added slice-content selector
10-06-2015 version 0.0.13
- Added Object and Hash convenience function slice.
10-06-2015 version 0.0.12
- Fixed a bug when using a object reference in a hash inside an array
13-05-2015 version 0.0.11
- Added support for multiple named iterators
9-05-2015 version 0.0.10
- Implemented the object iterator
- Added the description of the object inspector to the readme
3-05-2015 version 0.0.9
- Extracted the datasources
- Fix error messages when using connect without a valid section in hiera.yaml
- Add support for data source names with underscores.
23-04-2015 version 0.0.8
- Add support for range syntax in selectors
- Add support for negative numbers and explicit positive numbers
- Add support for wildcard object searches
05-04-2015 version 0.0.7
- Added Puppet connect objects face to list objects
- object('name') is now different dfrom object(name). Without quotes is a reference
- awesome_print is no longer a requirement, but an add-on
03-04-2015 version 0.0.6
- Fixed a bug on interpreting Objects beyond the first level
- Unquoted object names are references
02-04-2015 version 0.0.5
- Fixed a bug on interpreting Hashes beyond the first level
02-04-2015 version 0.0.4
- Added cross referencing output to Puppetconnect values.
29-03-2015 version 0.0.3
- Added Puppet connect values commands to read the configs
24-03-2015 version 0.0.2
- Better support for selectors
- extended the language documentation
- better error messages when using selectors
- better error messages when using invalid attributes on objects
- allow selectors as integral part of the language. Now any value or reference can have a selector
11-03-2015 version 0.0.1
- Initial release