Skip to content

Instantly share code, notes, and snippets.

View clauswitt's full-sized avatar

Claus Witt clauswitt

View GitHub Profile
## mysql::master
ruby_block "store_mysql_master_status" do
block do
node.set[:mysql][:master] = true
m = Mysql.new("localhost", "root", node[:mysql][:server_root_password])
m.query("show master status") do |row|
row.each_hash do |h|
node.set[:mysql][:master_file] = h['File']
node.set[:mysql][:master_position] = h['Position']
end
@clauswitt
clauswitt / Rakefile
Created December 17, 2013 08:47
Various files for our chef server setup
#
# Rakefile for Chef Server Repository
#
# Author:: Adam Jacob (<adam@opscode.com>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
activate :deploy do |deploy|
deploy.build_before = true
deploy.method = :rsync
deploy.host = "hostname.com"
deploy.path = "/opt/sites/hostname.com"
deploy.user = "deploy"
end
{
"run_list": [
"role[hostname-setup]"
]
}
server {
listen 80;
server_name sitename.com;
access_log /var/log/nginx/sitename.access.log;
root /opt/sites/sitename.com;
index index.html index.htm;
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf)$ {
expires max;
access_log off;
directory "/opt/sites" do
owner "deploy"
group "deploy"
mode 00755
action :create
end
directory "/opt/sites/sitename.com" do
owner "deploy"
group "deploy"
{
"id": "deploy",
"comment": "Deploy User",
"groups": ["sysadmin","devops","developers"],
"email": "email of user",
"shell": "\/bin\/zsh",
"home": "\/home\/deploy",
"ssh_keys": ["public ssh key"],
"ssh_keygen": false,
"dotfiles": "https://github.com/username/dotfiles.git"
include_recipe "git"
search( :users, "dotfiles:*" ).each do |u|
user_id = u["id"]
directory "/home/#{user_id}/bin" do
owner user_id
group user_id
mode "0755"
action :create
end
name "base"
description "base role"
run_list [
"recipe[chef-solo-search]",
"recipe[apt]",
"recipe[apt-update]",
"recipe[ntp]",
"recipe[git]",
"recipe[zsh]",
"recipe[tmux]",
newpost() {
middleman article $1
vim `gsts |awk '{print \$2}'`
}