File { ensure => directory, mode => "0755", } file { '/etc/puppetlabs/code/hieradata':; '/etc/puppetlabs/code/environments':; '/etc/puppetlabs/code/environments/production':; '/etc/puppetlabs/code/environments/production/manifests':; '/etc/puppetlabs/code/environments/production/modules':; '/etc/puppetlabs/code/environments/production/data':; '/etc/puppetlabs/code/environments/production/lib':; '/etc/puppetlabs/code/environments/production/lib/puppet':; '/etc/puppetlabs/code/environments/production/lib/puppet/functions':; '/etc/puppetlabs/code/environments/production/lib/puppet/functions/environment':; '/etc/puppetlabs/code/environments/production/functions':; '/etc/puppetlabs/code/environments/production/modules/hello':; '/etc/puppetlabs/code/environments/production/modules/hello/manifests':; '/etc/puppetlabs/code/environments/production/modules/hello/data':; '/etc/puppetlabs/code/environments/production/modules/hello/functions':; '/etc/puppetlabs/code/environments/production/modules/hello/lib':; '/etc/puppetlabs/code/environments/production/modules/hello/lib/puppet':; '/etc/puppetlabs/code/environments/production/modules/hello/lib/puppet/functions':; '/etc/puppetlabs/code/environments/production/modules/hello/lib/puppet/functions/hello':; } ## Global data provider config (hiera) file { '/etc/puppetlabs/code/hiera.yaml': ensure => file, mode => "0644", content => '--- :backends: - "yaml" - "yaml2" :logger: "console" :hierarchy: - "global" :yaml: :datadir: "/etc/puppetlabs/code/hieradata" :yaml2: :datadir: "/etc/puppetlabs/code/seconddata" ', } file { '/etc/puppetlabs/code/hieradata/global.yaml': ensure => file, mode => "0644", content => '--- global_key: "global-hiera provided value for key" another_global_key: "global-hiera provided value for key" ', } ## Evironment data provider configuration file { '/etc/puppetlabs/code/environments/production/environment.conf': ensure => file, mode => "0644", content => 'environment_timeout = 0 environment_data_provider = "hiera" ', } # Environment hiera data provider file { '/etc/puppetlabs/code/environments/production/hiera.yaml': ensure => file, mode => "0644", content => '--- version: 4 datadir: data hierarchy: -name: "default" backend: yaml path: "common.yaml" -name: "nodir" backend: yaml path: "nofile.yaml" ', } file { '/etc/puppetlabs/code/environments/production/data/common.yaml': ensure => file, mode => "0644", content => '--- global_key: "env-production hiera provided value" environment_key: "env-production hiera provided value" ', } file { '/etc/puppetlabs/code/environments/production/lib/puppet/functions/environment/data.rb': ensure => file, mode => "0644", content => "Puppet::Functions.create_function(:'environment::data') do def data() { 'environment_key': 'env-production-ruby-function data() provided value', 'global_key': 'env-production-ruby-function data () provided value', } end end ", } # Environment puppet function data provider file { '/etc/puppetlabs/code/environments/production/functions/data.pp': ensure => file, mode => "0755", content => 'function environment::data() { { "environment_key" => "env-production-puppet-function data() provided value", "global_key" => "env-production-puppet-function data() provided value", } } ', } ## Module data provider configuration # Module hiera data provider file { '/etc/puppetlabs/code/environments/production/modules/hello/hiera.yaml': ensure => file, mode => "0644", content => '--- version: 4 ', } file { '/etc/puppetlabs/code/environments/production/modules/hello/data/common.yaml': ensure => file, mode => "0644", content => '--- "hello::module_key": "module-production-hello-hiera provided value" "hello::global_key": "module-production-hello-hiera provided value" "environment_key": "module-production-hello-hiera provided value" "global_key": "module-production-hello-hiera provided value" ', } # Module ruby function data provider file { '/etc/puppetlabs/code/environments/production/modules/hello/lib/puppet/functions/hello/data.rb': ensure => file, mode => "0644", content => "Puppet::Functions.create_function(:'hello::data') do def data() { 'hello::module_key' => 'module-production-hello-ruby-function provided value', 'hello::global_key' => 'module-production-hello-ruby-function provided value', } end end ", } # Module puppet function data provider file { '/etc/puppetlabs/code/environments/production/modules/hello/functions/data.pp': ensure => file, mode => "0644", content => "function hello::data() { { 'hello::module_key' => 'module-production-hello-puppet-function provided value', 'hello::global_key' => 'module-production-hello-puppet-function provided value', } } ", } file { '/etc/puppetlabs/code/environments/production/manifests/site.pp': ensure => file, mode => "0644", content => "node default { include hello } ", } file { '/etc/puppetlabs/code/environments/production/modules/hello/manifests/init.pp': ensure => file, mode => "0644", content => 'class hello { notice("hello from production-hello") } ', } file { '/etc/puppetlabs/code/environments/production/modules/hello/metadata.json': ensure => file, mode => "0644", content => '{ "name": "tester-hello", "version": "0.1.0", "author": "tester", "summary": null, "license": "Apache-2.0", "source": "", "project_page": null, "issues_url": null, "dependencies": [], "data_provider": "hiera" } ', }