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
Works:
irb(main):001:0> require "openssl"
=> true
irb(main):002:0>
Doesn't work:
irb(main):001:0> require "puppet/network/xmlrpc/client"
Puppet::Error: You must have the Ruby openssl library installed
#!/bin/bash
DIR="$1"
# only start rename when $DIR is not root or empty
if [ "$DIR" == "" ] || [ "$DIR" == "/" ]; then
echo "No directory given" >&2
exit 1
fi
newproperty(:mode) do
desc "Set trunking mode of the interface."
defaultto(:undef)
newvalues(:undef, :access, :dot1q, :dynamic, :private, :trunk)
end
newproperty(:trunk_native_vlan) do
desc "Set native VLAN when interface is in trunking mode"
defaultto(:undef)
newvalues(:undef, /^\d+$/)
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') }
# $resources = hiera_hash('resources')
$resources = {
'postgresql::database' => {
'db1' => { db1 params },
},
# ...
}
create_create_resources($resources)
@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',
@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

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
# 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'
# }
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: [
{