diff --git a/data/common.yaml b/data/common.yaml index 5bb90a8..dedd6b9 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -2,7 +2,6 @@ classes: - base - ldapclient::ldapcert: | -----BEGIN CERTIFICATE----- MIIE7jCCA9agAwIBAgIJAKVPvcTSmTbFMA0GCSqGSIb3DQEBBQUAMIGqMQswCQYD diff --git a/data/ubuntu/1404.yaml b/data/ubuntu/1404.yaml index 6504c71..9a52308 100644 --- a/data/ubuntu/1404.yaml +++ b/data/ubuntu/1404.yaml @@ -1,13 +1,15 @@ --- - -classes: - - base - - dnsclient - - ldapclient - - subversionclient - - sudoers +classes: + - base ldapclient::ldapclient_packages: - ldap-auth-client - ldap-utils - libldap-2.4-2 + +base::basepackages: + - 'bash' + - 'ca_root_nss-3.15.5' + - 'git' + - 'zsh-5.0.5' + - 'apt-file' diff --git a/hiera.yaml b/hiera.yaml index b166baa..3b76d69 100644 --- a/hiera.yaml +++ b/hiera.yaml @@ -4,20 +4,20 @@ :backends: - - module_data - yaml - eyaml -# The ASF specific variables below are created in facter with customfact module. -:hierarchy: - - "%{clientcert}" - - "%{asf_osname}/%{asf_osrelease}" - - "colo/%{asf_colo}" - - "common" - :yaml: :datadir: /etc/puppet/data :eyaml: :datadir: /etc/puppet/data +# The ASF specific variables below are created in facter with customfact module. +:hierarchy: + - "nodes/%{clientcert}" + - "%{::asf_osname}/%{::asf_osrelease}" + - "colo/%{asf_colo}" + - "common" + +:logger: console diff --git a/manifests/site.pp b/manifests/site.pp index d15b92d..839123f 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -1,6 +1,4 @@ hiera_include("classes") -include customfact - node default { } diff --git a/modules/base/data/freebsd/100release.yaml b/modules/base/data/freebsd/100release.yaml deleted file mode 100644 index 1a33712..0000000 --- a/modules/base/data/freebsd/100release.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -base::base_packages: - - 'bash-4.3.0_1' - - 'ca_root_nss-3.15.5' - - 'git-1.9.0_1' - - 'zsh-5.0.5' diff --git a/modules/base/data/hiera.yaml b/modules/base/data/hiera.yaml deleted file mode 100644 index d23d5f3..0000000 --- a/modules/base/data/hiera.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -:hierarchy: - - "%{::asf_osname}/%{::asf_osrelease}" - - "common" diff --git a/modules/base/data/ubuntu/1404.yaml b/modules/base/data/ubuntu/1404.yaml deleted file mode 100644 index 97fad3f..0000000 --- a/modules/base/data/ubuntu/1404.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -base::base_packages: - - 'bash' - - 'ca_root_nss-3.15.5' - - 'git' - - 'zsh-5.0.5' - - 'apt-file' diff --git a/modules/base/manifests/init.pp b/modules/base/manifests/init.pp index 86d811f..2c101ad 100644 --- a/modules/base/manifests/init.pp +++ b/modules/base/manifests/init.pp @@ -1,12 +1,13 @@ #/usr/local/etc/puppet/modules/base/manifests/init.pp class base ( - $base_packages = [], + $basepackages = hiera('base::basepackages'), $pkgprovider = '', ) { - package { $base_packages: + package { $basepackages: ensure => installed, } } + diff --git a/modules/module_data/Modulefile b/modules/module_data/Modulefile deleted file mode 100644 index 5c05ad2..0000000 --- a/modules/module_data/Modulefile +++ /dev/null @@ -1,6 +0,0 @@ -name 'ripienaar-module_data' -version '0.0.3' -description 'A hiera backend to allow the use of data while writing sharable modules' -project_page 'https://github.com/ripienaar/puppet-module-data' -license 'ASL 2.0' -author 'R.I.Pienaar ' diff --git a/modules/module_data/README.md b/modules/module_data/README.md deleted file mode 100644 index d1409ec..0000000 --- a/modules/module_data/README.md +++ /dev/null @@ -1,61 +0,0 @@ -What? -===== - -While hiera does a decent job of separating code and data for users -it is quite difficult for module authors to use hiera to create reusable -modules. This is because the puppet backend is optional and even when -it is loaded the module author cannot influence the hierarchy. - -With this commit we add a new module_data backend that loads data from -within a module and allow the module author to set a hierarchy for this -data. - -The goal of this backend is to allow module authors to specify true -module default data in their modules but still allow users to override -the data using the standard method - especially useful with the puppet 3 -hiera integration. - -This backend is always loaded as the least important tier in the -hierarchy - unless a user choose to put it somewhere specific, but this -backend will always be enabled. - -Given a module layout: - - your_module - ├── data - │ ├── hiera.yaml - │ └── osfamily - │ ├── Debian.yaml - │ └── RedHat.yaml - └── manifests - └── init.pp - -The hiera.yaml is optional in this example it would be: - - --- - :hierarchy: - - osfamily/%{::osfamily} - - common - -But when no hiera.yaml exist in the module, the default would be: - - --- - :hierarchy: - - common - -The data directory is then a standard Hiera data store. - -Status? -------- - -This is but a first stab at turning my old pull request for ticket 16856 -into a standalone module that any > 3.0.0 Puppet user can depend on to -get this essential feature. - -Some more testing is needed, sanity checking for support versions etc so -consider this a early feedback-saught release - -Contact? --------- - -R.I.Pienaar / rip@devco.net / @ripienaar / http://devco.net diff --git a/modules/module_data/lib/hiera/backend/module_data_backend.rb b/modules/module_data/lib/hiera/backend/module_data_backend.rb deleted file mode 100644 index 5d4025b..0000000 --- a/modules/module_data/lib/hiera/backend/module_data_backend.rb +++ /dev/null @@ -1,91 +0,0 @@ -class Hiera - module Backend - class Module_data_backend - def initialize(cache=nil) - require 'yaml' - require 'hiera/filecache' - - Hiera.debug("Hiera Module Data backend starting") - - @cache = cache || Filecache.new - end - - def load_module_config(module_name, environment) - default_config = {:hierarchy => ["common"]} - - if mod = Puppet::Module.find(module_name, environment) - path = mod.path - module_config = File.join(path, "data", "hiera.yaml") - config = {} - - if File.exist?(module_config) - Hiera.debug("Reading config from %s file" % module_config) - config = load_data(module_config) - end - - config["path"] = path - - return default_config.merge(config) - else - return default_config - end - end - - def load_data(path) - return {} unless File.exist?(path) - - @cache.read(path, Hash, {}) do |data| - YAML.load(data) - end - end - - def lookup(key, scope, order_override, resolution_type) - answer = nil - - Hiera.debug("Looking up %s in Module Data backend" % key) - - unless scope["module_name"] - Hiera.debug("Skipping Module Data backend as this does not look like a module") - return answer - end - - config = load_module_config(scope["module_name"], scope["environment"]) - - unless config["path"] - Hiera.debug("Could not find a path to the module '%s' in environment '%s'" % [scope["module_name"], scope["environment"]]) - return answer - end - - config[:hierarchy].each do |source| - source = File.join(config["path"], "data", "%s.yaml" % Backend.parse_string(source, scope)) - - Hiera.debug("Looking for data in source %s" % source) - data = load_data(source) - - raise("Data loaded from %s should be a hash but got %s" % [source, data.class]) unless data.is_a?(Hash) - - next if data.empty? - next unless data.include?(key) - - found = data[key] - - case resolution_type - when :array - raise("Hiera type mismatch: expected Array or String and got %s" % found.class) unless [Array, String].include?(found.class) - answer ||= [] - answer << Backend.parse_answer(found, scope) - - when :hash - raise("Hiera type mismatch: expected Hash and got %s" % found.class) unless found.is_a?(Hash) - answer = Backend.parse_answer(found, scope).merge(answer || {}) - else - answer = Backend.parse_answer(found, scope) - break - end - end - - return answer - end - end - end -end diff --git a/modules/module_data/lib/puppet/indirector/data_binding/hiera.rb b/modules/module_data/lib/puppet/indirector/data_binding/hiera.rb deleted file mode 100644 index df8c8ba..0000000 --- a/modules/module_data/lib/puppet/indirector/data_binding/hiera.rb +++ /dev/null @@ -1,75 +0,0 @@ -require "hiera" -require "hiera/config" -require "hiera/scope" - -begin - require 'puppet/indirector/hiera' -rescue LoadError => e - begin - require "puppet/indirector/code" - rescue LoadError => e - $stderr.puts "Couldn't require either of puppet/indirector/{hiera,code}!" - end -end - - -class Hiera::Config - class << self - alias :old_load :load unless respond_to?(:old_load) - - def load(source) - old_load(source) - - @config[:backends] << "module_data" unless @config[:backends].include?("module_data") - - @config - end - end -end - -class Puppet::DataBinding::Hiera < Puppet::Indirector::Code - desc "Retrieve data using Hiera." - - def initialize(*args) - if ! Puppet.features.hiera? - raise "Hiera terminus not supported without hiera library" - end - super - end - - if defined?(::Psych::SyntaxError) - DataBindingExceptions = [::StandardError, ::Psych::SyntaxError] - else - DataBindingExceptions = [::StandardError] - end - - def find(request) - hiera.lookup(request.key, nil, Hiera::Scope.new(request.options[:variables]), nil, nil) - rescue *DataBindingExceptions => detail - raise Puppet::DataBinding::LookupError.new(detail.message, detail) - end - - private - - def self.hiera_config - hiera_config = Puppet.settings[:hiera_config] - config = {} - - if File.exist?(hiera_config) - config = Hiera::Config.load(hiera_config) - else - Puppet.warning "Config file #{hiera_config} not found, using Hiera defaults" - end - - config[:logger] = 'puppet' - config - end - - def self.hiera - @hiera ||= Hiera.new(:config => hiera_config) - end - - def hiera - self.class.hiera - end -end diff --git a/modules/module_data/metadata.json b/modules/module_data/metadata.json deleted file mode 100644 index 418dd0c..0000000 --- a/modules/module_data/metadata.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "author": "R.I.Pienaar ", - "description": "A hiera backend to allow the use of data while writing sharable modules", - "source": "UNKNOWN", - "checksums": { - "README.md": "3c2b5884ad51ef786b8613dd8e147e2b", - "Modulefile": "7cd4a28852f136be87acc5c71cc74a1f", - "lib/puppet/indirector/data_binding/hiera.rb": "9a67f431134c49f86fa686b116718806", - "lib/hiera/backend/module_data_backend.rb": "8f9da7dd8e7d02fb7beac72f187ad874" - }, - "name": "ripienaar-module_data", - "version": "0.0.3", - "project_page": "https://github.com/ripienaar/puppet-module-data", - "license": "ASL 2.0", - "dependencies": [ - - ], - "summary": "UNKNOWN", - "types": [ - - ] -} \ No newline at end of file diff --git a/puppet.conf b/puppet.conf index acf62b4..cae68f9 100755 --- a/puppet.conf +++ b/puppet.conf @@ -14,8 +14,8 @@ sslddir = /etc/puppet/ssl data_binding_terminus = hiera hiera_config = /etc/puppet/hiera.yaml #catalog_terminus = compiler - #facts_terminus = yaml - #inventory_terminus = yaml + facts_terminus = yaml + inventory_terminus = yaml #default_file_terminus = rest #httplog = /var/log/puppet/http.log #filetimeout = 15