Skip to content

Instantly share code, notes, and snippets.

plain_pass = Chef::EncryptedDataBagItem.load("aws-admin-passwords", "svc_goagent")["password"]
p plain_pass
#if unix box
if node['platform'] == 'ubuntu'
@trekr5
trekr5 / gist:a00d8622300fb83a954f
Created March 16, 2015 11:39
local_users_spec.rb
describe 'core::local_users' do
before (stub_resources)
let (:chef_run) do
ChefSpec::SoloRunner.new do |node, server|
env = Chef::Environment.new
env.name 'my_environment'
env.override_attributes(encrypted_data_bag_secret_key_path: 'C:/tmp/vagrant-chef-2/encrypted_data_bag_secret')
allow(server).to receive(:encrypted_data_bag_secret_key_path).and_return(env.override_attributes)
@trekr5
trekr5 / gist:d4cd96a032a819dc93e3
Created March 23, 2015 18:46
restriction of access
def svc_create_user(user,shadow_password)
user user do
supports :manage_home => true
comment "chef created service user: #{user}"
home "/home/#{user}"
shell 'usr/sbin/nologin'
action :create
end
def remove_login_rights(user)
cookbook_file "ntrights.exe" do
source "ntrights.exe"
path "C:/users/#{user}"
mode '0644'
action :create_if_missing
notifies :run, 'execute[remove-right]', :immediately
end
def remove_login_rights(user)
cookbook_file "ntrights.exe" do
source "ntrights.exe"
path "/windows/temp"
mode '0644'
action :create_if_missing
notifies :run, 'execute[remove-right]', :immediately
end
execute "remove-right" do
it\cookbook-core>vagrant provision windows
windows: Loading Berkshelf datafile...
windows: Sharing cookbooks with VM
windows: Updating Vagrant's Berkshelf...
windows: Resolving cookbook dependencies...
windows: Fetching 'core' from source at .
windows: Using apt (2.6.1)
windows: Using chef-client (4.2.4)
windows: Using chocolatey (0.2.1) from https://github.com/chocolatey/chocolatey-cookbook.git (at master)
windows: Using chef_handler (1.1.6)
@trekr5
trekr5 / gist:e7e9deb528800a4775ee
Created March 30, 2015 10:24
chefspec test to ensure that decrypted databag returns data
require 'spec_helper'
describe 'core::local_users_linux' do
let (:chef_run) { ChefSpec::SoloRunner.new.converge('core::local_users_linux') }
let(:databag){Chef::EncryptedDataBagItem.load("aws-admin-passwords", "svc_goagent")}
before do
allow(databag).and_return({
@trekr5
trekr5 / gist:5f2ff2a7f3791918a0dd
Last active August 29, 2015 14:20
My elasticsearch query
client = Elasticsearch::Client.new hosts: [{host: 'localhost:9200', port: 9200}]
value = client.search index: logstash_date,
body: {
"facets"=> {
"0"=> {
"date_histogram"=> {
"field"=> "@timestamp",
"interval"=> "15m"
curl -XGET 'localhost:9200/logstash-2015.04.30/_search?pretty' -d '{
"facets": {
"3": {
"date_histogram": {
"field": "@timestamp",
"interval": "1m"
},
"global": true,
"facet_filter": {
"fquery": {
#!/bin/bash
# Dashing service
# Add this file to /etc/init.d/
# $ sudo cp dashboard /etc/init.d/
# Update variables DASHING_DIR, GEM_HOME, & PATH to suit your installation
# $ sudo nano /etc/init.d/dashboard
# Make executable
# $ sudo chmod 755 /etc/init.d/dashboard
# Update rc.d
# $ sudo update-rc.d dashboard defaults