-
Notifications
You must be signed in to change notification settings - Fork 4
Opentable specific mods #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
forge 'https://forgeapi.puppetlabs.com' | ||
|
||
mod 'puppetlabs-stdlib', '>= 2.3.3 < 5.0.0' | ||
mod 'puppetlabs-stdlib', '>= 2.3.3 < 5.0.0' | ||
mod 'puppet/archive', '>= 0.5.0' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
function usage () { | ||
echo "usage: $0 znode_path" >&2 | ||
exit 1 | ||
} | ||
|
||
_znode="$1" | ||
|
||
[ -z $_znode ] && usage | ||
|
||
[[ $(echo "stat $_znode" | zkCli.sh 2>&1 >/dev/null) != \ | ||
*'Node does not exist:'* ]] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,11 @@ | |
# Should not be included directly | ||
# | ||
class zookeeper::install( | ||
$install_method = $zookeeper::install_method, | ||
$download_url = 'http://mirror.cogentco.com/pub/apache/zookeeper', | ||
$install_method = 'package', | ||
$mirror_url = 'http://mirror.cogentco.com/pub/apache', | ||
$archive_checksum = {}, | ||
$install_dir = '/opt/zookeeper', | ||
$package_dir = '/var/tmp/zookeeper', | ||
$ensure = present, | ||
$snap_retain_count = 3, | ||
$cleanup_sh = '/usr/lib/zookeeper/bin/zkCleanup.sh', | ||
|
@@ -34,6 +36,11 @@ | |
anchor { 'zookeeper::install::end': } | ||
|
||
if ($install_method == 'package') { | ||
$clean = $manual_clean | ||
$repo_source = is_hash($repo) ? { | ||
true => 'custom', | ||
false => $repo, | ||
} | ||
case $::osfamily { | ||
'Debian': { | ||
class { 'zookeeper::os::debian': | ||
|
@@ -67,37 +74,82 @@ | |
fail("Module '${module_name}' is not supported on OS: '${::operatingsystem}', family: '${::osfamily}'") | ||
} | ||
} | ||
} else { | ||
} elsif ($install_method == 'archive') { | ||
include '::archive' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this should be } else if ($install_method == 'archive') {
# ...
} else {
fail("you must select a valid installation method for zookeeper")
} |
||
|
||
$basefilename = "zookeeper-${ensure}.tar.gz" | ||
$package_url = "${mirror_url}/zookeeper/zookeeper-${ensure}/${basefilename}" | ||
$extract_path = "${install_dir}-${ensure}" | ||
|
||
if ($manual_clean == undef) { | ||
$clean = versioncmp($ensure, '3.4') ? { | ||
'-1' => true, | ||
default => false, | ||
} | ||
} else { | ||
$clean = $manual_clean | ||
} | ||
|
||
package { ['zookeeper','zookeeperd']: | ||
ensure => absent | ||
} | ||
|
||
file { $install_dir: | ||
ensure => link, | ||
target => "${install_dir}-${ensure}" | ||
} | ||
|
||
exec { 'download-zk-package': | ||
command => "/usr/bin/wget -O /tmp/zookeeper-${ensure}.tar.gz ${package_mirror}/zookeeper-${ensure}/zookeeper-${ensure}.tar.gz", | ||
creates => "/tmp/zookeeper-${ensure}.tar.gz" | ||
target => $extract_path | ||
} | ||
|
||
exec { 'install-zk-package': | ||
command => "/bin/tar -xvzf /tmp/zookeeper-${ensure}.tar.gz -C /opt", | ||
creates => "${install_dir}-${ensure}/zookeeper-${ensure}.jar", | ||
file { $package_dir: | ||
ensure => directory, | ||
owner => 'zookeeper', | ||
group => 'zookeeper', | ||
require => [ | ||
Exec['download-zk-package'] | ||
] | ||
Group['zookeeper'], | ||
User['zookeeper'], | ||
], | ||
} | ||
file { "${install_dir}-${ensure}": | ||
|
||
file { $extract_path: | ||
ensure => directory, | ||
recurse => true, | ||
owner => 'zookeeper', | ||
group => 'zookeeper' | ||
group => 'zookeeper', | ||
require => [ | ||
Group['zookeeper'], | ||
User['zookeeper'], | ||
], | ||
} | ||
|
||
archive { "${package_dir}/${basefilename}": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this resource There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe? The deb doesn't do a restart on upgrade. |
||
ensure => present, | ||
extract => true, | ||
extract_command => 'tar xfz %s --strip-components=1', | ||
extract_path => $extract_path, | ||
source => $package_url, | ||
checksum => $archive_checksum['hash'], | ||
checksum_type => $archive_checksum['type'], | ||
creates => "${extract_path}/conf", | ||
cleanup => true, | ||
user => 'zookeeper', | ||
group => 'zookeeper', | ||
require => [ | ||
File[$package_dir], | ||
File[$install_dir], | ||
Group['zookeeper'], | ||
User['zookeeper'], | ||
], | ||
} | ||
} else { | ||
fail("You must specify a valid install method for zookeeper") | ||
} | ||
|
||
file { '/usr/local/bin/znode_exists.sh': | ||
ensure => file, | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0755', | ||
source => 'puppet:///modules/zookeeper/znode_exists.sh', | ||
require => File['/usr/local/bin'], | ||
} | ||
|
||
class { 'zookeeper::post_install': | ||
ensure => $ensure, | ||
|
@@ -108,7 +160,7 @@ | |
datastore => $datastore, | ||
snap_retain_count => $snap_retain_count, | ||
cleanup_sh => $cleanup_sh, | ||
manual_clean => $manual_clean, | ||
manual_clean => $clean, | ||
require => Anchor['zookeeper::install::end'], | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,39 @@ | ||
define zookeeper::znode( | ||
$ensure = '', | ||
$assosiation = '' | ||
$association = '' | ||
) { | ||
|
||
|
||
validate_re($name, '^\/', "znode path must start with a '/'") | ||
if $name =~ /\/\.{1,2}(\/.*)?$/ { | ||
fail("znode name cannot be '.' or '..'") | ||
} | ||
|
||
$create_cmd = shellquote( | ||
'/bin/echo', | ||
"create ${name}", | ||
"\'${association}\'" | ||
) | ||
|
||
$rm_cmd = shellquote( | ||
'/bin/echo', | ||
"rmr ${name}" | ||
) | ||
|
||
if $ensure == 'present' { | ||
exec { "create znode ${name}": | ||
command => "/bin/echo \"create /${name} '${assosiation}'\" | ${zookeeper::install_dir}/bin/zkCli.sh", | ||
unless => "/bin/bash -c \"if [[ \\\"`echo 'ls /' | /opt/zookeeper/bin/zkCli.sh | tail -n2 | head -n1`\\\" == *${name}* ]]; then exit 0; else exit 1; fi\"" | ||
command => "${create_cmd} | zkCli.sh", | ||
unless => shellquote('znode_exists.sh', $name), | ||
path => "/usr/share/zookeeper/bin:${zookeeper::install_dir}/bin:/bin:/usr/bin:/usr/local/bin", | ||
require => Class['::zookeeper::install'], | ||
|
||
} | ||
} else { | ||
exec { "delete znode ${name}": | ||
command => "/bin/echo \"rmr /${name}\" | ${zookeeper::install_dir}/bin/zkCli.sh", | ||
unless => "/bin/bash -c \"if [[ \\\"`echo 'ls /' | /opt/zookeeper/bin/zkCli.sh | tail -n2 | head -n1`\\\" == *${name}* ]]; then exit 0; else exit 1; fi\"" | ||
command => "${rm_cmd} | zkCli.sh", | ||
onlyif => shellquote('znode_exists.sh', $name), | ||
path => "/usr/share/zookeeper/bin:${zookeeper::install_dir}/bin:/bin:/usr/bin:/usr/local/bin", | ||
require => Class['::zookeeper::install'], | ||
} | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using
stdlib/validate_bool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is validated in init.pp.
Preferable to move it into config.pp?