Skip to content

Instantly share code, notes, and snippets.

View DavidS's full-sized avatar
☁️
Currently working as @DavidS-om

David Schmitt DavidS

☁️
Currently working as @DavidS-om
View GitHub Profile
@DavidS
DavidS / gist:af669a7babf63bc2002832137a898fdd
Created October 21, 2019 16:47
pdk new module --template-url https://github.com/DavidS/modulesync_config/ --template-ref test --skip-interview foo-foo
david@davids:~/tmp$ pdk new module --template-url https://github.com/DavidS/modulesync_config/ --template-ref test --skip-interview foo-foo
pdk (INFO): Creating new module: foo-foo
[✔] Installing missing Gemfile dependencies.
pdk (INFO): Module 'foo' generated at path '/home/david/tmp/foo', from template 'https://github.com/DavidS/modulesync_config/'.
pdk (INFO): In your module directory, add classes with the 'pdk new class' command.
david@davids:~/tmp$ find foo/
foo/
foo/metadata.json
foo/templates
foo/manifests
describe 'something' do
let(:route) { instance_double('Net::IP::Route', 'route') }
before(:each) do
allow(Net::IP::Route).to receive(:new).with({ test: 'data' }).and_return(route)
end
it 'doesn't suck' do
expect(Net::IP).to receive(:routes).with(route)
provider.create(context, name, {input: 'foo'})
end
@DavidS
DavidS / bolt-tester.md
Created August 8, 2018 08:42
design exploration of using bolt for system-level testing

bolt as acceptance tester

require 'puppet/resource_api'
Puppet::ResourceApi.register_type(
name: 'file_test',
docs: <<-EOS,
This type provides Puppet with the capabilities to manage ...
EOS
features: [],
title_patterns: [
{
# This file was automatically generated on 2017-08-01 17:47:49 +0100.
# Use the 'puppet generate types' command to regenerate this file.
# This type provides Puppet with the capabilities to manage GPG keys needed
# by apt to perform package validation. Apt has it's own GPG keyring that can
# be manipulated through the `apt-key` command.
#
# apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F':
# source => 'http://apt.puppetlabs.com/pubkey.gpg'
# }
deb http://deb.debian.org/debian stretch main
deb http://deb.debian.org/debian stretch-updates main
deb http://security.debian.org/ stretch/updates main
@DavidS
DavidS / 00_README.md
Last active March 14, 2017 10:04
A re-implementation of apt_key

Draft for new type and provider API

Hi *,

The type and provider API has been the bane of my existence since I started writing native resources. Now, finally, we'll do something about it. I'm currently working on designing a nicer API for types and providers. My primary goals are to provide a smooth and simple ruby developer experience for both scripters and coders. Secondary goals were to eliminate server side code, and make puppet 4 data types available. Currently this is completely aspirational (i.e. no real code has been written), but early private feedback was encouraging.

To showcase my vision, this gist has the apt_key type and provider ported over to my propo

@DavidS
DavidS / simple_iis_resource.rb
Created January 20, 2017 16:32
The simplest possible resource type implementation: talking to a external API
Puppet::SimpleResource.define(
name: 'iis_application_pool',
docs: 'Manage an IIS application pool through a powershell proxy.',
attributes: {
ensure: {
type: 'Enum[present, absent]',
docs: 'Whether this ApplicationPool should be present or absent on the target system.'
},
name: {
type: 'String',
# $resources = hiera_hash('resources')
$resources = {
'postgresql::database' => {
'db1' => { db1 params },
},
# ...
}
create_create_resources($resources)
vagrant@localhost:~/tmp$ cat case.pp
warning("\$::kernel == '${::kernel}'")
case $::kernel {
default: { warning('default/Linux - default matched') }
Linux: { warning('default/Linux - Linux matched') }
}
case $::kernel {
default: { warning('default/\'Linux\' - default matched') }