Skip to content

Instantly share code, notes, and snippets.

@phips
Last active August 29, 2015 13:56
Show Gist options
  • Save phips/9077981 to your computer and use it in GitHub Desktop.
Save phips/9077981 to your computer and use it in GitHub Desktop.
Install Kibana into Vagrant box
---
- hosts: default
gather_facts: false
sudo: true
vars:
kibana: https://download.elasticsearch.org/kibana/kibana/kibana-3.1.0.tar.gz
kbver: 3.1.0
es: https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.noarch.rpm
ls: https://download.elasticsearch.org/logstash/logstash/packages/centos/logstash-1.4.2-1_2c0f5a1.noarch.rpm
tasks:
- name: Ensure libselinux-python installed
yum: name=libselinux-python state=present
- name: Ensure EPEL RPM installed
yum: name=http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm state=present
- name: Ensure Java 1.7 installed
yum: name=java-1.7.0-openjdk state=present
# Ideally we'd take RPMs from local repo, but because this is a hacky
# playbook I don't want the yum module to keep downloading only to find
# it doesn't need to install. So, we'll use stat and register to skip
# if already installed.
- name: Check for Elasticsearch (prevent re-download)
stat: path=/usr/share/elasticsearch/bin
register: escheck
- name: Ensure Elasticsearch is installed
yum: name={{ es }} state=present
when: escheck.stat.isdir is not defined
- name: Check for Logstash (prevent re-download)
stat: path=/opt/logstash
register: lscheck
- name: Ensure Logstash is installed
yum: name={{ ls }} state=present
when: lscheck.stat.isdir is not defined
- name: Ensure Apache installed
yum: name=httpd state=present
- name: Fetch Kibana
get_url: url={{ kibana }} dest=/var/tmp/kibana.tgz
- name: Extract Kibana
command: /bin/tar xzf /var/tmp/kibana.tgz -C /var/www/html creates=/var/www/html/kibana-{{ kbver }}
- name: Symlink Kibana basedir
file: src=/var/www/html/kibana-{{ kbver }} dest=/var/www/html/kibana
state=link
- name: Add logstash binary to path
lineinfile: dest=/etc/profile.d/logstash.sh
state=present create=yes
line='export PATH=$PATH:/opt/logstash/bin'
owner=root group=root mode=0644
- name: Ensure services are running
service: name={{ item }} state=running enabled=true
with_items:
- httpd
- logstash
- elasticsearch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment