【问题标题】:puppet recipe installing tarballpuppet recipe 安装 tarball
【发布时间】:2012-07-04 20:51:16
【问题描述】:

我想使用 puppet recipe 安装 apache maven,但我无法在任何地方找到如何执行此操作的示例。有人可以帮忙吗? Apache maven 打包为 tar.gz 文件。我正在为 puppet 使用独立设置。

【问题讨论】:

    标签: installation tar puppet recipe


    【解决方案1】:

    我使用来自example42的这个sn-p:

    define netinstall (
      $url,
      $extracted_dir,
      $destination_dir,
      $owner = "root",
      $group = "root",
      $work_dir = "/var/tmp",
      $extract_command = "tar -zxvf",
      $preextract_command = "",
      $postextract_command = ""
    ) {
      $source_filename = urlfilename($url)
    
      if $preextract_command {
          exec {
              "PreExtract $source_filename":
                  command => $preextract_command,
                  before  => Exec["Extract $source_filename"],
                  refreshonly => true,
          }
      }
    
      exec {
          "Retrieve $url":
              cwd     => "$work_dir",
              command => "wget $url",
              creates => "$work_dir/$source_filename",
              timeout => 3600,
      }
    
      exec {
          "Extract $source_filename":
              command => "mkdir -p $destination_dir && cd $destination_dir && $extract_command $work_dir/$source_filename",
              unless  => "find $destination_dir | grep $extracted_dir",
              creates => "${destination_dir}/${extracted_dir}",
              require => Exec["Retrieve $url"],
      }
    
      if $postextract_command {
          exec {
              "PostExtract $source_filename":
                  command => $postextract_command,
                  cwd => "$destination_dir/$extracted_dir",
                  subscribe => Exec["Extract $source_filename"],
                  refreshonly => true,
                  timeout => 3600,
                  require => Exec["Retrieve $url"],    
          }
      }
    }
    

    示例用法:

    #Install prerequisites
    exec { "VPSMonPrerequisites":
        command     => "yum install -y ${vpsmonitor::params::prerequisites}",
        unless      => "rpm -qi ${vpsmonitor::params::prerequisites}",
        timeout     => 3600,
    }
    #Install tgz from source url
    netinstall { vpsmonitor:
        url                 => "${vpsmonitor::params::source_url}",
        extracted_dir       => "${vpsmonitor::params::extracted_dir}",
        destination_dir     => "${vpsmonitor::params::destination_dir}",
        postextract_command => "chown -R user. ${vpsmonitor::params::destination_dir}/${vpsmonitor::params::extracted_dir}",
        require             => [ Exec["VPSMonPrerequisites"], User["user"] ],
    }
    

    【讨论】:

    • 这个例子对我来说打破了“urlfilename”。
    • 我能够通过执行“puppet module install example42-puppi”并将第二个示例用作“puppi::netinstall”来使其工作
    【解决方案2】:

    有一个 Puppet 模块可以为您完成这项工作:dsestero/download_uncompress

    例子:

    $phpstorm_version = '2017.2.1'
    
    download_uncompress { 'PhpStorm':
      download_base_url => 'https://download.jetbrains.com/webide',
      distribution_name => "PhpStorm-${phpstorm_version}.tar.gz",
      dest_folder       => '/opt',
      creates           => "/opt/phpstorm-${phpstorm_version}",
      uncompress        => 'tar.gz',
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-15
      • 2012-12-17
      • 2015-12-30
      • 1970-01-01
      • 2015-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多