Skip to content

Instantly share code, notes, and snippets.

I want to define this in YAML:
ListenIP => '1.2.3.4',
ServerAlias => ['example.com', 'foo.example.com'],
config => 'DocumentRoot /var/www/sites/example
<Directory /var/www/sites/example/>
AllowOverride None
Options +Indexes
</Directory>'
irb(main):028:0> puts ({'ListenIP' => '1.2.3.4',
irb(main):029:2* 'ServerAlias' => ['example.com', 'foo.example.com'],
irb(main):030:2* 'config' => 'DocumentRoot /var/www/sites/example
irb(main):031:2' <Directory /var/www/sites/example/>
irb(main):032:2' AllowOverride None
irb(main):033:2' Options +Indexes
irb(main):034:2' </Directory>'}).to_yaml
---
config: |-
DocumentRoot /var/www/sites/example
---
:backends: - yaml
:logger: console
:hierarchy: - nodes/%{::hostname}
- %{::environment}
- common
:yaml:
:datadir: /opt/hieradata
I have a three-level hiera config: common, environment, node
I was under the impression I could define parts of an hash at each level and hiera would merge them.
ie. given this config:
common.yaml:
---
network:
forward_ipv4: false
module Puppet::Parser::Functions
newfunction(:hiera_hash, :type => :rvalue) do |*args|
if args[0].is_a?(Array)
args = args[0]
end
key = args[0]
default = args[1]
override = args[2]
class mod_jk::config{
require
::mod_jk::install
include
::apache::configfile
apache::confdfile{'mod_jk.conf':
source => 'puppet:///modules/mod_jk/mod_jk.conf'
class mod_jk::config::workers{
include
::concat::setup
$file = '/etc/httpd/conf/workers.properties'
concat{$file:
notify => Class['::apache::service']
}
Assume a two-level hiera config (common and nodename).
I have this in common.yaml:
sysctl:
hugepages:
buffer: 4194304
pagesize: 2048
I want to override buffer for a specific node foo, so I have this in foo.yaml:
DEVICE=bond0
ONBOOT=yes
BONDING_OPTS="miimon=80 mode=4"
TYPE=Ethernet
BOOTPROTO=none
-------------------------------
DEVICE=bond0.16
ONBOOT=yes
BRIDGE=vbr16
HOTPLUG=no
--- pre_install_network_config.orig 2012-12-06 00:05:26.934919988 +0000
+++ pre_install_network_config 2012-12-06 00:02:07.705104070 +0000
@@ -84,7 +84,8 @@
#end if
#end for
#end if
- #if $static and $ip != ""
+ #if $static == "True"
+ #if $ip != ""
#if $netmask == ""