Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ language: python
python: "2.7"

before_install:
# Make sure everything's up to date.
# Make sure everything's up to date.
- sudo apt-get update -qq
- sudo apt-get install -qq python-apt python-pycurl git python-pip

install:
# Install Ansible.
# Install Ansible.
- pip install ansible

script:
Expand All @@ -27,7 +27,6 @@ script:
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)


# 1st: check syntax
- echo "***************************** SYNTAX CHECK test 2 (1) *****************************"
- ansible-playbook -i local.ini test2.yml --syntax-check
Expand All @@ -42,18 +41,30 @@ script:
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)

# 1st: check syntax
- echo "***************************** SYNTAX CHECK test 3 (1) *****************************"
- ansible-playbook -i local.ini test3.yml --syntax-check
# 2nd: Make sure we run the entire playbook
- echo "***************************** RUN PLAY test 3 (2) *****************************"
- ansible-playbook -i local.ini test3.yml --sudo -vvvv
# 3rd: Make sure our playbook is idempotent
- echo "***************************** Idempotence test test 3 (3) *****************************"
- >
ansible-playbook -i local.ini test3.yml --sudo -vvvv | tee ansible_output
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)

after_failure:
- echo -e "######IdepotanceLog #######"
- echo "******IdepotanceLog *******"
- sudo cat ansible_output
- echo -e "######Syslog#######"
- echo "******Syslog*******"
- sudo cat /var/log/syslog
- echo -e "######NerveLog#######"
- echo "******NerveLog*******"
- sudo cat /var/log/smartstack/nerve.log
- echo -e "######SerfLog#######"
- echo "******SerfLog*******"
- sudo cat /var/log/smartstack/serf.log
- echo -e "######SyanpaseLog#######"
- echo "******SyanpaseLog*******"
- sudo cat /var/log/smartstack/synapse.log
- echo -e "######AnsibleFacts#######"
- ansible -i 127.0.0.1, -m setup all -c local

- echo "******AnsibleFacts*******"
- ansible -i 127.0.0.1, -m setup all -c local
9 changes: 8 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ smartstack_env_variable :
#smartstack_services_files : "service.yml" # set a filename here to include extra vars for nerve/synapse
smartstack_base_log_dir : "/var/log/smartstack"

# Omnibus Options
smartstack_omnibus_install : False
smartstack_omnibus_url : "https://github.com/yetu/omnibus-smartstack/releases/download/0.0.1/smartstack_0.0.1-1_amd64.deb"
smartstack_omnibus_sha256 : "548fbc3a92ec951bc8b1c3b086f1a1731cd859b727fd5897b6d92013255721ea"
smartstack_omnibus_src : "/opt/smartstack/src"

#If you are using different stages such as dev,prod
# you should set this tag
# This tag will be appended at the end of the each service only if is set
Expand Down Expand Up @@ -138,5 +144,6 @@ ip_fallback : False # if my match rules dont work just match the first IP
ruby_install : False
ruby_version : 2.1


# TODO: Remove me Left for backward compatibility
smartstack_git_install : False

7 changes: 5 additions & 2 deletions demo/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ Vagrant.configure("2") do |config|
config.vm.box_url = "http://files.vagrantup.com/precise64.box"

## Number of nodes
nodes = 2
nodes = 3
rangeofips = 149
(1..nodes).each do |n|

vmip = "192.168.56.#{rangeofips + n.to_i}"
name = "demo#{n}"
##Node Conf
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--cpus", "1", "--memory", "512"]
end

config.vm.define name do |cfg|
cfg.vm.box = name
cfg.vm.host_name = name
Expand All @@ -26,7 +30,6 @@ Vagrant.configure("2") do |config|
cfg.vm.provider "virtualbox" do |vb|
vb.gui = false
end

##Ansible Provisioning
cfg.vm.provision :ansible do |ansible|
ansible.playbook = "vagrant-provision.yml"
Expand Down
56 changes: 55 additions & 1 deletion demo/defaults-var.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,56 @@
---
## Just a place holder file
## Just a place holder file
smartstack_services_files : ""
services_ports :
synapse : 3210
nerve : 3211
haproxy : 3212
mysql : 3306
superapp : 8000
postgresql : 5432

services :
superapp:
synapse :
discovery :
method : "serf"
haproxy :
server_options : "check inter 10s fastinter 5s downinter 8s rise 3 fall 2"
listen :
- "mode tcp"
- "timeout connect 10s"
- "timeout client 1h"
- "timeout server 1h"
port : "{{ services_ports['superapp'] }}"
nerve:
port : "{{ services_ports['superapp'] }}"
reporter_type : "serf"
check_interval : 1
checks:
- type : "http"
uri : "/health"
timeout : 1
rise : 2
fall : 3

postgresql:
synapse :
discovery :
method : "serf"
haproxy :
server_options : "check inter 10s fastinter 5s downinter 8s rise 3 fall 2"
listen :
- "mode tcp"
- "timeout connect 10s"
- "timeout client 1h"
- "timeout server 1h"
port : "{{ services_ports['postgresql'] }}"
nerve:
port : "{{ services_ports['postgresql'] }}"
reporter_type : "serf"
check_interval : 1
checks:
- type : "tcp"
timeout : 5
rise : 2
fall : 2
10 changes: 8 additions & 2 deletions demo/demo1-var.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
---
nerve_install : True
nerve_selected_services : [ "postgresql", "superapp" ]
synapse_install : False
nerve_selected_services : [ "postgresql" ]

serf_masters : [ "192.168.56.150", "192.168.56.151"]
serf_bind : "{{service_ip}}"
ip_match_enabled : True
ip_match_rules :
- regx : "192.168.56.*"
reg_match : true

smartstack_services_files : "services.yml"
#smartstack_services_files : "services.yml"
#####
#Since this is a demo we will make a list of packages to install
packages_to_install :
- "postgresql"
- "python-psycopg2"
###
ruby_install : True

## App config
color : "#D80000"
PS1 : '\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\[\e[0;31m\]\h\[\e[m\]:\w\$ '
20 changes: 14 additions & 6 deletions demo/demo2-var.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
---
nerve_install : False
nerve_install : True
nerve_selected_services : [ "superapp" ]

synapse_install : True
synapse_selected_services : [ "postgresql" ]
serf_bind : "{{service_ip}}"
synapse_selected_services : [ "postgresql"]

serf_masters : [ "192.168.56.150", "192.168.56.151"]
serf_bind : "{{service_ip}}"
ip_match_enabled : True
ip_match_rules :
- regx : "192.168.56.*"
reg_match : true

smartstack_services_files : "services.yml"
#smartstack_services_files : "services.yml"
#####
#Since this is a demo we will make a list of packages to install
packages_to_install :
- "postgresql-client"
- "python-psycopg2"

###
ruby_install : True
ruby_install : True

##
color : "#3300CC"
PS1 : '\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\[\e[1;34m\]\h\[\e[m\]:\w\$ '
22 changes: 22 additions & 0 deletions demo/demo3-var.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
nerve_install : False
synapse_install : True
synapse_selected_services : [ "superapp"]

serf_masters : [ "192.168.56.150", "192.168.56.151"]
serf_bind : "{{service_ip}}"
ip_match_enabled : True
ip_match_rules :
- regx : "192.168.56.*"
reg_match : true

#smartstack_services_files : "services.yml"
#####
#Since this is a demo we will make a list of packages to install
packages_to_install :
- "nginx"
###
ruby_install : True

## App config
PS1 : '\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\[\e[0;32m\]\h\[\e[m\]:\w\$ '
9 changes: 9 additions & 0 deletions demo/nginx_default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
}
location = /favicon.ico {
alias /var/www/media/images/favicon.X.ico;
}
}
47 changes: 47 additions & 0 deletions demo/superapp.py.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python
from wsgiref.simple_server import make_server
import psycopg2

def build_response():
conn_string = "host='localhost' dbname='superapp' user='superapp' password='superapp'"
print "Connecting to database\n ->%s" % (conn_string)

try:
conn = psycopg2.connect(conn_string)
postgres_status = " RUNNING "
print "RUNNING to psql"
except:
postgres_status = " NOT RUNNING :("
print not "RUNNING to psql"

machine = "{{ inventory_hostname }}"
my_color = "{{ color }}"

body = ""
body += "<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML 3.0//EN\">\n"
body += "<HTML>"
body += "<HEAD>"
body += "<TITLE>A Small Hello</TITLE>"
body += "</HEAD>"
body += "<BODY bgcolor=\"" + my_color + "\">"
body += "<H1>Hi I am " + machine + "</H1>"
body += "<H2>Postgresql status " + postgres_status + "</H2>"
body += "</BODY>"
body += "</HTML>"
return body

def hello_world_app(environ, start_response):
machine = "{{ inventory_hostname }}"
status = '200 OK' # HTTP Status
headers = [('Content-type', 'text/html'), ('x-server',machine)] # HTTP Headers
start_response(status, headers)

# The returned object is going to be printed
body = build_response()
return [body]

httpd = make_server('', 8000, hello_world_app)
print "Serving on port 8000..."

# Serve until process is killed
httpd.serve_forever()
Loading