Created
March 3, 2014 18:20
-
-
Save colinsurprenant/9331289 to your computer and use it in GitHub Desktop.
Vangrantfile and Ansible playbook.yml for basic Elasticsearch and Logstash install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
vars: | |
base_deps: | |
- curl | |
- wget | |
- htop | |
- sysstat | |
- iotop | |
- screen | |
- git-core | |
- openjdk-7-jdk | |
install_user: "colin" | |
install_user_pubkey: "~{{ install_user }}/.ssh/id_rsa.pub" | |
logstash_distribution: "logstash-1.4.0.beta1" | |
logstash_target_dir: "/home/{{ install_user }}/logstash" | |
logstash_download_file: "{{ logstash_distribution }}.tar.gz" | |
logstash_download_url: "https://download.elasticsearch.org/logstash/logstash/{{ logstash_download_file }}" | |
elasticsearch_distribution: "elasticsearch-1.0.0" | |
elasticsearch_target_dir: "/home/{{ install_user }}/elasticsearch" | |
elasticsearch_download_file: "{{ elasticsearch_distribution }}.tar.gz" | |
elasticsearch_download_url: "https://download.elasticsearch.org/elasticsearch/elasticsearch/{{ elasticsearch_download_file }}" | |
tasks: | |
- name: update packages | |
apt: update_cache=yes | |
sudo: yes | |
- name: upgrade packages | |
apt: upgrade=full | |
sudo: yes | |
- name: dependencies | |
apt: pkg={{ item }} state=latest | |
with_items: base_deps | |
sudo: yes | |
- name: create user | |
action: user name={{ install_user }} group=admin shell=/bin/bash | |
sudo: yes | |
- name: setup authorized key(s) | |
action: authorized_key user={{ install_user }} key="{{ lookup('file', install_user_pubkey) }}" | |
sudo: yes | |
- name: setup logstash env | |
action: command mkdir -p {{ logstash_target_dir }} creates={{ logstash_target_dir}} | |
sudo: yes | |
sudo_user: "{{ install_user }}" | |
- name: download logstash | |
get_url: url={{ logstash_download_url }} dest="{{ logstash_target_dir }}/{{ logstash_download_file }}" | |
sudo: yes | |
sudo_user: "{{ install_user }}" | |
- name: extract logstash | |
command: tar -C {{ logstash_target_dir }} -zxf "{{ logstash_target_dir }}/{{ logstash_download_file }}" | |
sudo: yes | |
sudo_user: "{{ install_user }}" | |
- name: setup elasticsearch env | |
action: command mkdir -p {{ elasticsearch_target_dir }} creates={{ elasticsearch_target_dir}} | |
sudo: yes | |
sudo_user: "{{ install_user }}" | |
- name: download elasticsearch | |
get_url: url={{ elasticsearch_download_url }} dest="{{ elasticsearch_target_dir }}/{{ elasticsearch_download_file }}" | |
sudo: yes | |
sudo_user: "{{ install_user }}" | |
- name: extract elasticsearch | |
command: tar -C {{ elasticsearch_target_dir }} -zxf "{{ elasticsearch_target_dir }}/{{ elasticsearch_download_file }}" | |
sudo: yes | |
sudo_user: "{{ install_user }}" | |
- name: install elasticsearch-kopf plugin | |
command: chdir="{{ elasticsearch_target_dir }}/{{ elasticsearch_distribution }}" bin/plugin -install lmenezes/elasticsearch-kopf | |
sudo: yes | |
sudo_user: "{{ install_user }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant.configure("2") do |config| | |
config.ssh.forward_agent = true | |
config.vm.synced_folder "./", "/vagrant", :disabled => true | |
# AWS EC2 config | |
# | |
# $ vagrant up ec2 --provider=aws | |
# | |
# - make sure you correctly configure your AWS settings below | |
config.vm.define :ec2 do |target| | |
target.vm.box = "dummy" | |
target.ssh.username = "ubuntu" | |
target.vm.provider :aws do |aws, override| | |
aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"] | |
aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"] | |
aws.keypair_name = ENV["AWS_KEYPAIR_NAME"] | |
override.ssh.private_key_path = ENV["AWS_PRIVATE_KEY_PATH"] | |
aws.ami = "ami-f9327c90" # Ubuntu 13.04, us-east-1, 64bits, ebs root | |
aws.instance_type = "m1.small" | |
aws.region = "us-east-1" | |
aws.tags = {"Name" => "myname"} | |
aws.security_groups = ["mygroup"] | |
end | |
target.vm.provision :ansible do |ansible| | |
ansible.playbook = "playbook.yml" | |
end | |
end | |
# Virtualbox config | |
# | |
# $ vagrant up vbox | |
# | |
# - change target.vm.box to your need | |
config.vm.define :vbox do |target| | |
# veewee-ubuntu-13.04 created using veewee | |
# bundle exec veewee vbox define 'veewee-ubuntu-13.04' 'ubuntu-13.04-server-amd64' | |
# bundle exec veewee vbox build 'veewee-ubuntu-13.04' | |
# bundle exec veewee vbox export 'veewee-ubuntu-13.04' | |
target.vm.box = "veewee-ubuntu-13.04" | |
target.vm.provider :virtualbox do |vb| | |
vb.customize ["modifyvm", :id, "--memory", 1024] | |
end | |
target.vm.provision :ansible do |ansible| | |
ansible.playbook = "playbook.yml" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment