【问题标题】:Install a package from tarball using puppet使用 puppet 从 tarball 安装包
【发布时间】:2016-12-20 05:26:26
【问题描述】:

我正在尝试使用 puppet 安装 ActiveMQ。这个包有 tar 球。如何确保每个文件都从 puppet 推送(递归)并确保服务正在运行。因为它在“bin”目录中有自己的可执行文件。

【问题讨论】:

  • 阅读fileexecservice资源的文档。

标签: activemq puppet


【解决方案1】:

我会问是否必须从 Tarball 安装 activemq?作为一个包进行管理可能会更容易,例如 yum 或 apt install。

管理 tarball 总是会变得更加困难,尤其是在更新版本或处理下载失败等问题时。

我建议使用来自 forge 的现有 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"],
  }

【讨论】:

  • 非常感谢,这真的很有帮助。 :)
猜你喜欢
  • 2012-07-04
  • 2012-01-24
  • 1970-01-01
  • 1970-01-01
  • 2012-12-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-15
相关资源
最近更新 更多