Skip to content

Instantly share code, notes, and snippets.

{
"variables": {
"HOME": "{{env `HOME`}}",
"USER": "{{env `USER`}}",
"build_timestamp": "{{isotime \"20060102150405\"}}",
"vm_name": "centos7"
},
"builders": [{
"type": "vmware-iso",
"http_directory": "kickstart",
{
"handlers": {
"handler-graphite-status": {
"type": "pipe",
"command": "/opt/sensu/embedded/bin/handler-graphite-status.rb"
}
}
}
@trilitheus
trilitheus / myrecipe.rb
Last active August 29, 2015 14:09
Using user cookbook
users_manage 'mygroup' do
group_id 5001
action [:remove, :create]
end
@trilitheus
trilitheus / AWK sum columns.sh
Last active August 29, 2015 14:06
Awk sum columns
awk '{ sum+=$1} END {print sum}' FILENAME
awk '{ sum+=$5 } {sum2+=$6 } END {print sum, sum2}' FILENAME
# Ubuntu 12.04
- install chefdk
- update to 3.8+ kernel (raring backport minimal)
- install docker
- sudo chef gem install kitchen-docker
- ensure your user is sudo passwordless
@trilitheus
trilitheus / platforms.rb
Last active August 29, 2015 14:02
platform case
case node['platform']
when 'oracle'
case node['platform_version'].to_i
when '5'
pkg_src = 'http://myrepo/mypkg.OEL5.x86_64.rpm'
when '6'
pkg_src = 'http://myrepo/mypkg.OEL6.x86_64.rpm'
end
when 'redhat', 'centos'
case node['platform_version'].to_i
@trilitheus
trilitheus / graphite wrapper attributes.rb
Last active August 29, 2015 14:02
graphite storage schema
override['graphite']['storage_schemas'] = [
{
'name' => 'chef_reporting',
'pattern' => 'chef.*',
'retentions' => '30m:2y'
},
{
'name' => '2min_interval',
'pattern' => '.*\.2m\..*',
'retentions' => '2m:30d,30m:1y'
@trilitheus
trilitheus / Password attribute reset.rb
Last active August 29, 2015 14:02
Wipe password attributes before report to chef server
chef_gem 'chef-vault'
require 'chef-vault'
secrets = ChefVault::Item.load('secrets', 'my_app')
node.override['my_app']['password'] = secrets['password']
###################
## Do your thang ##
###################
require 'gitlab'
g = Gitlab.client(:endpoint => 'http(s)://gitlaburl/api/v3', :private_token => 'userprivatetoken')
user = g.user
# use per_page setting as gitlab uses pagination with default of 20 items
projects = g.projects(:per_page => '100')
puts "Projects accessible by user #{user.name}:"
projects.reverse.each do |project|