2012-07-04 29 views
9

Tôi muốn cài đặt apache maven bằng cách sử dụng công thức con rối, nhưng tôi không thể tìm thấy bất cứ nơi nào một ví dụ về cách làm điều này. Có ai có thể giúp cho việc này không? Maven Apache được đóng gói dưới dạng tệp tar.gz. Tôi đang sử dụng một thiết lập độc lập cho con rối.công thức con rối cài đặt tarball

Trả lời

11

tôi sử dụng đoạn mã này từ example42:

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"],  
     } 
    } 
} 

ví dụ sử dụng:

#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"] ], 
} 
+0

Ví dụ này phá vỡ "urlfilename" cho tôi. – Jared

+0

Tôi đã có thể làm cho nó hoạt động bằng cách chỉ cần thực hiện "cài đặt mô-đun con rối example42-puppi" và chỉ sử dụng ví dụ thứ hai là "puppi :: netinstall" – Jared

0

Có một mô-đun Múa rối mà làm công việc này cho bạn: dsestero/download_uncompress

Ví dụ:

$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', 
} 
Các vấn đề liên quan