Skip to content

Instantly share code, notes, and snippets.

@gsarjeant
gsarjeant / gist:b78367731424629ceceba565df237843
Created November 8, 2023 15:23
Polar - impersonation (annotated)
actor User {
permissions = ["impersonate"];
}
resource Document {
permissions = ["read"];
}
# a user can do anything some other user can do
# if they are allowed to impersonate that user and
@gsarjeant
gsarjeant / README.md
Created July 2, 2017 17:42 — forked from TJM/README.md
Puppet SCCM Client Install as a package

SCCM Install using Puppet "package"

This script was donated by a customer of ours. They have sent us a sanitized version of the script to share.

Please use this at your own risk, and fully understand what it is doing before using it!

The Problem:

SCCM Installation fires off in the background and you have no idea whether it worked or not. Also, if any other installs try to start while the SCCM setup is running, you will get an error.

@gsarjeant
gsarjeant / sample-vagrant-beaker-nodeset.yml
Created October 18, 2014 02:10
Sample beaker vagrant nodeset
OSTS:
centos-65-x64:
roles:
- master
platform: el-6-x86_64
#box : centos-65-x64-vbox436-nocm
box : puppetlabs/puppet-training-centos-6.5-pe-3.3.0
box_url : /Users/gsarjeant/Sites/build/vagrant/centos-6.5-pe-3.3.1.box
#box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
hypervisor : vagrant
@gsarjeant
gsarjeant / sample-beaker-rspec.rb
Created October 18, 2014 02:09
Sample beaker-rspec test
module_path = '/path/to/module/root/directory'
module_name = 'my_module'
# The test manifest should be a manifest in the tests directory of your module,
# which declares the class you want to include (e.g. include my_class)
test_manifest = "#{module_path}/tests/init.pp"
# Use puppet_module_install to scp the module directory from the host into the modulepath on the target VM
# NOTE: puppet_module_install is defined in beaker-rspec:
# https://github.com/puppetlabs/beaker-rspec/blob/master/lib/beaker-rspec/beaker_shim.rb
# The module name is the base name of the module directory with any leading namespace identifier removed
@gsarjeant
gsarjeant / puppet-manifest-shared-group.rb
Created October 18, 2014 01:29
Puppet manifest shared group
require 'spec_helper_acceptance'
# Defines a shared example group for solution manifests.
# Pass a manifest to this shared example group by declaring let(:manifest) { some_manifest }
# in the it_behaves_like "a puppet manifest" block in your test.
shared_examples_for "a puppet manifest" do
describe 'on first application' do
it 'should have empty stderr' do
apply_manifest(manifest, :catch_failures => true) do |r|
@gsarjeant
gsarjeant / Beaker-Gemfile.rb
Created October 17, 2014 21:58
Sample beaker Gemfile
# A sample Gemfile
source "https://rubygems.org"
gem "beaker"
gem "beaker-rspec"
gem "rake"
@gsarjeant
gsarjeant / serverspec-basic.rb
Created October 17, 2014 21:42
Basic serverspec test
# spec/localhost/httpd_spec.rb
require 'spec_helper'
describe package('httpd') do
it { should be_installed }
end
describe service('httpd') do
it { should be_enabled }
it { should be_running }
@gsarjeant
gsarjeant / rspec-test-init.pp
Last active August 29, 2015 14:07
Basic puppet class for rspec demo
class test {
file { '/tmp/test':
ensure => file,
owner => root,
group => root,
}
}
@gsarjeant
gsarjeant / rspec-puppet.basic.rb
Created October 17, 2014 21:22
Basic rspec-puppet test
require 'spec_helper'
describe('test', :type => :class) do
describe 'when called with no parameters' do
it {
should compile
should contain_file('/tmp/test').with({
@gsarjeant
gsarjeant / puppet-pre-commit
Last active August 29, 2015 14:07
Puppet module git pre-commit hook: no git-stash
#! /bin/sh
# If we don't have a HEAD, then this is the first commit and we can't do any of this
git show > /dev/null 2>&1
if [ $? -ne 0 ]; then exit 0; fi
EXITCODE=0
for file in `git diff-index --cached --diff-filter=AM --name-only HEAD`
do
echo "Validating ${file}..."