-
Notifications
You must be signed in to change notification settings - Fork 12
/
zookeeper.json
141 lines (141 loc) · 8.49 KB
/
zookeeper.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
{
"_copyright": "2016-2022, Frederico Martins",
"_author": "Frederico Martins <http://github.com/fscm>",
"_license": "SPDX-License-Identifier: MIT",
"variables": {
"aws_access_key": "{{env `aws_access_key`}}",
"aws_ami_name": "zookeeper",
"aws_ami_name_prefix": "",
"aws_instance_type": "t2.micro",
"aws_region": "{{env `aws_region`}}",
"aws_secret_key": "{{env `aws_secret_key`}}",
"aws_ssh_username": "admin",
"java_build_number": "12",
"java_major_version": "8",
"java_token": "e758a0de34e24606bca991d704f6dcbf",
"java_update_version": "151",
"os_short_arch": "x64",
"system_locale": "en_US",
"zookeeper_uid": "2006",
"zookeeper_version": "{{env `zookeeper_version`}}"
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "{{user `aws_region`}}",
"instance_type": "{{user `aws_instance_type`}}",
"ssh_username": "{{user `aws_ssh_username`}}",
"associate_public_ip_address": true,
"ami_name": "{{user `aws_ami_name_prefix`}}{{user `aws_ami_name`}}-{{user `zookeeper_version`}}-({{isotime \"20060102150405\"}})",
"source_ami_filter": {
"filters": {
"architecture": "x86_64",
"name": "debian-jessie-*",
"root-device-type": "ebs",
"virtualization-type": "hvm"
},
"owners": ["379101102735"],
"most_recent": true
}
}],
"provisioners": [
{
"type": "file",
"source": "files/sysctl/",
"destination": "/tmp"
},
{
"type": "file",
"source": "files/systemd/",
"destination": "/tmp"
},
{
"type": "file",
"source": "files/zookeeper/",
"destination": "/tmp"
},
{
"type": "shell",
"inline_shebang": "/bin/bash -e",
"environment_vars": [
"DEBIAN_FRONTEND=noninteractive"
],
"inline": [
"unset HISTFILE",
"history -cw",
"echo === Waiting for Cloud-Init ===",
"timeout 180 /bin/bash -c 'until stat /var/lib/cloud/instance/boot-finished &>/dev/null; do echo waiting...; sleep 6; done'",
"echo === System Packages ===",
"echo 'deb http://ftp.debian.org/debian jessie-backports main contrib non-free' | sudo tee /etc/apt/sources.list.d/backports.list > /dev/null",
"sudo apt-get -qq update",
"sudo apt-get -y -qq install --no-install-recommends apt-transport-https apt-show-versions bash-completion logrotate ntp ntpdate htop vim wget curl dbus bmon nmon parted mawk wget curl sudo rsyslog ethtool unzip zip telnet tcpdump strace tar libyaml-0-2 lsb-base lsb-release xfsprogs sysfsutils",
"sudo apt-get -y -qq --purge autoremove",
"sudo apt-get autoclean",
"sudo apt-get clean",
"echo === System Settings ===",
"echo 'dash dash/sh boolean false' | sudo debconf-set-selections",
"sudo dpkg-reconfigure -f noninteractive dash",
"sudo update-locale LC_CTYPE={{user `system_locale`}}.UTF-8",
"echo 'export TZ=:/etc/localtime' | sudo tee /etc/profile.d/tz.sh > /dev/null",
"sudo update-alternatives --set editor /usr/bin/vim.basic",
"echo === Sysctl ===",
"sudo cp /tmp/50-zookeeper.conf /etc/sysctl.d/",
"sudo chown root:root /etc/sysctl.d/50-zookeeper.conf",
"sudo chmod 0644 /etc/sysctl.d/50-zookeeper.conf",
"sudo sysctl -p /etc/sysctl.d/50-zookeeper.conf",
"echo === Java ===",
"sudo mkdir /opt/java",
"curl -sL --retry 3 --insecure --header 'Cookie: oraclelicense=accept-securebackup-cookie;' 'http://download.oracle.com/otn-pub/java/jdk/{{user `java_major_version`}}u{{user `java_update_version`}}-b{{user `java_build_number`}}/{{user `java_token`}}/jre-{{user `java_major_version`}}u{{user `java_update_version`}}-linux-{{user `os_short_arch`}}.tar.gz' | sudo tar xz --strip-components=1 -C /opt/java/",
"sudo chown -R root:root /opt/java",
"echo 'export JAVA_HOME=/opt/java' | sudo tee /etc/profile.d/java.sh > /dev/null",
"sudo sed -i -r -e 's/#DefaultEnvironment/DefaultEnvironment/;/DefaultEnvironment/s/([^=])$/\\1 /;/DefaultEnvironment/s/$/\"JAVA_HOME=\\/opt\\/java\"/' /etc/systemd/system.conf",
"sudo gzip -r /opt/java/man/man1",
"for program in /opt/java/bin/*; do name=${program##*/}; manpage=''; [[ -f /opt/java/man/man1/${name}.1.gz ]] && manpage=\"--slave /usr/share/man/man1/${name}.1.gz ${name}.1.gz /opt/java/man/man1/${name}.1.gz\"; [[ -x ${program} && ! -L ${program} ]] && sudo update-alternatives --install /usr/bin/${name} ${name} /opt/java/bin/${name} 1 ${manpage}; done",
"echo === Zookeeper ===",
"sudo groupadd -g {{user `zookeeper_uid`}} zookeeper",
"sudo useradd -m -u {{user `zookeeper_uid`}} -g {{user `zookeeper_uid`}} -c 'Apache Zookeeper' -s /bin/bash -d /srv/zookeeper zookeeper",
"curl -sL --retry 3 --insecure 'https://archive.apache.org/dist/zookeeper/zookeeper-{{user `zookeeper_version`}}/zookeeper-{{user `zookeeper_version`}}.tar.gz' | sudo tar xz --strip-components=1 -C /srv/zookeeper/",
"sudo mkdir -p /data/zookeeper",
"sudo mkdir -p /var/{log,run}/zookeeper",
"sudo ln -s /var/log/zookeeper /srv/zookeeper/logs",
"sudo ln -s /data/zookeeper /srv/zookeeper/data",
"sudo cp /srv/zookeeper/conf/zoo_sample.cfg /srv/zookeeper/conf/zoo.cfg",
"sudo sed -i -r -e '/^dataDir/s/=.*/=\\/data\\/zookeeper/' /srv/zookeeper/conf/zoo.cfg",
"sudo sed -i -r -e '/^clientPort/s/=.*/=2181/' /srv/zookeeper/conf/zoo.cfg",
"sudo sed -i -r -e 's/# *maxClientCnxns/maxClientCnxns/;/^maxClientCnxns/s/=.*/=100/' /srv/zookeeper/conf/zoo.cfg",
"sudo sed -i -r -e 's/# *autopurge.snapRetainCount/autopurge.snapRetainCount/;/^autopurge.snapRetainCount/s/=.*/=50/' /srv/zookeeper/conf/zoo.cfg",
"sudo sed -i -r -e 's/# *autopurge.purgeInterval/autopurge.purgeInterval/;/^autopurge.purgeInterval/s/=.*/=3/' /srv/zookeeper/conf/zoo.cfg",
"sudo sed -i -r -e 's/# *log4j.appender.ROLLINGFILE.MaxFileSize/log4j.appender.ROLLINGFILE.MaxFileSize/;/^log4j.appender.ROLLINGFILE.MaxFileSize/s/=.*/=10MB/' /srv/zookeeper/conf/log4j.properties",
"sudo sed -i -r -e 's/# *log4j.appender.ROLLINGFILE.MaxBackupIndex/log4j.appender.ROLLINGFILE.MaxBackupIndex/;/^log4j.appender.ROLLINGFILE.MaxBackupIndex/s/=.*/=10/' /srv/zookeeper/conf/log4j.properties",
"echo \"JVMFLAGS=\\\"\\$JVMFLAGS -Xmx\\$(/usr/bin/awk '/MemTotal/{m=\\$2*.65;print int(m)\\\"k\\\"}' /proc/meminfo)\\\"\" | sudo tee -a /srv/zookeeper/conf/java.env > /dev/null",
"echo -e 'JMXLOCALONLY=false\nJMXPORT=7199\nJMXAUTH=false\nJMXSSL=false' | sudo tee -a /srv/zookeeper/conf/java.env > /dev/null",
"echo -e 'ZOO_LOG4J_PROP=\"INFO,ROLLINGFILE\"\\nZOO_LOG_DIR=\"/var/log/zookeeper\"\\nZOOPIDFILE=\"/var/run/zookeeper/zookeeper.pid\"\\nZOOCFGDIR=\"/srv/zookeeper/conf\"' | sudo tee -a /srv/zookeeper/conf/zookeeper-env.sh > /dev/null",
"echo 1 | sudo tee /data/zookeeper/myid > /dev/null",
"sudo chown -R zookeeper:zookeeper /srv/zookeeper /data/zookeeper /var/log/zookeeper /var/run/zookeeper",
"sudo cp /tmp/zookeeper.service /lib/systemd/system/",
"sudo systemctl daemon-reload",
"sudo systemctl disable zookeeper.service",
"sudo cp /tmp/zookeeper_config /usr/local/bin/",
"sudo chown root:staff /usr/local/bin/zookeeper_config",
"sudo chmod 0755 /usr/local/bin/zookeeper_config",
"echo === Extra System Settings ===",
"sudo sed -r -i -e 's/.*(GRUB_CMDLINE_LINUX_DEFAULT)=\"(.*)\"/\\1=\"\\2 elevator=deadline\"/' /etc/default/grub",
"sudo update-grub2",
"echo === System Cleanup ===",
"sudo rm -f /root/.bash_history",
"sudo rm -f /home/{{user `aws_ssh_username`}}/.bash_history",
"sudo rm -f /var/log/wtmp",
"sudo rm -f /var/log/btmp",
"sudo rm -rf /var/log/installer",
"sudo rm -rf /var/lib/cloud/instances",
"sudo rm -rf /tmp/* /var/tmp/* /tmp/.*-unix",
"sudo find /var/cache -type f -delete",
"sudo find /var/log -type f | while read f; do echo -n '' | sudo tee $f > /dev/null; done;",
"sudo find /var/lib/apt/lists -not -name lock -type f -delete",
"sudo sync",
"echo === All Done ==="
]
}
]
}