使用puppet从tarball安装包

时间:2016-12-16 14:53:40

标签: activemq puppet

我尝试使用puppet安装ActiveMQ。这个包裹有焦油球。如何确保从puppet中推送(递归)每个文件,并确保服务正在运行。因为它在' bin中有自己的可执行文件。 DIR。

1 个答案:

答案 0 :(得分:0)

我想问一下从Tarball安装activemq是否必不可少?作为一个软件包管理它可能更容易,例如yum或apt install。

管理tarball总是比较困难,特别是在更新版本或处理下载失败等问题时。

我建议使用伪造的现有activemq模块:

https://forge.puppet.com/modules?utf-8=%E2%9C%93&sort=latest_release&q=activemq

为了让您大致了解它的外观,下面是一些可行的基本代码:

  $activemq_home = "/usr/local/activemq"

  package{"java-1.6.0-openjdk":
    ensure => installed;
  }

  $activemq_version = "5.4.3"

  user {"activemq":
    ensure => present,
    home => $activemq_home,
    managehome => false,
    shell => "/bin/sh",
  }

  group {"activemq":
    ensure => present,
    require => User["activemq"],
  }

  Exec{path => ["/usr/local/bin","/usr/bin","/bin"]}

  $puppet_cache = "/usr/local/src/gitorious"

  file {$puppet_cache:
    ensure => directory,
    owner => "root",
    group => "root",
  }

  exec { 'download_amq_src': 
    unless  => '/usr/bin/test -e ${activemq_home}/apache-activemq-${amq_version}-bin.tar.gz',
    command => 'cd /tmp && /usr/bin/wget http://archive.apache.org/dist/activemq/apache-activemq/${amq_version}/apache-activemq-${amq_version}-bin.tar.gz',     
    require => File[$activemq_home], 
}

# Unpack the archive in the amq user directory
exec { 'unpack_amq_src':
    onlyif  => '/usr/bin/test -d ${activemq_home}/apache-activemq-${amq_version}-bin',
    command => 'cd $amq_home && /bin/tar -xf /tmp/apache-activemq-${amq_version}-bin.tar.gz',
    require => Exec['download_amq'],
}

  file {"/etc/init.d/activemq":
    ensure => file,
    mode => 755,
    owner => "root",
    group => "root",
    content => template("activemq/etc/init.d/activemq.erb"),
    require => File["/etc/activemq.conf"],
  }

  service{"activemq":
    enable => true,
    ensure => running,
    require => File["/etc/init.d/activemq"],
  }

  file { "activemq.xml":
    path => "$activemq_home/conf/activemq.xml",
    ensure => present,
    mode => 644,
    owner => "activemq",
    group => "activemq",
    content => template("activemq/activemq.xml.erb"),
    require => File["/etc/init.d/activemq"],
    notify => Service["activemq"],
  }