Skip to content

Instantly share code, notes, and snippets.

View initcron's full-sized avatar

Gourav Shah initcron

View GitHub Profile
@initcron
initcron / gist:9679423
Created March 21, 2014 04:17
knife search
498 knife search users "*:*"
499 knife search node "*:*"
500 ohai
501 knife search node "plat*:ubuntu"
502 knife search node "*:*"
503 knife search node
504 knife search node "*:*"
505 knife search node "ipaddress:10.*"
506 knife search node "ipaddress:10.*" -a platform
507 knife search node "ipaddress:10.* AND platform:ubuntu"
@initcron
initcron / base.rb
Created March 21, 2014 06:02
base role
name "base"
description "Base Server Role"
run_list "recipe[ntp]", "recipe[motd]", "recipe[chef-client]"
{
"id": "mark",
"production" : {
"comment": "Mark in Production",
"uid": 3001,
"gid": 0,
"home": "/home/mark",
"shell": "/bin/zsh"
},
mark = data_bag_item('admins','mark')
user mark['id'] do
comment mark[node.chef_environment]['comment']
uid mark[node.chef_environment]['uid']
gid mark[node.chef_environment]['gid']
home mark[node.chef_environment]['home']
shell mark[node.chef_environment]['shell']
end
@initcron
initcron / gist:10014719
Created April 7, 2014 04:12
Encrypted data bags
openssl rand -base64 512 | tr -d '\r\n' > ~/.chef/encrypted_data_bag_secret
@initcron
initcron / default.rb
Created April 7, 2014 04:34
Encrypted Data Bags
search( :users, "*:*" ).each do | user_account |
user_id = user_account['id']
user_data = Chef::EncryptedDataBagItem.load("users", user_id)
user user_data['id'] do
comment user_data['comment']
uid user_data['uid']
gid user_data['gid']
home user_data['home']
@initcron
initcron / file.rb
Created April 7, 2014 06:23
profider for swap_file, step 2
use_inline_resources
action :create do
resource_name = new_resource.file_name.gsub('/', '_')
execute "create#{resource_name}" do
command "dd if=/dev/zero of=#{new_resource.file_name} bs=1024 count=#{new_resource.blocks}"
not_if { ::File.exists?(new_resource.file_name) }
@initcron
initcron / file.rb
Created April 7, 2014 06:48
action_destroy for swap/providers/file.rb
action :destroy do
resource_name = new_resource.file_name.gsub('/', '_')
execute "swapoff#{resource_name}" do
command "swapoff #{new_resource.file_name}"
only_if "grep -q #{new_resource.file_name} /proc/swaps"
end
execute "delete#{resource_name}" do
@initcron
initcron / git_installed.bats
Created April 9, 2014 04:38
bats test for git
#!/usr/bin/env bats
@test "git binary is found in PATH" {
run which git
[ "$status" -eq 0 ]
}
@initcron
initcron / kitchen.yml
Created April 9, 2014 05:15
kitchen.yml after adding a test suite for git server
---
driver:
name: vagrant
provisioner:
name: chef_solo
platforms:
- name: ubuntu-12.04
- name: centos-6.4