Skip to content

Instantly share code, notes, and snippets.

View nathenharvey's full-sized avatar

Nathen Harvey nathenharvey

View GitHub Profile
# This is a Chef recipe file. It can be used to specify resources which will
# apply configuration to a server.
log "Welcome to Chef, #{node["starter_name"]}!" do
level :info
cookbook_file "helloworld.txt" do
path "/Users/rossmohan/HELLOWORLD.TXT"
action :create_if_missing
end
end
{"foo" => "1.0", "bar" => "latest"}.each do |pkg,ver|
if ver == "latest"
yum_package pkg do
action :upgrade
end
else
yum_package pkg do
version ver
action :install
end
@nathenharvey
nathenharvey / attributes.rb
Created November 26, 2013 03:38
A quick cookbook for installing maldetect
# cookbooks/maldetect/attributes/attributes.rb
default["maldetect"]["version"] = "1.4.2"
default["maldetect"]["checksum"] = "e118760d2440832564ac72977abb95a6141c25b520f21dfa30a89e1f6c835d63"
default[:vertx][:version] = '2.0.2'
default[:vertx][:home] = '/srv/vertx'
default[:vertx][:url] = 'http://dl.bintray.com/vertx/downloads/'
# cookbooks/users/attributes/default.rb
default["sudo"]["users"] = ["userA", "userB"]
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This is a Vagrant configuration file. It can be used to set up and manage
# virtual machines on your local system or in the cloud. See http://downloads.vagrantup.com/
# for downloads and installation instructions, and see http://docs.vagrantup.com/v2/
# for more information and configuring and using Vagrant.
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
#
# Cookbook Name:: calagator
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
include_recipe "database::postgresql"
data_bag("vhosts").each do |site|
site_data = data_bag_item("vhosts", site)
site_name = site_data["id"]
document_root = "/srv/apache/#{site_name}"
template "/etc/apache2/sites-available/#{site_name}" do
source "custom-vhost.erb"
mode "0644"
variables(
:document_root => document_root,
@nathenharvey
nathenharvey / failed execute resource
Created September 19, 2013 23:13
example of a failed 'execute' resource. This will cause the chef-client run to fail and throw an exception.
cookbooks/foo/recipes/default.rb
#
# Cookbook Name:: foo
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#