Skip to content

@abhishekkr /$conf_dir hiera.yaml
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Puppet Module : No Code In Data ~ using Hiera with multiple backends
:backends:
- http
- redis
- yaml
- json
:http:
:host: testnode.testenv.abk
:port: 5984
:output: json
:failure: graceful
:paths:
- /config/%{::hostname}.json
- /config/%{::fqdn}.json
- /config/%{::environment}.json
- /config/%{::operatingsystem}.json
- /config/common.json
:redis:
:password: my_redis_password
:yaml:
:datadir: '/etc/puppet/hieradata/yaml'
:json:
:datadir: '/etc/puppet/hieradata/json'
:hierarchy:
- %{::hostname}
- %{::fqdn}
- %{::environment}
- %{::operatingsystem}
- common
:logger: console
{
"message": "It's better to use PuppetDB.",
"this_file": "/etc/puppet/hieradata/json/common.json"
}
---
public_data : "# created on CentOS"
this_file : "/etc/puppet/hieradata/yaml/CentOS.yaml"
---
public_file : "/tmp/notice"
public_data : "# created on any node"
this_file : "/etc/puppet/hieradata/yaml/common.yaml"
sed -i 's/^requirepass\s*\S*//g' /etc/redis.conf
REDIS_PASSWORD='my_redis_password'
echo "requirepass $REDIS_PASSWORD" >> /etc/redis.conf
/sbin/service redis restart
redis-cli -a $REDIS_PASSWORD <<'EOF'
set common:secret_file /etc/local.keys
set production:secret_file /etc/global.keys
KEYS *
EOF
{
"secret_data": "all the secret keys",
"this_file": "http://testnode.testenv.abk/config/mynode.json"
}
gem install hiera hiera-http hiera-puppet hiera-redis
cat > site.pp << EOF
\$public_file = hiera('public_file','/tmp/abc')
file{
\$public_file:
content => hiera('public_data','a2z'),
ensure => present,
}
\$secret_file = hiera('secret_file','/tmp/cba')
file{
\$secret_file:
content => hiera('secret_data','z2a'),
ensure => present,
}
\$msg = hiera('message', '')
notice(\$msg)
EOF
puppet apply --environment=testnode site.pp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.