Skip to content

Instantly share code, notes, and snippets.

@spuder
Last active March 1, 2017 15:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spuder/519e605a03eab9c2a136 to your computer and use it in GitHub Desktop.
Save spuder/519e605a03eab9c2a136 to your computer and use it in GitHub Desktop.
Dashing cookbook

Working cookbook for dashing

https://github.com/benbria/dashing-chef

First you need to install RVM. This installs sitewide as root, which really is a bad idea unless no one else uses this machine.

sudo apt-get update; apt-get install curl -y
command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
\curl -sSL https://get.rvm.io | sudo bash
source /usr/local/rvm/scripts/rvm
rvm install 1.9.3-p551 --binary --max-time 20
rvm use 1.9.3-p551
#gem install bundler
#gem install dashing

In your runlist, add the following, (where acme-dashing is the name of your wrapper cookbook)

{
  "name": "dashing",
  "description": "Manages dashing site",
  "json_class": "Chef::Role",
  "default_attributes": {
    "dashing": {
      "ruby_env": "source /etc/profile.d/rvm.sh && rvm use ruby-1.9.3-p551 && gem install bundler && gem install dashing",
      "js_env": "source /usr/local/src/nvm/nvm.sh && nvm use v0.8.16"
    }
  },
  "override_attributes": {

  },
  "chef_type": "role",
  "run_list": [
    "recipe[apt]",
    "recipe[nodejs]",
    "recipe[acme-dashing]"
  ],
  "env_run_lists": {

  }
}

Additional information

https://github.com/benbria/dashing-chef/issues/3

source "https://supermarket.chef.io"
metadata
cookbook 'apt'
cookbook 'nodejs'
cookbook 'dashing'
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:9090;
}
}
include_recipe 'dashing'
package 'git' do
action :install
end
directory '/opt/dashing' do
action :create
end
cookbook_file '/opt/dashing/dashing-lab.pem' do
source 'dashing-dev.pem'
action :create
end
cookbook_file '/opt/dashing/dashing-prod.pem' do
source 'dashing-prod.pem'
action :create
end
git "/opt/dashing/devops-dashboard" do
repository "http://git.example.com/devops/devops-dashboard.git"
reference "master"
action :sync
notifies :restart, "dashing_dashboard[/opt/dashing/devops-dashboard]"
end
# While you could use a nginx cookbook to do this, it is way more complicated
package 'nginx' do
action :install
end
template '/etc/nginx/sites-available/dashing' do
source 'dashing.erb'
notifies :restart, 'service[nginx]'
end
link '/etc/nginx/sites-enabled/dashing' do
to '/etc/nginx/sites-available/dashing'
notifies :restart, 'service[nginx]'
end
file '/etc/nginx/sites-enabled/default' do
action :delete
notifies :restart, 'service[nginx]'
end
dashing_dashboard "/opt/dashing/devops-dashboard" do
action :create
port 9090
end
service 'nginx' do
action :start
end
default['dashing']['ruby_env'] = 'source /etc/profile.d/rvm.sh && rvm use ruby-1.9.3-p551 && gem install bundler && gem install dashing'
default['dashing']['js_env'] = 'source /usr/local/src/nvm/nvm.sh && nvm use v0.8.16'
---
driver:
name: vagrant
provisioner:
name: chef_solo
platforms:
- name: ubuntu-14.04
driver:
network:
- ["forwarded_port", {guest: 9090, host: 9090}]
suites:
- name: default
run_list:
- recipe[apt]
- recipe[nodejs]
- recipe[dashing::default]
- recipe[nd-dashing]
attributes:
dashing:
service_type: 'upstart'
ruby_env: 'source /etc/profile.d/rvm.sh && rvm use ruby-1.9.3-p551 && gem install bundler && gem install dashing'
js_env: 'source /usr/local/src/nvm/nvm.sh && nvm use v0.8.16'
@spuder
Copy link
Author

spuder commented Jul 16, 2015

Note, this doesn't always start the service automatically. Not sure why that is.

cd /opt/dashing/devops
dashing start -p 9090

Watch for errors that stream by

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment