Skip to content

Instantly share code, notes, and snippets.

@endzyme
Last active December 22, 2015 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save endzyme/f41f2e049b21872f7ce0 to your computer and use it in GitHub Desktop.
Save endzyme/f41f2e049b21872f7ce0 to your computer and use it in GitHub Desktop.
Puppet Hiera Intro - Getting Started (Basic output example)
---
ntp::service_enable: false
ntp::service_ensure: 'stopped'
apache::default_vhost: false
apache::vhosts:
'subdomain.loc':
priority: 1
port: '80'
docroot: '/var/www/newdir'
'subdomain2.loc':
priority: 2
port: 8080
docroot: '/var/www/somethingelse'
---
ntp::service_enable: true
ntp::service_ensure: 'running'
ntp::autoupdate: false
ntp::servers:
- 0.us.pool.ntp.org
- 1.us.pool.ntp.org
---
:backends:
- yaml
:yaml:
:datadir: /etc/puppet/manifests/data
:hierarchy:
- %{::clientcert}
- %{::environment}
- common
:logger: console
---
ntp::autoupdate: true
ntp::servers:
- '0.us.pool.ntp.org'
- '1.us.pool.ntp.org'
- '2.us.pool.ntp.org'
- '3.us.pool.ntp.org'
---
ntp::service_enable: true
ntp::service_ensure: 'running'
ntp::autoupdate: true
ntp::servers:
- ntp.ubuntu.com
node /ntp(\d+)?.localhost/ {
include ntp
}
node /apache(\d+)?.localhost/ {
include ntp
include apache
$resource = hiera('apache::vhosts')
create_resources('apache::vhost', $resource)
}
for i in `find . -name '*.yaml'` ;do echo $i ; ruby -e "require 'yaml'; YAML.parse(File.open('$i'))" ;done
#!/usr/bin/env ruby
require 'yaml'
exit_code = 0
if ARGV.length != 1
puts "Usage: ruby validate_ymls.rb directory_absolute_path"
exit!
end
base_path = ARGV[0].chomp("/")
base_dir = Dir.glob("#{base_path}/**/*.yaml") + Dir.glob("#{base_path}/**/*.yml")
base_dir.each do |file_name|
#puts "validating #{file_name}"
begin
env_constants = YAML::load(open(file_name))
rescue Exception => e
puts "ERROR!!! #{file_name} contains error! Message: #{e.message}"
exit_code = 1
end
end
if exit_code == 0
puts "No Errors Detected in loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment