[Pkg-puppet-devel] [facter] 23/180: (FACT-375) Update install_utils from puppet project

Stig Sandbeck Mathisen ssm at debian.org
Mon Jun 30 15:06:27 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit 6b5f05265d9f535831ba495e5c760ae0cd02de2f
Author: Adrien Thebo <git at somethingsinistral.net>
Date:   Mon Mar 17 10:30:02 2014 -0700

    (FACT-375) Update install_utils from puppet project
---
 acceptance/lib/puppet/acceptance/install_utils.rb | 101 ++++++++++++++++++++++
 1 file changed, 101 insertions(+)

diff --git a/acceptance/lib/puppet/acceptance/install_utils.rb b/acceptance/lib/puppet/acceptance/install_utils.rb
index cca5b77..5df4235 100644
--- a/acceptance/lib/puppet/acceptance/install_utils.rb
+++ b/acceptance/lib/puppet/acceptance/install_utils.rb
@@ -49,6 +49,107 @@ module Puppet
         end
         return true
       end
+
+      def fetch(base_url, file_name, dst_dir)
+        FileUtils.makedirs(dst_dir)
+        src = "#{base_url}/#{file_name}"
+        dst = File.join(dst_dir, file_name)
+        if File.exists?(dst)
+          logger.notify "Already fetched #{dst}"
+        else
+          logger.notify "Fetching: #{src}"
+          logger.notify "  and saving to #{dst}"
+          open(src) do |remote|
+            File.open(dst, "w") do |file|
+              FileUtils.copy_stream(remote, file)
+            end
+          end
+        end
+        return dst
+      end
+
+      def stop_firewall_on(host)
+        case host['platform']
+        when /debian/
+          on host, 'iptables -F'
+        when /fedora|el-7/
+          on host, puppet('resource', 'service', 'firewalld', 'ensure=stopped')
+        when /el|centos/
+          on host, puppet('resource', 'service', 'iptables', 'ensure=stopped')
+        when /ubuntu/
+          on host, puppet('resource', 'service', 'ufw', 'ensure=stopped')
+        else
+          logger.notify("Not sure how to clear firewall on #{host['platform']}")
+        end
+      end
+
+      def install_repos_on(host, sha, repo_configs_dir)
+        platform = host['platform']
+        platform_configs_dir = File.join(repo_configs_dir,platform)
+
+        case platform
+          when /^(fedora|el|centos)-(\d+)-(.+)$/
+            variant = (($1 == 'centos') ? 'el' : $1)
+            fedora_prefix = ((variant == 'fedora') ? 'f' : '')
+            version = $2
+            arch = $3
+
+            rpm = fetch(
+              "http://yum.puppetlabs.com",
+              "puppetlabs-release-%s-%s.noarch.rpm" % [variant, version],
+              platform_configs_dir
+            )
+
+            pattern = "pl-puppet-%s-%s-%s%s-%s.repo"
+            repo_filename = pattern % [
+              sha,
+              variant,
+              fedora_prefix,
+              version,
+              arch
+            ]
+            repo = fetch(
+              "http://builds.puppetlabs.lan/puppet/%s/repo_configs/rpm/" % sha,
+              repo_filename,
+              platform_configs_dir
+            )
+
+            on host, "rm -rf /root/*.repo; rm -rf /root/*.rpm"
+
+            scp_to host, rpm, '/root'
+            scp_to host, repo, '/root'
+
+            on host, "mv /root/*.repo /etc/yum.repos.d"
+            on host, "rpm -Uvh --force /root/*.rpm"
+
+          when /^(debian|ubuntu)-([^-]+)-(.+)$/
+            variant = $1
+            version = $2
+            arch = $3
+
+            deb = fetch(
+              "http://apt.puppetlabs.com/",
+              "puppetlabs-release-%s.deb" % version,
+              platform_configs_dir
+            )
+
+            list = fetch(
+              "http://builds.puppetlabs.lan/puppet/%s/repo_configs/deb/" % sha,
+              "pl-puppet-%s-%s.list" % [sha, version],
+              platform_configs_dir
+            )
+
+            on host, "rm -rf /root/*.list; rm -rf /root/*.deb"
+
+            scp_to host, deb, '/root'
+            scp_to host, list, '/root'
+
+            on host, "mv /root/*.list /etc/apt/sources.list.d"
+            on host, "dpkg -i --force-all /root/*.deb"
+          else
+            host.logger.notify("No repository installation step for #{platform} yet...")
+        end
+      end
     end
   end
 end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list