39
35
if extra_packages is not None:
40
36
apt_install(extra_packages, fatal=True)
42
# Place default redis template
43
if os.path.exists('files/logstash.tar.gz'):
44
extract_package('files/logstash.tar.gz')
51
# finalize the installation and make sure logstash owns everything
52
subprocess.call(['chown', '-R', 'logstash', BASEPATH])
55
# TODO : Add flat file support
57
# Fetch the logstash binary
58
filename = config('logstash-source').split('/')[-1]
59
fpath = os.path.join(os.path.sep, 'tmp', filename)
61
if os.path.exists(fpath) and os.path.exists(BASEPATH):
62
log("Found LOGSTASH package, doing nothing")
65
with open(fpath, 'wb') as handle:
66
response = requests.get(config('logstash-source'), stream=True)
68
for block in response.iter_content(1024):
73
with open(fpath, 'r') as handle:
78
if sha.hexdigest() != str(config('logstash-sum')):
79
raise ValueError("Provided SUM does not match downloaded sum")
81
log("Verified {} with SHA1 sum of {}".format(filename,
84
# Extract and move into place
85
extract_package(filename)
88
def extract_package(filename):
89
t = tarfile.open(os.path.join(os.path.sep, 'tmp', filename))
90
t.extractall(path='.')
92
basename = filename.rsplit('.', 2)[0]
93
shutil.move(basename, BASEPATH)
96
44
def create_skeleton():
97
45
dirs = ['bin', 'conf.d', 'data']