Puppet Class: zookeeper::server

Defined in:
modules/zookeeper/manifests/server.pp

Overview

Parameters:

  • jmx_port (Any) (defaults to: 9998)
  • java_opts (Any) (defaults to: undef)
  • cleanup_script (Any) (defaults to: '/usr/share/zookeeper/bin/zkCleanup.sh')
  • cleanup_script_args (Any) (defaults to: '-n 10 > /dev/null')
  • cleanup_cron_deploy (Any) (defaults to: true)
  • default_template (Any) (defaults to: 'zookeeper/zookeeper.default.erb')
  • log4j_template (Any) (defaults to: 'zookeeper/log4j.properties.erb')


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'modules/zookeeper/manifests/server.pp', line 18

class zookeeper::server(
    $jmx_port            = 9998,
    $java_opts           = undef,
    $cleanup_script      = '/usr/share/zookeeper/bin/zkCleanup.sh',
    $cleanup_script_args = '-n 10 > /dev/null',
    $cleanup_cron_deploy = true,
    $default_template    = 'zookeeper/zookeeper.default.erb',
    $log4j_template      = 'zookeeper/log4j.properties.erb',
) {
    # need zookeeper common package and config.
    Class['zookeeper'] -> Class['zookeeper::server']

    # Install zookeeper server package
    package { 'zookeeperd':
        ensure    => $::zookeeper::version,
    }

    file { '/etc/default/zookeeper':
        content => template($default_template),
        require => Package['zookeeperd'],
    }

    file { '/etc/zookeeper/conf/log4j.properties':
        content => template($log4j_template),
        require => Package['zookeeperd'],
    }

    file { $::zookeeper::data_dir:
        ensure => 'directory',
        owner  => 'zookeeper',
        group  => 'zookeeper',
        mode   => '0755',
    }

    # Get this host's $myid from the $fqdn in the $zookeeper_hosts hash.
    $myid = $::zookeeper::hosts[$::fqdn]
    file { '/etc/zookeeper/conf/myid':
        content => $myid,
    }
    file { "${::zookeeper::data_dir}/myid":
        ensure => 'link',
        target => '/etc/zookeeper/conf/myid',
    }

    service { 'zookeeper':
        ensure     => running,
        require    => [
            Package['zookeeperd'],
            File[ $::zookeeper::data_dir],
            File["${::zookeeper::data_dir}/myid"],
            File['/etc/default/zookeeper'],
            File['/etc/zookeeper/conf/zoo.cfg'],
            File['/etc/zookeeper/conf/myid'],
            File['/etc/zookeeper/conf/log4j.properties'],
        ],
        hasrestart => true,
        hasstatus  => true,
    }

    $cleanup_cron_ensure = $cleanup_cron_deploy ? {
        true    => 'present',
        default => 'absent',
    }

    cron { 'zookeeper-cleanup':
        ensure  => $cleanup_cron_ensure,
        command => "${cleanup_script} ${cleanup_script_args}",
        minute  => 10,
        hour    => 0,
        user    => 'zookeeper',
        require => Service['zookeeper'],
    }
}