Last active
December 20, 2015 12:39
-
-
Save abhishekkr/6133012 to your computer and use it in GitHub Desktop.
Puppet Module : No Code In Data ~ using Hiera with multiple backends
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "message": "It's better to use PuppetDB.", | |
| "this_file": "/etc/puppet/hieradata/json/common.json" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| public_data : "# created on CentOS" | |
| this_file : "/etc/puppet/hieradata/yaml/CentOS.yaml" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| public_file : "/tmp/notice" | |
| public_data : "# created on any node" | |
| this_file : "/etc/puppet/hieradata/yaml/common.yaml" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "secret_data": "all the secret keys", | |
| "this_file": "http://testnode.testenv.abk/config/mynode.json" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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