Skip to content

Commit 84cabf0

Browse files
committed
Merge pull request #742 from im-denisenko/new-vagrantbox
New vagrantbox
2 parents 87628bd + 3b9a099 commit 84cabf0

25 files changed

+510
-146
lines changed

.travis.yml

+11-21
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,21 @@ matrix:
1111
- php: 5.6
1212

1313
env:
14-
global:
15-
- ES_VER=1.3.4
16-
- ES_MAPPER_ATTACHMENTS_VER=2.0.0.RC1
17-
- ES_TRANSPORT_THRIFT_VER=2.0.0
18-
- ES_GEOCLUSTER_FACET_VER=0.0.10
19-
- ES_WAIT_ON_MAPPING_CHANGE=true
20-
- MEMCACHE_VER=3.0.8
2114
matrix:
22-
- ES_REQUIRE=dev
23-
- ES_REQUIRE=no-dev
24-
25-
services:
26-
- memcached
15+
- ES_COMPOSER_NODEV=no
16+
- ES_COMPOSER_NODEV=yes
17+
18+
install:
19+
- /bin/bash ansible/provision.sh
2720

2821
before_script:
29-
- composer self-update
30-
- composer --${ES_REQUIRE} --prefer-source install
31-
- ./test/bin/install_php_memcache.sh
32-
- ./test/bin/run_elasticsearch.sh
33-
- ./test/bin/run_proxy.sh
22+
- mkdir -p build/logs
3423

3524
script:
36-
- mkdir -p build/logs
37-
- phpunit --coverage-clover build/logs/clover.xml -c test/
25+
- phpunit -c test/
3826

3927
after_script:
40-
- ./test/bin/show_logs.sh
41-
- php vendor/bin/coveralls -v
28+
- cat /var/log/elasticsearch/*.log
29+
- cat /var/log/nginx/*.log
30+
- cat build/logs/phpunit-tap.log
31+
- php vendor/bin/coveralls -v

README.markdown

+3-6
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ Dependencies
2222
| Project | Version | Required |
2323
|---------|---------|----------|
2424
|[Elasticsearch](https://github.com/elasticsearch/elasticsearch/tree/v1.3.4)|1.3.4|yes|
25-
|[Elasticsearch mapper attachments plugin](https://github.com/elasticsearch/elasticsearch-mapper-attachments/tree/v2.0.0.RC1)|2.0.0.RC1|no|
26-
|[Elasticsearch thrift transport plugin](https://github.com/elasticsearch/elasticsearch-transport-thrift/tree/v2.0.0)|2.0.0|no|
27-
|[Elasticsearch geocluster facet plugin](https://github.com/zenobase/geocluster-facet/tree/0.0.10)|0.0.10|no|
28-
29-
30-
25+
|[Elasticsearch mapper attachments plugin](https://github.com/elasticsearch/elasticsearch-mapper-attachments/tree/v2.3.2)|2.3.2|no|
26+
|[Elasticsearch thrift transport plugin](https://github.com/elasticsearch/elasticsearch-transport-thrift/tree/v2.3.0)|2.3.0|no|
27+
|[Elasticsearch geocluster facet plugin](https://github.com/zenobase/geocluster-facet/tree/0.0.11)|0.0.11|no|

Vagrantfile

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
# Elastica debian image
2-
#
3-
# All passwords and username (db, ...) are root / root
4-
#
5-
# The image has 2GB of memory and a size of 10GB
6-
7-
Vagrant::Config.run do |config|
8-
9-
config.vm.box = "debian-6.0.3-64-elastica-20120115"
10-
config.vm.box_url = "http://files.ruflin.com/vagrant/debian-6.0.3-64-elastica-20120528.box"
11-
config.vm.network :hostonly, "10.10.10.10"
12-
13-
config.vm.share_folder "project", "/project", "."
1+
2+
Vagrant.require_version ">= 1.4.0"
3+
4+
Vagrant.configure("2") do |config|
5+
6+
config.vm.box = "ubuntu/precise32"
7+
8+
config.vm.network :private_network, ip: "10.10.10.10"
9+
10+
config.vm.provision "shell" do |sh|
11+
sh.inline = "/bin/bash /vagrant/ansible/provision.sh"
12+
end
13+
14+
config.vm.provider :virtualbox do |vb|
15+
vb.customize ["modifyvm", :id, "--memory", "512"]
16+
end
17+
1418
end

ansible/es-playbook.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
3+
- name: Create a virtual machine
4+
hosts: localhost
5+
connection: local
6+
vars:
7+
- ES_VER: "1.3.4"
8+
- ES_SHORT_VER: "1.3"
9+
- ES_MAPPER_ATTACHMENTS_VER: "2.3.2"
10+
- ES_TRANSPORT_THRIFT_VER: "2.3.0"
11+
- ES_GEOCLUSTER_FACET_VER: "0.0.11"
12+
- ES_PROJECT_ROOT: "{{ lookup('env', 'ES_PROJECT_ROOT') }}"
13+
- ES_COMPOSER_NODEV: "{{ lookup('env', 'ES_COMPOSER_NODEV') }}"
14+
roles:
15+
- base
16+
- elasticsearch
17+
- memcached
18+
- nginx
19+
- php

ansible/provision.sh

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
# ----------------------------------------------------------------------------
4+
# Install ansible
5+
6+
sudo apt-get update -q
7+
sudo apt-get install python python-pip python-dev -yq
8+
sudo pip install ansible==1.8.2 -q
9+
sudo mkdir -p /etc/ansible/
10+
echo 'localhost' | sudo tee /etc/ansible/hosts
11+
12+
# ----------------------------------------------------------------------------
13+
# Configure playbook
14+
15+
# Write to stdout directly
16+
export PYTHONUNBUFFERED=1
17+
18+
# No cows >_<
19+
export ANSIBLE_NOCOWS=1
20+
21+
# Root of git repo
22+
if [ -z "$ES_PROJECT_ROOT" ]; then
23+
export ES_PROJECT_ROOT="$(dirname $(dirname $(readlink -f $0)))"
24+
fi
25+
26+
# Install or not require-dev packages
27+
if [ -z "$ES_COMPOSER_NODEV" ]; then
28+
export ES_COMPOSER_NODEV="no"
29+
fi
30+
31+
# ----------------------------------------------------------------------------
32+
# Run playbook
33+
34+
ansible-playbook $ES_PROJECT_ROOT/ansible/es-playbook.yml -v -s | tee /tmp/ansible-playbook-progress
35+
36+
if grep -q 'FATAL\|ERROR' /tmp/ansible-playbook-progress; then
37+
exit 1
38+
fi
39+
40+
# ----------------------------------------------------------------------------
41+
42+
echo 'Waiting for elasticsearch server ready'
43+
elasticsearch_ready() {
44+
http_code=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:9200")
45+
return $(test $http_code = "200")
46+
}
47+
while ! elasticsearch_ready; do
48+
echo -n '.'
49+
sleep 1s
50+
done
51+
52+
# ----------------------------------------------------------------------------
53+
# Say bye
54+
55+
echo 'Done'

ansible/roles/base/tasks/main.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
3+
- name: install base packages
4+
apt: >
5+
force=yes
6+
name={{ item }}
7+
state=present
8+
update_cache=no
9+
with_items:
10+
- curl
11+
- git
12+
- htop
13+
- vim
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
3+
- name: restart elasticsearch
4+
service: >
5+
name=elasticsearch
6+
state=restarted
+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
3+
- name: import ppa:webupd8team/java gpg key
4+
apt_key: >
5+
id=EEA14886
6+
keyserver=keyserver.ubuntu.com
7+
state=present
8+
9+
- name: add ppa:webupd8team/java repository
10+
apt_repository: >
11+
repo="deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main"
12+
state=present
13+
update_cache=yes
14+
15+
- name: accept oracle license
16+
shell: >
17+
echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
18+
19+
- name: install java
20+
apt: >
21+
force=yes
22+
name={{ item }}
23+
state=present
24+
update_cache=no
25+
with_items:
26+
- oracle-java7-installer
27+
- oracle-java7-set-default
28+
29+
- name: import elasticsearch gpg key
30+
apt_key: >
31+
id=D88E42B4
32+
keyserver=pgp.mit.edu
33+
state=present
34+
35+
- name: add elasticsearch repository
36+
apt_repository: >
37+
repo="deb http://packages.elasticsearch.org/elasticsearch/{{ ES_SHORT_VER }}/debian stable main"
38+
state=present
39+
update_cache=yes
40+
41+
- name: install elasticsearch
42+
apt: >
43+
force=yes
44+
name=elasticsearch={{ ES_VER }}
45+
state=present
46+
update_cache=no
47+
48+
- name: install mapper-attachments plugin
49+
command: >
50+
creates=/usr/share/elasticsearch/plugins/mapper-attachments
51+
/usr/share/elasticsearch/bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/{{ ES_MAPPER_ATTACHMENTS_VER }}
52+
53+
- name: install geocluster-facet plugin
54+
command: >
55+
creates=/usr/share/elasticsearch/plugins/geocluster-facet
56+
/usr/share/elasticsearch/bin/plugin -install geocluster-facet --url https://github.com/zenobase/geocluster-facet/releases/download/{{ ES_GEOCLUSTER_FACET_VER }}/geocluster-facet-{{ ES_GEOCLUSTER_FACET_VER }}.jar
57+
58+
- name: install transport-thrift plugin
59+
command: >
60+
creates=/usr/share/elasticsearch/plugins/transport-thrift
61+
/usr/share/elasticsearch/bin/plugin -install elasticsearch/elasticsearch-transport-thrift/{{ ES_TRANSPORT_THRIFT_VER }}
62+
63+
- name: create elasticsearch config
64+
template: >
65+
dest=/etc/elasticsearch/elasticsearch.yml
66+
src=config.yml.j2
67+
notify: restart elasticsearch
68+
69+
- name: create elasticsearch service config
70+
template: >
71+
dest=/etc/default/elasticsearch
72+
src=service-default.j2
73+
notify: restart elasticsearch
74+
75+
- name: start elasticsearch
76+
service: >
77+
enabled=yes
78+
name=elasticsearch
79+
state=started
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#################################### Index ####################################
2+
3+
index.number_of_shards: 2
4+
index.number_of_replicas: 0
5+
6+
#################################### Plugin ###################################
7+
8+
plugin.mandatory: mapper-attachments,geocluster-facet,transport-thrift
9+
10+
############################## Network And HTTP ###############################
11+
12+
http.port: 9200
13+
thrift.port: 9500
14+
15+
################################## Discovery ##################################
16+
17+
discovery.zen.ping.multicast.enabled: false
18+
19+
################################## UDP ########################################
20+
21+
bulk.udp.enabled: true
22+
bulk.udp.bulk_actions: 5
23+
24+
################################## Scripting ##################################
25+
26+
script.disable_dynamic: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Service configuration file
2+
# http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/setup-service.html
3+
4+
# Run Elasticsearch as this user ID and group ID
5+
#ES_USER=elasticsearch
6+
#ES_GROUP=elasticsearch
7+
8+
# Heap Size (defaults to 256m min, 1g max)
9+
#ES_HEAP_SIZE=2g
10+
11+
# Heap new generation
12+
#ES_HEAP_NEWSIZE=
13+
14+
# max direct memory
15+
#ES_DIRECT_SIZE=
16+
17+
# Maximum number of open files, defaults to 65535.
18+
#MAX_OPEN_FILES=65535
19+
20+
# Maximum locked memory size. Set to "unlimited" if you use the
21+
# bootstrap.mlockall option in elasticsearch.yml. You must also set
22+
# ES_HEAP_SIZE.
23+
#MAX_LOCKED_MEMORY=unlimited
24+
25+
# Maximum number of VMA (Virtual Memory Areas) a process can own
26+
#MAX_MAP_COUNT=262144
27+
28+
# Elasticsearch log directory
29+
#LOG_DIR=/var/log/elasticsearch
30+
31+
# Elasticsearch data directory
32+
#DATA_DIR=/var/lib/elasticsearch
33+
34+
# Elasticsearch work directory
35+
#WORK_DIR=/tmp/elasticsearch
36+
37+
# Elasticsearch configuration directory
38+
#CONF_DIR=/etc/elasticsearch
39+
40+
# Elasticsearch configuration file (elasticsearch.yml)
41+
#CONF_FILE=/etc/elasticsearch/elasticsearch.yml
42+
43+
# Additional Java OPTS
44+
ES_JAVA_OPTS='-server'
45+
46+
# Configure restart on package upgrade (true, every other setting will lead to not restarting)
47+
#RESTART_ON_UPGRADE=true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
3+
- name: restart memcached
4+
service: >
5+
name=memcached
6+
state=restarted
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
3+
- name: install memcached
4+
apt: >
5+
force=yes
6+
name=memcached
7+
state=present
8+
update_cache=no
9+
10+
- name: start memcached
11+
service: >
12+
enabled=yes
13+
name=memcached
14+
state=started

ansible/roles/nginx/handlers/main.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
3+
- name: restart nginx
4+
service: >
5+
name=nginx
6+
state=restarted

ansible/roles/nginx/tasks/main.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
3+
- name: install nginx
4+
apt: >
5+
force=yes
6+
name=nginx
7+
state=present
8+
update_cache=no
9+
10+
- name: create mime.types
11+
template: >
12+
dest=/etc/nginx/mime.types
13+
src=mime.types.j2
14+
notify: restart nginx
15+
16+
- name: create nginx.conf
17+
template: >
18+
dest=/etc/nginx/nginx.conf
19+
src=nginx.conf.j2
20+
notify: restart nginx
21+
22+
- name: start nginx
23+
service: >
24+
enabled=yes
25+
name=nginx
26+
state=started

0 commit comments

Comments
 (0)