Skip to content

Instantly share code, notes, and snippets.

@deinspanjer
Last active January 4, 2016 03:39
Show Gist options
  • Save deinspanjer/8563208 to your computer and use it in GitHub Desktop.
Save deinspanjer/8563208 to your computer and use it in GitHub Desktop.
# in manifests/default.pp
define append_if_no_such_line($file, $line, $refreshonly = 'false') {
exec { "/bin/echo '$line' >> '$file'":
unless => "/bin/grep -Fxqe '$line' '$file'",
path => "/bin",
refreshonly => $refreshonly,
}
}
class must-have {
include apt
apt::ppa { "ppa:webupd8team/java": }
exec { 'apt-get update':
command => '/usr/bin/apt-get update',
before => Apt::Ppa["ppa:webupd8team/java"],
}
exec { 'apt-get update 2':
command => '/usr/bin/apt-get update',
require => [ Apt::Ppa["ppa:webupd8team/java"], Package["git-core"] ],
}
package { ["vim",
"curl",
"git-core",
"bash"]:
ensure => present,
require => Exec["apt-get update"],
before => Apt::Ppa["ppa:webupd8team/java"],
}
package { ["oracle-java7-installer"]:
ensure => present,
require => Exec["apt-get update 2"],
}
exec {
"accept_license":
command => "echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections && echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections",
cwd => "/home/vagrant",
user => "vagrant",
path => "/usr/bin/:/bin/",
require => Package["curl"],
before => Package["oracle-java7-installer"],
logoutput => true,
}
}
include hadoop
================================
# later on, in modules/hadoop:
class hadoop {
...
exec { "download_hadoop":
command => "/tmp/grrr /hadoop/common/hadoop-${hadoop_version}/$hadoop_tarball -O /vagrant/$hadoop_tarball --read-timeout=5 --tries=0",
timeout => 1800,
path => $path,
creates => "/vagrant/$hadoop_tarball",
require => [ Package["oracle-java7-installer"], Exec["download_grrr"]]
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment