Still hitting the encoding conversion error

This commit is contained in:
Timor Raiman 2013-11-20 14:22:59 +02:00 committed by Arik Fraimovich
parent 63851b16af
commit 11d331c051
14 changed files with 403 additions and 107 deletions

View File

@ -0,0 +1 @@
metadata

View File

@ -0,0 +1,73 @@
redash Cookbook
=================
TODO: Enter the cookbook description here.
e.g.
This cookbook makes your favorite breakfast sandwich.
Requirements
------------
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
Expect to have these attriburtes defined:
node['postgresql']['password']['postgres'] <=== used for the initial connection to PG, where the redash role+databases are created
e.g.
#### packages
- `toaster` - thelight needs toaster to brown your bagel.
Attributes
----------
TODO: List you cookbook attributes here.
e.g.
#### thelight::default
<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><tt>['thelight']['bacon']</tt></td>
<td>Boolean</td>
<td>whether to include bacon</td>
<td><tt>true</tt></td>
</tr>
</table>
Usage
-----
#### thelight::default
TODO: Write usage instructions for each cookbook.
e.g.
Just include `thelight` in your node's `run_list`:
```json
{
"name":"my_node",
"run_list": [
"recipe[thelight]"
]
}
```
Contributing
------------
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
e.g.
1. Fork the repository on Github
2. Create a named feature branch (like `add_component_x`)
3. Write your change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github
License and Authors
-------------------
Authors: TODO: List authors

View File

@ -0,0 +1,39 @@
default["redash"]["install_path"] = "/opt"
default["redash"]["user"] = "redash"
default['redash']['redis_url'] = "redis://localhost:6379"
default['redash']['db']['user'] = "redash"
default['redash']['db']['password'] = "secureredisecure"
#default['redash']['db']['host'] = "localhost"
default['redash']['db']['port'] = 5432
default['redash']['db']['dbname'] = "redash_db0"
default['redash']['cfg']['dbname'] = "redash_cfgdb0"
default['redash']['cfg']['user'] = "redash"
default['redash']['cfg']['password'] = "secureredisecure"
default['redash']['cfg']['host'] = node['redash']['db']['host']
default['redash']['cfg']['port'] = 5432
default['redash']['db']['postgres_pwd'] = node['postgresql']['password']['postgres']
default['redash']['cfg']['postgres_pwd'] = node['postgresql']['password']['postgres']
#Accept logins from open id's verified by google accounts:
default['redash']['allow']['google_app_domain'] = "everything.me"
#Two strings with python list inside...:
default['redash']['allow']['google_app_users'] = ['joe@gmail.com','max@gmail.com']
default['redash']['allow']['admins'] = ['timor@everything.me','arik@everything.me']
default['redash']['workers_count'] = 2
default['redash']['max_connections'] = 3
default['redash']['cookie_secret'] = "c292a0a3aa32397cdb050e233733900f"
default['redash']['server']['log'] = node['redash']['install_path']+"/redash/log/server.log"
default['redash']['worker']['log'] = node['redash']['install_path']+"/redash/log/worker.log"
default['redash']['server']['py'] = "./main"
default['redash']['worker']['py'] = "./main"
default['redash']['svlog_opt'] = "-tt"

View File

@ -0,0 +1,17 @@
name 'redash'
maintainer 'Everything.me'
maintainer_email 'timor@everything.me'
license 'All rights reserved'
description 'Installs/Configures redash'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.4'
depends "postgresql"
depends "python"
depends "ark"
depends "database"
%w(python dhcp sysctl git).each do |cookbook|
depends cookbook
end
depends 'runit', '>= 1.1.0'

View File

@ -0,0 +1,125 @@
#
# Cookbook Name:: redash
# Recipe:: default
#
include_recipe "postgresql::client"
include_recipe "python"
include_recipe "runit"
#Enable cheff to interact with pg:
include_recipe "database::postgresql"
#Download and deploy the redash release
#TODO: version should be acc. to what's in metadata.rb
#TODO: install path should be a configurable attribute
user node['redash']['user'] do
system true
end
#Ark fails due to errors in remote_file not telling rest-client to expect binary..
#solution: use an older rest-client..
chef_gem "rest-client__p" do
action :purge
package_name "rest-client"
end
chef_gem "rest-client__i" do
action :install
package_name "rest-client"
version "1.5.0"
end
ark "bla" do
#url "http://github.com/EverythingMe/redash/releases/download/v0.1.35/redash.35.tar.gz"
#url "http://www.xmlcan.ca/~timor/redash.35.tar.gz"
url "http://www.xmlcan.ca/~timor/bla.tar.gz"
action :put
path node["redash"]["install_path"]
#Due to peculiarity of the way the archive gets created:
strip_leading_dir false
end
#Install dependencies acc. to file:
bash ":install pip dependencies" do
code <<-EOS
cd #{node["redash"]["install_path"]}/redash
pip install -r ./rd_service/requirements.txt
EOS
end
#Configure:
template "#{node["redash"]["install_path"]}/redash/rd_service/settings.py" do
source "settings.py.erb"
end
#Setup pg user(s) and database(s):
pg_db_super_connection = {
:host => node['redash']['db']['host'],
:port => node['redash']['db']['port'],
:username => 'postgres',
:password => node['redash']['db']['postgres_pwd']
}
pg_cfg_super_connection = {
:host => node['redash']['cfg']['host'],
:port => node['redash']['cfg']['port'],
:username => 'postgres',
:password => node['redash']['cfg']['postgres_pwd']
}
#The data db:
postgresql_database node['redash']['db']['dbname'] do
connection pg_db_super_connection
action :create
end
#The configuration db:
postgresql_database node['redash']['cfg']['dbname'] do
connection pg_cfg_super_connection
action :create
end
postgresql_database_user "redash_db_user" do
username node['redash']['db']['user']
connection pg_db_super_connection
password node['redash']['db']['password']
database_name node['redash']['db']['dbname']
privileges [:all]
action [:create,:grant]
end
postgresql_database_user "redash_cfg_user" do
username node['redash']['cfg']['user']
connection pg_cfg_super_connection
password node['redash']['cfg']['password']
database_name node['redash']['cfg']['dbname']
privileges [:all]
action [:create,:grant]
end
#Initialize the DB, connecting as normal user:
#Setup pg user(s) and database(s):
pg_db_connection = {
:host => node['redash']['db']['host'],
:port => node['redash']['db']['port'],
:user => node['redash']['db']['user'],
:password => node['redash']['db']['password'],
:dbname => node['redash']['cfg']['dbname']
}
constr = pg_db_connection.map{|(k,v)| "#{k}=#{v}"}.join(" ")
bash ":initialize db" do
code <<-EOS
cd #{node["redash"]["install_path"]}/redash
psql "#{constr}" < ./rd_service/data/tables.sql
EOS
end
#Install runit scripts and bring the system up:
runit_service "redash-server"
runit_service "redash-worker"

View File

@ -0,0 +1,38 @@
"""
Settings module generated and dropped off by Chef.
Will be overwritten.
"""
import django.conf
REDIS_URL = "<%= node['redash']['redis_url'] %>"
# Connection string for the database that is used to run queries against
CONNECTION_STRING = "user=<%= node['redash']['db']['user'] %> password=<%= node['redash']['db']['password'] %> host=<%= node['redash']['db']['host'] %> port=<%= node['redash']['db']['port'] %> dbname=<%= node['redash']['db']['dbname'] %>"
# Connection string for the operational databases (where we store the queries, results, etc)
INTERNAL_DB_CONNECTION_STRING = "user=<%= node['redash']['cfg']['user'] %> password=<%= node['redash']['cfg']['password'] %> host=<%= node['redash']['cfg']['host'] %> port=<%= node['redash']['cfg']['port'] %> dbname=<%= node['redash']['cfg']['dbname'] %>"
# Google Apps domain to allow access from; any user with email in this Google Apps will be allowed
# access
GOOGLE_APPS_DOMAIN = "<%= node['redash']['allow']['google_app_domain'] %>"
# Email addresses of specific users not from the above set Google Apps Domain, that you want to
# allow access to re:dash
ALLOWED_USERS = <%= Chef::JSONCompat.to_json node['redash']['allow']['google_app_users'] %>
# Email addresses of admin users
ADMINS = <%= Chef::JSONCompat.to_json node['redash']['allow']['admins'] %>
STATIC_ASSETS_PATH = "<%= node['redash']['install_path'] %>/rd_ui/dist/"
WORKERS_COUNT = <%= node['redash']['workers_count'] %>
MAX_CONNECTIONS = <%= node['redash']['max_connections'] %>
COOKIE_SECRET = "c292a0a3aa32397cdb050e233733900f"
# Configuration of the operational database for the Django models
django.conf.settings.configure(DATABASES = { 'default': {
'ENGINE': 'dbpool.db.backends.postgresql_psycopg2',
'OPTIONS': {'MAX_CONNS': <%= node['redash']['max_connections'] %>, 'MIN_CONNS': 1},
'NAME': '<%= node['redash']['db']['dbname'] %>',
'USER': '<%= node['redash']['db']['user'] %>',
'PASSWORD': '<%= node['redash']['db']['password'] %>',
'HOST': '<%= node['redash']['db']['host'] %>',
'PORT': '<%= node['redash']['db']['port'] %>',
},}, TIME_ZONE = 'UTC')

View File

@ -0,0 +1,3 @@
#!/bin/sh
exec svlogd <%= node['redash']['svlog_opt'] %> <%= node['redash']['server']['log'] %>

View File

@ -0,0 +1,4 @@
#!/bin/sh
exec 2>&1
exec chpst -u <%= node['redash']['user'] %> env python <%= node['redash']['server']['py'] %>

View File

@ -0,0 +1,3 @@
#!/bin/sh
exec svlogd <%= node['redash']['svlog_opt'] %> <%= node['redash']['worker']['log'] %>

View File

@ -0,0 +1,4 @@
#!/bin/sh
exec 2>&1
exec chpst -u <%= node['redash']['user'] %> env python <%= node['redash']['worker']['py'] %>

2
vagrant/Berksfile Normal file
View File

@ -0,0 +1,2 @@
cookbook 'redash', path: '../cookbooks/redash'
cookbook 'apt'

67
vagrant/Berksfile.lock Normal file
View File

@ -0,0 +1,67 @@
{
"sources": {
"redash": {
"path": "../cookbooks/redash"
},
"apt": {
"locked_version": "2.3.0"
},
"postgresql": {
"locked_version": "3.2.0"
},
"build-essential": {
"locked_version": "1.4.2"
},
"openssl": {
"locked_version": "1.1.0"
},
"python": {
"locked_version": "1.4.4"
},
"yum": {
"locked_version": "2.4.2"
},
"ark": {
"locked_version": "0.4.0"
},
"database": {
"locked_version": "1.5.2"
},
"mysql": {
"locked_version": "4.0.4"
},
"aws": {
"locked_version": "1.0.0"
},
"xfs": {
"locked_version": "1.1.0"
},
"dhcp": {
"locked_version": "2.0.1"
},
"ruby-helper": {
"locked_version": "0.0.1"
},
"helpers-databags": {
"locked_version": "1.0.0"
},
"sysctl": {
"locked_version": "0.3.4"
},
"git": {
"locked_version": "2.7.0"
},
"dmg": {
"locked_version": "2.0.8"
},
"windows": {
"locked_version": "1.11.0"
},
"chef_handler": {
"locked_version": "1.1.4"
},
"runit": {
"locked_version": "1.4.0"
}
}
}

117
vagrant/Vagrantfile vendored
View File

@ -5,114 +5,29 @@
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network :forwarded_port, guest: 80, host: 8080
config.berkshelf.enabled = true
#config.omnibus.chef_version = :latest
config.omnibus.chef_version = "11.6.0"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network :private_network, ip: "192.168.33.10"
config.vm.network "forwarded_port", guest: 8888, host: 9999
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network :public_network
# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true
config.vm.provision :chef_solo do |chef|
#Run apt-get update before anything else (specifically postgresql)..
chef.add_recipe "apt"
chef.add_recipe "redash"
chef.add_recipe "postgresql"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
chef.json = {
"apt" => {"compiletime" => true},
"postgresql" => {"password" => {"postgres" => "securepass"}},
"redash" => {"db" => {"host" => "localhost"}},
}
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider :virtualbox do |vb|
# # Don't boot with headless mode
# vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
# vb.customize ["modifyvm", :id, "--memory", "1024"]
# end
#
# View the documentation for the provider you're using for more
# information on available options.
# Enable provisioning with Puppet stand alone. Puppet manifests
# are contained in a directory path relative to this Vagrantfile.
# You will need to create the manifests directory and a manifest in
# the file precise32.pp in the manifests_path directory.
#
# An example Puppet manifest to provision the message of the day:
#
# # group { "puppet":
# # ensure => "present",
# # }
# #
# # File { owner => 0, group => 0, mode => 0644 }
# #
# # file { '/etc/motd':
# # content => "Welcome to your Vagrant-built virtual machine!
# # Managed by Puppet.\n"
# # }
#
# config.vm.provision :puppet do |puppet|
# puppet.manifests_path = "manifests"
# puppet.manifest_file = "site.pp"
# end
# Enable provisioning with chef solo, specifying a cookbooks path, roles
# path, and data_bags path (all relative to this Vagrantfile), and adding
# some recipes and/or roles.
#
# config.vm.provision :chef_solo do |chef|
# chef.cookbooks_path = "../my-recipes/cookbooks"
# chef.roles_path = "../my-recipes/roles"
# chef.data_bags_path = "../my-recipes/data_bags"
# chef.add_recipe "mysql"
# chef.add_role "web"
#
# # You may also specify custom JSON attributes:
# chef.json = { :mysql_password => "foo" }
# end
# Enable provisioning with chef server, specifying the chef server URL,
# and the path to the validation key (relative to this Vagrantfile).
#
# The Opscode Platform uses HTTPS. Substitute your organization for
# ORGNAME in the URL and validation key.
#
# If you have your own Chef Server, use the appropriate URL, which may be
# HTTP instead of HTTPS depending on your configuration. Also change the
# validation key to validation.pem.
#
# config.vm.provision :chef_client do |chef|
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
# chef.validation_key_path = "ORGNAME-validator.pem"
# end
#
# If you're using the Opscode platform, your validator client is
# ORGNAME-validator, replacing ORGNAME with your organization name.
#
# If you have your own Chef Server, the default validation client name is
# chef-validator, unless you changed the configuration.
#
# chef.validation_client_name = "ORGNAME-validator"
end
end

5
vagrant/notes Normal file
View File

@ -0,0 +1,5 @@
Download:
https://github.com/EverythingMe/redash/releases/download/v0.1.35/redash.35.tar.gz
--> /opt/redash
deploy postgresql db, sql file.
edit / replace settings file.