From da663d987ec8bd5fd719429c4844fc3eb4122338 Mon Sep 17 00:00:00 2001 From: Ryan Hall Date: Fri, 15 Sep 2017 16:34:04 -0400 Subject: [PATCH 1/2] Update custom provider Fix puppet package resource and return valid data from the te_agent_bin provider. --- lib/puppet/provider/package/te_agent_bin.rb | 30 ++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/package/te_agent_bin.rb b/lib/puppet/provider/package/te_agent_bin.rb index 441bc9b..965542a 100755 --- a/lib/puppet/provider/package/te_agent_bin.rb +++ b/lib/puppet/provider/package/te_agent_bin.rb @@ -14,16 +14,41 @@ has_feature :versionable has_feature :install_options + confine :osfamily => [ :RedHat ] + confine :exists => "/etc/init.d/twdaemon" + def self.prefetch(packages) packages.each do |name, pkg| version = get_version(pkg) - pkg.provider = new({:ensure => version, :name => name, :provider => :te_agent_bin}) if version + pkg.provider = new({:name => name, :ensure => version, :provider => :te_agent_bin}) if version end end + def self.instances + paths = [] + versions = [] + File.open('/etc/init.d/twdaemon').each_line do |r| + next if r.match(/^#/) + pathn = r.sub(/bin.*/, 'data/version') + npath = pathn.rstrip! + paths.push(npath) + end + paths.each do |path| + vfile = File.open("#{path}") + vfile.each_line do |v| + versionr = /\d.\d.\d/.match(v).to_s + versions.push(versionr) + end + end + versions.each.collect do |version| + new(:name => 'te_agent', :ensure => version, :provider => :te_agent_bin) + end + end + + def query version = get_version - version ? {:ensure => version, :name => resource[:name], :provider => :te_agent_bin} : nil + version ? {:name => resource[:name], :ensure => version, :provider => :te_agent_bin} : nil end def install @@ -82,7 +107,6 @@ def install_options def join_options(options) return unless options - options.collect do |val| case val when Hash From bc21384fc68559c1f0d6bd9a528391183e2d3256 Mon Sep 17 00:00:00 2001 From: Ryan Hall Date: Sat, 16 Sep 2017 15:05:40 -0400 Subject: [PATCH 2/2] Update te_agent_bin.rb --- lib/puppet/provider/package/te_agent_bin.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/puppet/provider/package/te_agent_bin.rb b/lib/puppet/provider/package/te_agent_bin.rb index 965542a..1d83bfa 100755 --- a/lib/puppet/provider/package/te_agent_bin.rb +++ b/lib/puppet/provider/package/te_agent_bin.rb @@ -14,9 +14,6 @@ has_feature :versionable has_feature :install_options - confine :osfamily => [ :RedHat ] - confine :exists => "/etc/init.d/twdaemon" - def self.prefetch(packages) packages.each do |name, pkg| version = get_version(pkg) @@ -45,7 +42,6 @@ def self.instances end end - def query version = get_version version ? {:name => resource[:name], :ensure => version, :provider => :te_agent_bin} : nil